2012-02-23 08:27:29

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 0/5] perf annotate: Random tiny cleanups

Hello,

This is a patchset tries to fix and improve what I found during code reading.
Please take a look and consider applying. Comments are welcome, of course.

Thanks.


Namhyung Kim (5):
perf annotate: Print asm code as blue when source code is displayed
perf annotate: Handle lower case key code in annotate_browser__run()
perf annotate: Restore title when came back to original symbol
perf annotate: Fix help string on tui
perf annotate: Add missing newline on error message

tools/perf/util/annotate.c | 2 +-
tools/perf/util/ui/browsers/annotate.c | 18 ++++++++++++------
2 files changed, 13 insertions(+), 7 deletions(-)

--
1.7.9


2012-02-23 08:27:32

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 2/5] perf annotate: Handle lower case key code in annotate_browser__run()

Accepting upper case character only is unconvenient since it requires
SHIFT key too. Why not change to it accept a simple key stroke?

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/ui/browsers/annotate.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 76caae95df39..374d3bc570b2 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -287,9 +287,11 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
nd = self->curr_hot;
break;
case 'H':
+ case 'h':
nd = self->curr_hot;
break;
case 'S':
+ case 's':
if (annotate_browser__toggle_source(self))
ui_helpline__puts(help);
continue;
--
1.7.9

2012-02-23 08:27:38

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 5/5] perf annotate: Add missing newline on error message

If perf.data couldn't find vmlinux image for the given build-id,
it would print error message. However it lacked a newline at the
end, so the output looked like below:

$ perf annotate --stdio
No vmlinux file with build id 63b554b2e90f14a4bced200008865e757d3e8b36
was found in the path.

Please use:

perf buildid-cache -av vmlinux

or:

--vmlinux vmlinux Percent | Source code & Disassembly of a.out
------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 00000000004004f4 <foo>:
0.00 : 4004f4: push %rbp
0.00 : 4004f5: mov %rsp,%rbp
0.00 : 4004f8: movl $0x0,-0x4(%rbp)
0.00 : 4004ff: jmp 400517 <foo+0x23>
14.70 : 400501: mov 0x200b28(%rip),%rax # 601030 <count>
0.02 : 400508: add $0x1,%rax
0.01 : 40050c: mov %rax,0x200b1d(%rip) # 601030 <count>
0.01 : 400513: addl $0x1,-0x4(%rbp)
13.92 : 400517: cmpl $0x98967f,-0x4(%rbp)
71.33 : 40051e: jle 400501 <foo+0xd>
0.00 : 400520: leaveq
0.00 : 400521: retq

Fix it by adding a newline at the end of the message. It doesn't affect
the tui output AFAICS. New output will look like this:

...
or:

--vmlinux vmlinux
Percent | Source code & Disassembly of a.out
------------------------------------------------
:
:
:
: Disassembly of section .text:
...

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/annotate.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 011ed2676604..e5a462f1d07c 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -315,7 +315,7 @@ fallback:
"Please use:\n\n"
" perf buildid-cache -av vmlinux\n\n"
"or:\n\n"
- " --vmlinux vmlinux",
+ " --vmlinux vmlinux\n",
sym->name, build_id_msg ?: "");
goto out_free_filename;
}
--
1.7.9

2012-02-23 08:27:37

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 1/5] perf annotate: Print asm code as blue when source code is displayed

Print unselected asm code lines as blue. This is what we do now
for --stdio.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/ui/browsers/annotate.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 295a9c93f945..76caae95df39 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -69,14 +69,17 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
if (!self->navkeypressed)
width += 1;

+ if (!ab->hide_src_code && ol->offset != -1)
+ if (!current_entry || (self->use_navkeypressed &&
+ !self->navkeypressed))
+ ui_browser__set_color(self, HE_COLORSET_CODE);
+
if (!*ol->line)
slsmg_write_nstring(" ", width - 18);
else
slsmg_write_nstring(ol->line, width - 18);

- if (!current_entry)
- ui_browser__set_color(self, HE_COLORSET_CODE);
- else
+ if (current_entry)
ab->selection = ol;
}

--
1.7.9

2012-02-23 08:28:14

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 4/5] perf annotate: Fix help string on tui

Separate multiple binding using /, capitalize descriptions,
add missing key binding.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/ui/browsers/annotate.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index e73357770d5d..57a4c6ef3fd2 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -233,9 +233,9 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
struct rb_node *nd = NULL;
struct map_symbol *ms = self->b.priv;
struct symbol *sym = ms->sym;
- const char *help = "<-, ESC: exit, TAB/shift+TAB: cycle hottest lines, "
- "H: Hottest, -> Line action, S -> Toggle source "
- "code view";
+ const char *help = "<-/ESC: Exit, TAB/shift+TAB: Cycle hot lines, "
+ "H: Go to hottest line, ->/ENTER: Line action, "
+ "S: Toggle source code view";
int key;

if (ui_browser__show(&self->b, sym->name, help) < 0)
--
1.7.9

2012-02-23 08:28:13

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 3/5] perf annotate: Restore title when came back to original symbol

On tui annotation, the title was set to name of the target symbol if
user selects the target. However it remained after returning to original
symbol from the target. Fix it.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/ui/browsers/annotate.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 374d3bc570b2..e73357770d5d 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -343,6 +343,7 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
pthread_mutex_unlock(&notes->lock);
symbol__tui_annotate(target, ms->map, evidx,
timer, arg, delay_secs);
+ ui_browser__show_title(&self->b, sym->name);
}
continue;
case K_LEFT:
--
1.7.9