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>
This commit is contained in:
Arnaldo Carvalho de Melo 2016-04-14 17:45:51 -03:00
parent bfbba189b6
commit 6f736735e3
4 changed files with 47 additions and 53 deletions

View file

@ -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;
perf_evsel__fprintf_sym(evsel, sample, al, 0,
output[attr->type].print_ip_opts,
symbol_conf.use_callchain,
scripting_max_stack, stdout);
if (symbol_conf.use_callchain &&
thread__resolve_callchain(al->thread, &cursor_callchain, evsel,
sample, NULL, NULL, scripting_max_stack) == 0)
cursor = &cursor_callchain;
putchar(cursor ? '\n' : ' ');
sample__fprintf_sym(sample, al, 0, output[attr->type].print_ip_opts, cursor, stdout);
}
if (PRINT_FIELD(IREGS))