lkml.org 
[lkml]   [2017]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 35/35] perf annotate: Align source and offset lines
Date
Aligning source with offset lines, which are more advanced,
because of the address column.

Before:
: static void *worker_thread(void *__tdata)
: {
0.00 : 48a971: push %rbp
0.00 : 48a972: mov %rsp,%rbp
0.00 : 48a975: sub $0x30,%rsp
0.00 : 48a979: mov %rdi,-0x28(%rbp)
0.00 : 48a97d: mov %fs:0x28,%rax
0.00 : 48a986: mov %rax,-0x8(%rbp)
0.00 : 48a98a: xor %eax,%eax
: struct thread_data *td = __tdata;
0.00 : 48a98c: mov -0x28(%rbp),%rax
0.00 : 48a990: mov %rax,-0x10(%rbp)
: int m = 0, i;
0.00 : 48a994: movl $0x0,-0x1c(%rbp)
: int ret;
:
: for (i = 0; i < loops; i++) {
0.00 : 48a99b: movl $0x0,-0x18(%rbp)

After:
: static void *worker_thread(void *__tdata)
: {
0.00 : 48a971: push %rbp
0.00 : 48a972: mov %rsp,%rbp
0.00 : 48a975: sub $0x30,%rsp
0.00 : 48a979: mov %rdi,-0x28(%rbp)
0.00 : 48a97d: mov %fs:0x28,%rax
0.00 : 48a986: mov %rax,-0x8(%rbp)
0.00 : 48a98a: xor %eax,%eax
: struct thread_data *td = __tdata;
0.00 : 48a98c: mov -0x28(%rbp),%rax
0.00 : 48a990: mov %rax,-0x10(%rbp)
: int m = 0, i;
0.00 : 48a994: movl $0x0,-0x1c(%rbp)
: int ret;
:
: for (i = 0; i < loops; i++) {
0.00 : 48a99b: movl $0x0,-0x18(%rbp)

It makes bigger different when displaying script sources,
where the comment lines looks oddly shifted from the lines
which actually hold code. I'll send script support separately.

Link: http://lkml.kernel.org/n/tip-uamk3iiewlii40o4mlog2cpp@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/annotate.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2516e53104be..530961a343fc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1082,6 +1082,7 @@ static void annotate__branch_printf(struct block_range *br, u64 addr)
}
}

+#define ADDR_LEN 10

static int disasm_line__print(struct disasm_line *dl, u64 start)
{
@@ -1090,7 +1091,7 @@ static int disasm_line__print(struct disasm_line *dl, u64 start)
struct block_range *br;

br = block_range__find(addr);
- color_fprintf(stdout, annotate__address_color(br), " %" PRIx64 ":", addr);
+ color_fprintf(stdout, annotate__address_color(br), " %*" PRIx64 ":", ADDR_LEN, addr);
color_fprintf(stdout, annotate__asm_color(br), "%s", dl->al.line);
annotate__branch_printf(br, addr);
return 0;
@@ -1164,7 +1165,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
color_fprintf(stdout, color, " %7.2f", sample->percent);
}

- printf(" : ");
+ printf(" : ");

disasm_line__print(dl, start);
printf("\n");
@@ -1182,7 +1183,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
if (!*al->line)
printf(" %*s:\n", width, " ");
else
- printf(" %*s: %s\n", width, " ", al->line);
+ printf(" %*s: %*s %s\n", width, " ", ADDR_LEN, " ", al->line);
}

return 0;
--
2.13.6
\
 
 \ /
  Last update: 2017-10-11 17:04    [W:0.371 / U:7.928 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site