diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2013-12-04 09:16:36 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-04 13:09:53 -0500 |
commit | a2cb3cf20e06ef119ae541c1a08dc1977f7f0fff (patch) | |
tree | fc1ed6bb6cb889ba993d5b0889f10353f4d2182c /tools/perf | |
parent | 779e24e2c777bffa9a6e3d5e821859e67008c98b (diff) |
perf script: Do not call perf_event__preprocess_sample() twice)
The perf_event__preprocess_sample() function is called in
process_sample_event(). Instead of calling it again in
perf_evsel__print_ip(), pass through the resultant addr_location.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/529F3944.9050007@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-script.c | 11 | ||||
-rw-r--r-- | tools/perf/util/session.c | 31 | ||||
-rw-r--r-- | tools/perf/util/session.h | 4 |
3 files changed, 22 insertions, 24 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 952dce979252..c555bddfccd7 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -414,7 +414,8 @@ static void print_sample_bts(union perf_event *event, | |||
414 | struct perf_sample *sample, | 414 | struct perf_sample *sample, |
415 | struct perf_evsel *evsel, | 415 | struct perf_evsel *evsel, |
416 | struct machine *machine, | 416 | struct machine *machine, |
417 | struct thread *thread) | 417 | struct thread *thread, |
418 | struct addr_location *al) | ||
418 | { | 419 | { |
419 | struct perf_event_attr *attr = &evsel->attr; | 420 | struct perf_event_attr *attr = &evsel->attr; |
420 | 421 | ||
@@ -424,7 +425,7 @@ static void print_sample_bts(union perf_event *event, | |||
424 | printf(" "); | 425 | printf(" "); |
425 | else | 426 | else |
426 | printf("\n"); | 427 | printf("\n"); |
427 | perf_evsel__print_ip(evsel, event, sample, machine, | 428 | perf_evsel__print_ip(evsel, sample, machine, al, |
428 | output[attr->type].print_ip_opts, | 429 | output[attr->type].print_ip_opts, |
429 | PERF_MAX_STACK_DEPTH); | 430 | PERF_MAX_STACK_DEPTH); |
430 | } | 431 | } |
@@ -443,7 +444,7 @@ static void print_sample_bts(union perf_event *event, | |||
443 | static void process_event(union perf_event *event, struct perf_sample *sample, | 444 | static void process_event(union perf_event *event, struct perf_sample *sample, |
444 | struct perf_evsel *evsel, struct machine *machine, | 445 | struct perf_evsel *evsel, struct machine *machine, |
445 | struct thread *thread, | 446 | struct thread *thread, |
446 | struct addr_location *al __maybe_unused) | 447 | struct addr_location *al) |
447 | { | 448 | { |
448 | struct perf_event_attr *attr = &evsel->attr; | 449 | struct perf_event_attr *attr = &evsel->attr; |
449 | 450 | ||
@@ -458,7 +459,7 @@ static void process_event(union perf_event *event, struct perf_sample *sample, | |||
458 | } | 459 | } |
459 | 460 | ||
460 | if (is_bts_event(attr)) { | 461 | if (is_bts_event(attr)) { |
461 | print_sample_bts(event, sample, evsel, machine, thread); | 462 | print_sample_bts(event, sample, evsel, machine, thread, al); |
462 | return; | 463 | return; |
463 | } | 464 | } |
464 | 465 | ||
@@ -474,7 +475,7 @@ static void process_event(union perf_event *event, struct perf_sample *sample, | |||
474 | else | 475 | else |
475 | printf("\n"); | 476 | printf("\n"); |
476 | 477 | ||
477 | perf_evsel__print_ip(evsel, event, sample, machine, | 478 | perf_evsel__print_ip(evsel, sample, machine, al, |
478 | output[attr->type].print_ip_opts, | 479 | output[attr->type].print_ip_opts, |
479 | PERF_MAX_STACK_DEPTH); | 480 | PERF_MAX_STACK_DEPTH); |
480 | } | 481 | } |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 4ce146bae552..8a7da6f4a569 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -1487,11 +1487,10 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, | |||
1487 | return NULL; | 1487 | return NULL; |
1488 | } | 1488 | } |
1489 | 1489 | ||
1490 | void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, | 1490 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, |
1491 | struct perf_sample *sample, struct machine *machine, | 1491 | struct machine *machine, struct addr_location *al, |
1492 | unsigned int print_opts, unsigned int stack_depth) | 1492 | unsigned int print_opts, unsigned int stack_depth) |
1493 | { | 1493 | { |
1494 | struct addr_location al; | ||
1495 | struct callchain_cursor_node *node; | 1494 | struct callchain_cursor_node *node; |
1496 | int print_ip = print_opts & PRINT_IP_OPT_IP; | 1495 | int print_ip = print_opts & PRINT_IP_OPT_IP; |
1497 | int print_sym = print_opts & PRINT_IP_OPT_SYM; | 1496 | int print_sym = print_opts & PRINT_IP_OPT_SYM; |
@@ -1500,15 +1499,10 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, | |||
1500 | int print_oneline = print_opts & PRINT_IP_OPT_ONELINE; | 1499 | int print_oneline = print_opts & PRINT_IP_OPT_ONELINE; |
1501 | char s = print_oneline ? ' ' : '\t'; | 1500 | char s = print_oneline ? ' ' : '\t'; |
1502 | 1501 | ||
1503 | if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) { | ||
1504 | error("problem processing %d event, skipping it.\n", | ||
1505 | event->header.type); | ||
1506 | return; | ||
1507 | } | ||
1508 | |||
1509 | if (symbol_conf.use_callchain && sample->callchain) { | 1502 | if (symbol_conf.use_callchain && sample->callchain) { |
1503 | struct addr_location node_al; | ||
1510 | 1504 | ||
1511 | if (machine__resolve_callchain(machine, evsel, al.thread, | 1505 | if (machine__resolve_callchain(machine, evsel, al->thread, |
1512 | sample, NULL, NULL, | 1506 | sample, NULL, NULL, |
1513 | PERF_MAX_STACK_DEPTH) != 0) { | 1507 | PERF_MAX_STACK_DEPTH) != 0) { |
1514 | if (verbose) | 1508 | if (verbose) |
@@ -1517,6 +1511,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, | |||
1517 | } | 1511 | } |
1518 | callchain_cursor_commit(&callchain_cursor); | 1512 | callchain_cursor_commit(&callchain_cursor); |
1519 | 1513 | ||
1514 | if (print_symoffset) | ||
1515 | node_al = *al; | ||
1516 | |||
1520 | while (stack_depth) { | 1517 | while (stack_depth) { |
1521 | node = callchain_cursor_current(&callchain_cursor); | 1518 | node = callchain_cursor_current(&callchain_cursor); |
1522 | if (!node) | 1519 | if (!node) |
@@ -1531,9 +1528,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, | |||
1531 | if (print_sym) { | 1528 | if (print_sym) { |
1532 | printf(" "); | 1529 | printf(" "); |
1533 | if (print_symoffset) { | 1530 | if (print_symoffset) { |
1534 | al.addr = node->ip; | 1531 | node_al.addr = node->ip; |
1535 | al.map = node->map; | 1532 | node_al.map = node->map; |
1536 | symbol__fprintf_symname_offs(node->sym, &al, stdout); | 1533 | symbol__fprintf_symname_offs(node->sym, &node_al, stdout); |
1537 | } else | 1534 | } else |
1538 | symbol__fprintf_symname(node->sym, stdout); | 1535 | symbol__fprintf_symname(node->sym, stdout); |
1539 | } | 1536 | } |
@@ -1553,7 +1550,7 @@ next: | |||
1553 | } | 1550 | } |
1554 | 1551 | ||
1555 | } else { | 1552 | } else { |
1556 | if (al.sym && al.sym->ignore) | 1553 | if (al->sym && al->sym->ignore) |
1557 | return; | 1554 | return; |
1558 | 1555 | ||
1559 | if (print_ip) | 1556 | if (print_ip) |
@@ -1562,15 +1559,15 @@ next: | |||
1562 | if (print_sym) { | 1559 | if (print_sym) { |
1563 | printf(" "); | 1560 | printf(" "); |
1564 | if (print_symoffset) | 1561 | if (print_symoffset) |
1565 | symbol__fprintf_symname_offs(al.sym, &al, | 1562 | symbol__fprintf_symname_offs(al->sym, al, |
1566 | stdout); | 1563 | stdout); |
1567 | else | 1564 | else |
1568 | symbol__fprintf_symname(al.sym, stdout); | 1565 | symbol__fprintf_symname(al->sym, stdout); |
1569 | } | 1566 | } |
1570 | 1567 | ||
1571 | if (print_dso) { | 1568 | if (print_dso) { |
1572 | printf(" ("); | 1569 | printf(" ("); |
1573 | map__fprintf_dsoname(al.map, stdout); | 1570 | map__fprintf_dsoname(al->map, stdout); |
1574 | printf(")"); | 1571 | printf(")"); |
1575 | } | 1572 | } |
1576 | } | 1573 | } |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 50f640958f0f..7e5d43986474 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -105,8 +105,8 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp); | |||
105 | struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, | 105 | struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, |
106 | unsigned int type); | 106 | unsigned int type); |
107 | 107 | ||
108 | void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, | 108 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, |
109 | struct perf_sample *sample, struct machine *machine, | 109 | struct machine *machine, struct addr_location *al, |
110 | unsigned int print_opts, unsigned int stack_depth); | 110 | unsigned int print_opts, unsigned int stack_depth); |
111 | 111 | ||
112 | int perf_session__cpu_bitmap(struct perf_session *session, | 112 | int perf_session__cpu_bitmap(struct perf_session *session, |