From: Adrian Hunter Date: Tue, 22 Jul 2014 13:17:15 +0000 (+0300) Subject: perf script: Improve srcline display for BTS X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8066be5fe755e95ee6a858bbcf4e6b9e933e1866;p=openwrt%2Fstaging%2Fblogic.git perf script: Improve srcline display for BTS Change the order of the output to put the srcline last. It puts the branch 'from address' and 'to address' on the same line, which is how it would be without the source line reference. So it makes it consistent and much easier to read. E.g. old format: 4028fc main+0x2c (/bin/ls) /build/buildd/coreutils-8.20/src/ls.c:1269 => 40d8a0 set_program_name+0x0 (/bin/ls) new format: 4028fc main+0x2c (/bin/ls) => 40d8a0 set_program_name+0x0 (/bin/ls) /build/buildd/coreutils-8.20/src/ls.c:1269 Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1406035081-14301-7-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9e9c91f5b7fa..333b15ebe72b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -427,15 +427,22 @@ static void print_sample_bts(union perf_event *event, struct addr_location *al) { struct perf_event_attr *attr = &evsel->attr; + bool print_srcline_last = false; /* print branch_from information */ if (PRINT_FIELD(IP)) { - if (!symbol_conf.use_callchain) - printf(" "); - else + unsigned int print_opts = output[attr->type].print_ip_opts; + + if (symbol_conf.use_callchain && sample->callchain) { printf("\n"); - perf_evsel__print_ip(evsel, sample, al, - output[attr->type].print_ip_opts, + } else { + printf(" "); + if (print_opts & PRINT_IP_OPT_SRCLINE) { + print_srcline_last = true; + print_opts &= ~PRINT_IP_OPT_SRCLINE; + } + } + perf_evsel__print_ip(evsel, sample, al, print_opts, PERF_MAX_STACK_DEPTH); } @@ -447,6 +454,9 @@ static void print_sample_bts(union perf_event *event, !output[attr->type].user_set)) print_sample_addr(event, sample, al->machine, thread, attr); + if (print_srcline_last) + map__fprintf_srcline(al->map, al->addr, "\n ", stdout); + printf("\n"); }