aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-12-24 01:16:02 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-12-24 01:16:02 -0500
commitf34548cb735b7a80bbbb0bdd09ad4c2173ba92d5 (patch)
treee53c9e39b3149221779c10595bc59fa02de4f45f /tools
parent76382b5bdb77c29ab430e1b82ef1c604c8dd113b (diff)
parent32b53076c31ce9159740b744d5eb5d9505312add (diff)
Merge branch 'sh/g3-prep' into sh/for-2.6.33
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile3
-rw-r--r--tools/perf/builtin-probe.c4
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/util/event.h4
-rw-r--r--tools/perf/util/probe-event.c15
-rw-r--r--tools/perf/util/probe-finder.h59
6 files changed, 56 insertions, 31 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 7814dbbd401d..4390d225686d 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -487,10 +487,11 @@ else
487 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); 487 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
488endif 488endif
489 489
490ifneq ($(shell sh -c "(echo '\#include <libdwarf/dwarf.h>'; echo '\#include <libdwarf/libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) 490ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
491 msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231); 491 msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231);
492 BASIC_CFLAGS += -DNO_LIBDWARF 492 BASIC_CFLAGS += -DNO_LIBDWARF
493else 493else
494 BASIC_CFLAGS += -I/usr/include/libdwarf
494 EXTLIBS += -lelf -ldwarf 495 EXTLIBS += -lelf -ldwarf
495 LIB_OBJS += util/probe-finder.o 496 LIB_OBJS += util/probe-finder.o
496endif 497endif
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 7e741f54d798..c1e6774fd3ed 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -38,6 +38,7 @@
38#include "util/strlist.h" 38#include "util/strlist.h"
39#include "util/event.h" 39#include "util/event.h"
40#include "util/debug.h" 40#include "util/debug.h"
41#include "util/debugfs.h"
41#include "util/symbol.h" 42#include "util/symbol.h"
42#include "util/thread.h" 43#include "util/thread.h"
43#include "util/session.h" 44#include "util/session.h"
@@ -205,6 +206,9 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
205 if ((!session.nr_probe && !session.dellist && !session.list_events)) 206 if ((!session.nr_probe && !session.dellist && !session.list_events))
206 usage_with_options(probe_usage, options); 207 usage_with_options(probe_usage, options);
207 208
209 if (debugfs_valid_mountpoint(debugfs_path) < 0)
210 die("Failed to find debugfs path.");
211
208 if (session.list_events) { 212 if (session.list_events) {
209 if (session.nr_probe != 0 || session.dellist) { 213 if (session.nr_probe != 0 || session.dellist) {
210 pr_warning(" Error: Don't use --list with" 214 pr_warning(" Error: Don't use --list with"
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index e50a6b10ee6f..5c2ab5357ec6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -224,7 +224,7 @@ static int __cmd_report(void)
224 224
225 perf_session__collapse_resort(session); 225 perf_session__collapse_resort(session);
226 perf_session__output_resort(session, session->events_stats.total); 226 perf_session__output_resort(session, session->events_stats.total);
227 fprintf(stdout, "# Samples: %ld\n#\n", session->events_stats.total); 227 fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total);
228 perf_session__fprintf_hists(session, NULL, false, stdout); 228 perf_session__fprintf_hists(session, NULL, false, stdout);
229 if (sort_order == default_sort_order && 229 if (sort_order == default_sort_order &&
230 parent_pattern == default_parent_pattern) 230 parent_pattern == default_parent_pattern)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 8027309b0422..690a96d0467c 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -95,8 +95,8 @@ typedef union event_union {
95} event_t; 95} event_t;
96 96
97struct events_stats { 97struct events_stats {
98 unsigned long total; 98 u64 total;
99 unsigned long lost; 99 u64 lost;
100}; 100};
101 101
102void event__print_totals(void); 102void event__print_totals(void);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 2ca62154f79b..29465d440043 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -62,6 +62,18 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
62 return ret; 62 return ret;
63} 63}
64 64
65/* Check the name is good for event/group */
66static bool check_event_name(const char *name)
67{
68 if (!isalpha(*name) && *name != '_')
69 return false;
70 while (*++name != '\0') {
71 if (!isalpha(*name) && !isdigit(*name) && *name != '_')
72 return false;
73 }
74 return true;
75}
76
65/* Parse probepoint definition. */ 77/* Parse probepoint definition. */
66static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp) 78static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
67{ 79{
@@ -82,6 +94,9 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
82 ptr = strchr(arg, ':'); 94 ptr = strchr(arg, ':');
83 if (ptr) /* Group name is not supported yet. */ 95 if (ptr) /* Group name is not supported yet. */
84 semantic_error("Group name is not supported yet."); 96 semantic_error("Group name is not supported yet.");
97 if (!check_event_name(arg))
98 semantic_error("%s is bad for event name -it must "
99 "follow C symbol-naming rule.", arg);
85 pp->event = strdup(arg); 100 pp->event = strdup(arg);
86 arg = tmp; 101 arg = tmp;
87 } 102 }
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 5e4050ce2963..a4086aaddb73 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -1,9 +1,9 @@
1#ifndef _PROBE_FINDER_H 1#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H 2#define _PROBE_FINDER_H
3 3
4#define MAX_PATH_LEN 256 4#define MAX_PATH_LEN 256
5#define MAX_PROBE_BUFFER 1024 5#define MAX_PROBE_BUFFER 1024
6#define MAX_PROBES 128 6#define MAX_PROBES 128
7 7
8static inline int is_c_varname(const char *name) 8static inline int is_c_varname(const char *name)
9{ 9{
@@ -12,48 +12,53 @@ static inline int is_c_varname(const char *name)
12} 12}
13 13
14struct probe_point { 14struct probe_point {
15 char *event; /* Event name */ 15 char *event; /* Event name */
16 char *group; /* Event group */ 16 char *group; /* Event group */
17 17
18 /* Inputs */ 18 /* Inputs */
19 char *file; /* File name */ 19 char *file; /* File name */
20 int line; /* Line number */ 20 int line; /* Line number */
21 21
22 char *function; /* Function name */ 22 char *function; /* Function name */
23 int offset; /* Offset bytes */ 23 int offset; /* Offset bytes */
24 24
25 int nr_args; /* Number of arguments */ 25 int nr_args; /* Number of arguments */
26 char **args; /* Arguments */ 26 char **args; /* Arguments */
27 27
28 int retprobe; /* Return probe */ 28 int retprobe; /* Return probe */
29 29
30 /* Output */ 30 /* Output */
31 int found; /* Number of found probe points */ 31 int found; /* Number of found probe points */
32 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/ 32 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
33}; 33};
34 34
35#ifndef NO_LIBDWARF 35#ifndef NO_LIBDWARF
36extern int find_probepoint(int fd, struct probe_point *pp); 36extern int find_probepoint(int fd, struct probe_point *pp);
37 37
38#include <libdwarf/dwarf.h> 38/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
39#include <libdwarf/libdwarf.h> 39#ifndef _MIPS_SZLONG
40# define _MIPS_SZLONG 0
41#endif
42
43#include <dwarf.h>
44#include <libdwarf.h>
40 45
41struct probe_finder { 46struct probe_finder {
42 struct probe_point *pp; /* Target probe point */ 47 struct probe_point *pp; /* Target probe point */
43 48
44 /* For function searching */ 49 /* For function searching */
45 Dwarf_Addr addr; /* Address */ 50 Dwarf_Addr addr; /* Address */
46 Dwarf_Unsigned fno; /* File number */ 51 Dwarf_Unsigned fno; /* File number */
47 Dwarf_Unsigned lno; /* Line number */ 52 Dwarf_Unsigned lno; /* Line number */
48 Dwarf_Off inl_offs; /* Inline offset */ 53 Dwarf_Off inl_offs; /* Inline offset */
49 Dwarf_Die cu_die; /* Current CU */ 54 Dwarf_Die cu_die; /* Current CU */
50 55
51 /* For variable searching */ 56 /* For variable searching */
52 Dwarf_Addr cu_base; /* Current CU base address */ 57 Dwarf_Addr cu_base; /* Current CU base address */
53 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */ 58 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
54 const char *var; /* Current variable name */ 59 const char *var; /* Current variable name */
55 char *buf; /* Current output buffer */ 60 char *buf; /* Current output buffer */
56 int len; /* Length of output buffer */ 61 int len; /* Length of output buffer */
57}; 62};
58#endif /* NO_LIBDWARF */ 63#endif /* NO_LIBDWARF */
59 64