diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-12-15 10:31:14 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-15 14:21:59 -0500 |
commit | fac13fd54e2bfbb0b49683a9b3ae2bf2a0d7677f (patch) | |
tree | 7ba607c0778289fca86add04373636b4a6c620ac /tools | |
parent | f13c12c634e124d5d31f912b969d542a016d6105 (diff) |
perf probe: Cleanup struct session in builtin-probe.c
Clean up struct session in builtin-probe.c, including
change need_dwarf to bool and move listing flag into
struct session as list_events flag.
This also changes parse_perf_probe_event() interface
due to code readability.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20091215153114.17436.77000.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-probe.c | 13 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 12 | ||||
-rw-r--r-- | tools/perf/util/probe-event.h | 4 |
3 files changed, 17 insertions, 12 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 5a47c1e11f7..559eeb42c5e 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -59,13 +59,13 @@ const char *default_search_path[NR_SEARCH_PATH] = { | |||
59 | static struct { | 59 | static struct { |
60 | char *vmlinux; | 60 | char *vmlinux; |
61 | char *release; | 61 | char *release; |
62 | int need_dwarf; | 62 | bool need_dwarf; |
63 | bool list_events; | ||
63 | int nr_probe; | 64 | int nr_probe; |
64 | struct probe_point probes[MAX_PROBES]; | 65 | struct probe_point probes[MAX_PROBES]; |
65 | struct strlist *dellist; | 66 | struct strlist *dellist; |
66 | } session; | 67 | } session; |
67 | 68 | ||
68 | static bool listing; | ||
69 | 69 | ||
70 | /* Parse an event definition. Note that any error must die. */ | 70 | /* Parse an event definition. Note that any error must die. */ |
71 | static void parse_probe_event(const char *str) | 71 | static void parse_probe_event(const char *str) |
@@ -77,7 +77,7 @@ static void parse_probe_event(const char *str) | |||
77 | die("Too many probes (> %d) are specified.", MAX_PROBES); | 77 | die("Too many probes (> %d) are specified.", MAX_PROBES); |
78 | 78 | ||
79 | /* Parse perf-probe event into probe_point */ | 79 | /* Parse perf-probe event into probe_point */ |
80 | session.need_dwarf = parse_perf_probe_event(str, pp); | 80 | parse_perf_probe_event(str, pp, &session.need_dwarf); |
81 | 81 | ||
82 | pr_debug("%d arguments\n", pp->nr_args); | 82 | pr_debug("%d arguments\n", pp->nr_args); |
83 | } | 83 | } |
@@ -166,7 +166,8 @@ static const struct option options[] = { | |||
166 | OPT_STRING('k', "vmlinux", &session.vmlinux, "file", | 166 | OPT_STRING('k', "vmlinux", &session.vmlinux, "file", |
167 | "vmlinux/module pathname"), | 167 | "vmlinux/module pathname"), |
168 | #endif | 168 | #endif |
169 | OPT_BOOLEAN('l', "list", &listing, "list up current probe events"), | 169 | OPT_BOOLEAN('l', "list", &session.list_events, |
170 | "list up current probe events"), | ||
170 | OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.", | 171 | OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.", |
171 | opt_del_probe_event), | 172 | opt_del_probe_event), |
172 | OPT_CALLBACK('a', "add", NULL, | 173 | OPT_CALLBACK('a', "add", NULL, |
@@ -207,10 +208,10 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) | |||
207 | if (argc > 0) | 208 | if (argc > 0) |
208 | parse_probe_event_argv(argc, argv); | 209 | parse_probe_event_argv(argc, argv); |
209 | 210 | ||
210 | if ((session.nr_probe == 0 && !session.dellist && !listing)) | 211 | if ((!session.nr_probe && !session.dellist && !session.list_events)) |
211 | usage_with_options(probe_usage, options); | 212 | usage_with_options(probe_usage, options); |
212 | 213 | ||
213 | if (listing) { | 214 | if (session.list_events) { |
214 | if (session.nr_probe != 0 || session.dellist) { | 215 | if (session.nr_probe != 0 || session.dellist) { |
215 | pr_warning(" Error: Don't use --list with" | 216 | pr_warning(" Error: Don't use --list with" |
216 | " --add/--del.\n"); | 217 | " --add/--del.\n"); |
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index d14a4585bca..add379c55c3 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -150,10 +150,13 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp) | |||
150 | } | 150 | } |
151 | 151 | ||
152 | /* Parse perf-probe event definition */ | 152 | /* Parse perf-probe event definition */ |
153 | int parse_perf_probe_event(const char *str, struct probe_point *pp) | 153 | void parse_perf_probe_event(const char *str, struct probe_point *pp, |
154 | bool *need_dwarf) | ||
154 | { | 155 | { |
155 | char **argv; | 156 | char **argv; |
156 | int argc, i, need_dwarf = 0; | 157 | int argc, i; |
158 | |||
159 | *need_dwarf = false; | ||
157 | 160 | ||
158 | argv = argv_split(str, &argc); | 161 | argv = argv_split(str, &argc); |
159 | if (!argv) | 162 | if (!argv) |
@@ -164,7 +167,7 @@ int parse_perf_probe_event(const char *str, struct probe_point *pp) | |||
164 | /* Parse probe point */ | 167 | /* Parse probe point */ |
165 | parse_perf_probe_probepoint(argv[0], pp); | 168 | parse_perf_probe_probepoint(argv[0], pp); |
166 | if (pp->file || pp->line) | 169 | if (pp->file || pp->line) |
167 | need_dwarf = 1; | 170 | *need_dwarf = true; |
168 | 171 | ||
169 | /* Copy arguments and ensure return probe has no C argument */ | 172 | /* Copy arguments and ensure return probe has no C argument */ |
170 | pp->nr_args = argc - 1; | 173 | pp->nr_args = argc - 1; |
@@ -177,12 +180,11 @@ int parse_perf_probe_event(const char *str, struct probe_point *pp) | |||
177 | if (pp->retprobe) | 180 | if (pp->retprobe) |
178 | semantic_error("You can't specify local" | 181 | semantic_error("You can't specify local" |
179 | " variable for kretprobe"); | 182 | " variable for kretprobe"); |
180 | need_dwarf = 1; | 183 | *need_dwarf = true; |
181 | } | 184 | } |
182 | } | 185 | } |
183 | 186 | ||
184 | argv_free(argv); | 187 | argv_free(argv); |
185 | return need_dwarf; | ||
186 | } | 188 | } |
187 | 189 | ||
188 | /* Parse kprobe_events event into struct probe_point */ | 190 | /* Parse kprobe_events event into struct probe_point */ |
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index f752159124a..028575b5fc3 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h | |||
@@ -1,10 +1,12 @@ | |||
1 | #ifndef _PROBE_EVENT_H | 1 | #ifndef _PROBE_EVENT_H |
2 | #define _PROBE_EVENT_H | 2 | #define _PROBE_EVENT_H |
3 | 3 | ||
4 | #include <stdbool.h> | ||
4 | #include "probe-finder.h" | 5 | #include "probe-finder.h" |
5 | #include "strlist.h" | 6 | #include "strlist.h" |
6 | 7 | ||
7 | extern int parse_perf_probe_event(const char *str, struct probe_point *pp); | 8 | extern void parse_perf_probe_event(const char *str, struct probe_point *pp, |
9 | bool *need_dwarf); | ||
8 | extern int synthesize_perf_probe_event(struct probe_point *pp); | 10 | extern int synthesize_perf_probe_event(struct probe_point *pp); |
9 | extern void parse_trace_kprobe_event(const char *str, char **group, | 11 | extern void parse_trace_kprobe_event(const char *str, char **group, |
10 | char **event, struct probe_point *pp); | 12 | char **event, struct probe_point *pp); |