aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2014-11-12 21:05:26 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-11-19 10:33:48 -0500
commite592488c01d51763de847fcecb3d969231a483a9 (patch)
tree5d835af0655251082dbca113e98e5df1cd0e413f /tools/perf/ui
parent2de217688e8f086bf6d920d530401b56fcbc6eff (diff)
perf annotate: Support source line numbers in annotate
With srcline key/sort'ing it's useful to have line numbers in the annotate window. This patch implements this. Use objdump -l to request the line numbers and save them in the line structure. Then the browser displays them for source lines. The line numbers are not displayed by default, but can be toggled on with 'k' There is one unfortunate problem with this setup. For lines not containing source and which are outside functions objdump -l reports line numbers off by a few: it always reports the first line number in the next function even for lines that are outside the function. I haven't found a nice way to detect/correct this. Probably objdump has to be fixed. See https://sourceware.org/bugzilla/show_bug.cgi?id=16433 The line numbers are still useful even with these problems, as most are correct and the ones which are not are nearby. v2: Fix help text. Handle (discriminator...) output in objdump. Left align the line numbers. Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1415844328-4884-9-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/browsers/annotate.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index f0697a3aede0..1e0a2fd80115 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -27,6 +27,7 @@ static struct annotate_browser_opt {
27 bool hide_src_code, 27 bool hide_src_code,
28 use_offset, 28 use_offset,
29 jump_arrows, 29 jump_arrows,
30 show_linenr,
30 show_nr_jumps; 31 show_nr_jumps;
31} annotate_browser__opts = { 32} annotate_browser__opts = {
32 .use_offset = true, 33 .use_offset = true,
@@ -128,7 +129,11 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
128 if (!*dl->line) 129 if (!*dl->line)
129 slsmg_write_nstring(" ", width - pcnt_width); 130 slsmg_write_nstring(" ", width - pcnt_width);
130 else if (dl->offset == -1) { 131 else if (dl->offset == -1) {
131 printed = scnprintf(bf, sizeof(bf), "%*s ", 132 if (dl->line_nr && annotate_browser__opts.show_linenr)
133 printed = scnprintf(bf, sizeof(bf), "%-*d ",
134 ab->addr_width + 1, dl->line_nr);
135 else
136 printed = scnprintf(bf, sizeof(bf), "%*s ",
132 ab->addr_width, " "); 137 ab->addr_width, " ");
133 slsmg_write_nstring(bf, printed); 138 slsmg_write_nstring(bf, printed);
134 slsmg_write_nstring(dl->line, width - printed - pcnt_width + 1); 139 slsmg_write_nstring(dl->line, width - printed - pcnt_width + 1);
@@ -733,6 +738,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
733 "o Toggle disassembler output/simplified view\n" 738 "o Toggle disassembler output/simplified view\n"
734 "s Toggle source code view\n" 739 "s Toggle source code view\n"
735 "/ Search string\n" 740 "/ Search string\n"
741 "k Toggle line numbers\n"
736 "r Run available scripts\n" 742 "r Run available scripts\n"
737 "? Search string backwards\n"); 743 "? Search string backwards\n");
738 continue; 744 continue;
@@ -741,6 +747,10 @@ static int annotate_browser__run(struct annotate_browser *browser,
741 script_browse(NULL); 747 script_browse(NULL);
742 continue; 748 continue;
743 } 749 }
750 case 'k':
751 annotate_browser__opts.show_linenr =
752 !annotate_browser__opts.show_linenr;
753 break;
744 case 'H': 754 case 'H':
745 nd = browser->curr_hot; 755 nd = browser->curr_hot;
746 break; 756 break;
@@ -984,6 +994,7 @@ static struct annotate_config {
984} annotate__configs[] = { 994} annotate__configs[] = {
985 ANNOTATE_CFG(hide_src_code), 995 ANNOTATE_CFG(hide_src_code),
986 ANNOTATE_CFG(jump_arrows), 996 ANNOTATE_CFG(jump_arrows),
997 ANNOTATE_CFG(show_linenr),
987 ANNOTATE_CFG(show_nr_jumps), 998 ANNOTATE_CFG(show_nr_jumps),
988 ANNOTATE_CFG(use_offset), 999 ANNOTATE_CFG(use_offset),
989}; 1000};