diff options
author | David Ahern <dsahern@gmail.com> | 2013-08-07 22:50:51 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-08-12 09:31:07 -0400 |
commit | a6ffaf91302dc1689fc72da0068b87226747fbe0 (patch) | |
tree | d18e038d5122813b00f3a8cd5faaff54982a9a96 /tools/perf/builtin-script.c | |
parent | cb627505ae028a0cd88cc29ed72a4c168a08751d (diff) |
perf tool: Simplify options to perf_evsel__print_ip
Make print options based on flags. Simplifies addition of more print
options which is the subject of upcoming patches.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1375930261-77273-10-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index cd616ff5d221..ee5d6f8b7415 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -66,6 +66,7 @@ struct output_option { | |||
66 | static struct { | 66 | static struct { |
67 | bool user_set; | 67 | bool user_set; |
68 | bool wildcard_set; | 68 | bool wildcard_set; |
69 | unsigned int print_ip_opts; | ||
69 | u64 fields; | 70 | u64 fields; |
70 | u64 invalid_fields; | 71 | u64 invalid_fields; |
71 | } output[PERF_TYPE_MAX] = { | 72 | } output[PERF_TYPE_MAX] = { |
@@ -235,6 +236,7 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
235 | { | 236 | { |
236 | int j; | 237 | int j; |
237 | struct perf_evsel *evsel; | 238 | struct perf_evsel *evsel; |
239 | struct perf_event_attr *attr; | ||
238 | 240 | ||
239 | for (j = 0; j < PERF_TYPE_MAX; ++j) { | 241 | for (j = 0; j < PERF_TYPE_MAX; ++j) { |
240 | evsel = perf_session__find_first_evtype(session, j); | 242 | evsel = perf_session__find_first_evtype(session, j); |
@@ -253,6 +255,24 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
253 | if (evsel && output[j].fields && | 255 | if (evsel && output[j].fields && |
254 | perf_evsel__check_attr(evsel, session)) | 256 | perf_evsel__check_attr(evsel, session)) |
255 | return -1; | 257 | return -1; |
258 | |||
259 | if (evsel == NULL) | ||
260 | continue; | ||
261 | |||
262 | attr = &evsel->attr; | ||
263 | |||
264 | output[j].print_ip_opts = 0; | ||
265 | if (PRINT_FIELD(IP)) | ||
266 | output[j].print_ip_opts |= PRINT_IP_OPT_IP; | ||
267 | |||
268 | if (PRINT_FIELD(SYM)) | ||
269 | output[j].print_ip_opts |= PRINT_IP_OPT_SYM; | ||
270 | |||
271 | if (PRINT_FIELD(DSO)) | ||
272 | output[j].print_ip_opts |= PRINT_IP_OPT_DSO; | ||
273 | |||
274 | if (PRINT_FIELD(SYMOFFSET)) | ||
275 | output[j].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET; | ||
256 | } | 276 | } |
257 | 277 | ||
258 | return 0; | 278 | return 0; |
@@ -382,8 +402,7 @@ static void print_sample_bts(union perf_event *event, | |||
382 | else | 402 | else |
383 | printf("\n"); | 403 | printf("\n"); |
384 | perf_evsel__print_ip(evsel, event, sample, machine, | 404 | perf_evsel__print_ip(evsel, event, sample, machine, |
385 | PRINT_FIELD(SYM), PRINT_FIELD(DSO), | 405 | output[attr->type].print_ip_opts); |
386 | PRINT_FIELD(SYMOFFSET)); | ||
387 | } | 406 | } |
388 | 407 | ||
389 | printf(" => "); | 408 | printf(" => "); |
@@ -423,9 +442,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample, | |||
423 | printf(" "); | 442 | printf(" "); |
424 | else | 443 | else |
425 | printf("\n"); | 444 | printf("\n"); |
445 | |||
426 | perf_evsel__print_ip(evsel, event, sample, machine, | 446 | perf_evsel__print_ip(evsel, event, sample, machine, |
427 | PRINT_FIELD(SYM), PRINT_FIELD(DSO), | 447 | output[attr->type].print_ip_opts); |
428 | PRINT_FIELD(SYMOFFSET)); | ||
429 | } | 448 | } |
430 | 449 | ||
431 | printf("\n"); | 450 | printf("\n"); |