summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-04-14 23:45:51 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-15 01:46:56 +0300
commit6f736735e30f51805f6be31d20a4bf5b0ae91bae (patch)
treebc26c54ba215e4891ee6fa60e881074aa543d744 /tools/perf/builtin-script.c
parentbfbba189b681c86b9ae380358e5f50ce1e33d240 (diff)
downloadlinux-6f736735e30f51805f6be31d20a4bf5b0ae91bae.tar.xz
perf evsel: Require that callchains be resolved before calling fprintf_{sym,callchain}
This way the print routine merely does printing, not requiring access to the resolving machinery, which helps disentangling the object files and easing creating subsets with a limited functionality set. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-2ti2jbra8fypdfawwwm3aee3@git.kernel.org 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.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 717ba0215234..875d84e7ba5b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -569,19 +569,23 @@ static void print_sample_bts(struct perf_sample *sample,
/* print branch_from information */
if (PRINT_FIELD(IP)) {
unsigned int print_opts = output[attr->type].print_ip_opts;
+ struct callchain_cursor *cursor = NULL, cursor_callchain;
- if (symbol_conf.use_callchain && sample->callchain) {
- printf("\n");
- } else {
- printf(" ");
+ if (symbol_conf.use_callchain && sample->callchain &&
+ thread__resolve_callchain(al->thread, &cursor_callchain, evsel,
+ sample, NULL, NULL, scripting_max_stack) == 0)
+ cursor = &cursor_callchain;
+
+ if (cursor == NULL) {
+ putchar(' ');
if (print_opts & EVSEL__PRINT_SRCLINE) {
print_srcline_last = true;
print_opts &= ~EVSEL__PRINT_SRCLINE;
}
- }
- perf_evsel__fprintf_sym(evsel, sample, al, 0, print_opts,
- symbol_conf.use_callchain,
- scripting_max_stack, stdout);
+ } else
+ putchar('\n');
+
+ sample__fprintf_sym(sample, al, 0, print_opts, cursor, stdout);
}
/* print branch_to information */
@@ -784,15 +788,15 @@ static void process_event(struct perf_script *script,
printf("%16" PRIu64, sample->weight);
if (PRINT_FIELD(IP)) {
- if (!symbol_conf.use_callchain)
- printf(" ");
- else
- printf("\n");
+ struct callchain_cursor *cursor = NULL, cursor_callchain;
+
+ if (symbol_conf.use_callchain &&
+ thread__resolve_callchain(al->thread, &cursor_callchain, evsel,
+ sample, NULL, NULL, scripting_max_stack) == 0)
+ cursor = &cursor_callchain;
- perf_evsel__fprintf_sym(evsel, sample, al, 0,
- output[attr->type].print_ip_opts,
- symbol_conf.use_callchain,
- scripting_max_stack, stdout);
+ putchar(cursor ? '\n' : ' ');
+ sample__fprintf_sym(sample, al, 0, output[attr->type].print_ip_opts, cursor, stdout);
}
if (PRINT_FIELD(IREGS))