From 88298f5a52dad53a7a9433470925fa90702bb486 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 27 Apr 2012 15:10:54 -0300 Subject: perf annotate browser: Add a right arrow before call instructions The counterpart of 'ret' instructions. Suggested-by: Linus Torvalds Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-jlz2ldaquaow0rqi2vr4b91l@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 077380b..4778172 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -117,6 +117,9 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ui_browser__write_graph(self, fwd ? SLSMG_DARROW_CHAR : SLSMG_UARROW_CHAR); SLsmg_write_char(' '); + } else if (ins__is_call(dl->ins)) { + ui_browser__write_graph(self, SLSMG_RARROW_CHAR); + SLsmg_write_char(' '); } else { slsmg_write_nstring(" ", 2); } -- cgit v0.10.2 From 944e1abed9e1c04e410ddfee849529eedd3e534a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 27 Apr 2012 16:27:52 -0300 Subject: perf ui browser: Add method to draw up/down arrow line It figures out the direction and draws downwards arrows too if that is the case. Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-tg329nr7q4dg9d0tl3o0wywg@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index 32ac116..f4b2530 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -600,8 +600,9 @@ void ui_browser__write_graph(struct ui_browser *browser __used, int graph) SLsmg_set_char_set(0); } -void __ui_browser__line_arrow_up(struct ui_browser *browser, unsigned int column, - u64 start, u64 end, int start_width) +static void __ui_browser__line_arrow_up(struct ui_browser *browser, + unsigned int column, + u64 start, u64 end, int start_width) { unsigned int row, end_row; @@ -639,6 +640,55 @@ out: SLsmg_set_char_set(0); } +static void __ui_browser__line_arrow_down(struct ui_browser *browser, + unsigned int column, + u64 start, u64 end, int start_width) +{ + unsigned int row, end_row; + + SLsmg_set_char_set(1); + + if (start >= browser->top_idx) { + row = start - browser->top_idx; + ui_browser__gotorc(browser, row, column); + SLsmg_write_char(SLSMG_ULCORN_CHAR); + ui_browser__gotorc(browser, row, column + 1); + SLsmg_draw_hline(start_width); + + if (row++ == 0) + goto out; + } else + row = 0; + + if (end >= browser->top_idx + browser->height) + end_row = browser->height - 1; + else + end_row = end - browser->top_idx;; + + ui_browser__gotorc(browser, row, column); + SLsmg_draw_vline(end_row - row + 1); + + ui_browser__gotorc(browser, end_row, column); + if (end < browser->top_idx + browser->height) { + SLsmg_write_char(SLSMG_LLCORN_CHAR); + ui_browser__gotorc(browser, end_row, column + 1); + SLsmg_write_char(SLSMG_HLINE_CHAR); + ui_browser__gotorc(browser, end_row, column + 2); + SLsmg_write_char(SLSMG_RARROW_CHAR); + } +out: + SLsmg_set_char_set(0); +} + +void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, + u64 start, u64 end, int start_width) +{ + if (start > end) + __ui_browser__line_arrow_up(browser, column, start, end, start_width); + else + __ui_browser__line_arrow_down(browser, column, start, end, start_width); +} + void ui_browser__init(void) { int i = 0; diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h index 2f226cb..059764b 100644 --- a/tools/perf/ui/browser.h +++ b/tools/perf/ui/browser.h @@ -38,8 +38,8 @@ void ui_browser__reset_index(struct ui_browser *self); void ui_browser__gotorc(struct ui_browser *self, int y, int x); void ui_browser__write_graph(struct ui_browser *browser, int graph); -void __ui_browser__line_arrow_up(struct ui_browser *browser, unsigned int column, - u64 start, u64 end, int start_width); +void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, + u64 start, u64 end, int start_width); void __ui_browser__show_title(struct ui_browser *browser, const char *title); void ui_browser__show_title(struct ui_browser *browser, const char *title); int ui_browser__show(struct ui_browser *self, const char *title, -- cgit v0.10.2 From 9d1ef56d571671097f54a5ec31a9b1fb7dc819ed Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 27 Apr 2012 16:35:29 -0300 Subject: perf annotate browser: Show current jump, back or forward Instead of trying to show the current loop by naively looking for the next backward jump, just use 'j' to toggle showing arrows connecting jump with its target. And do it for forward jumps as well. Loop detection requires more code to follow the flow control, etc. Reported-by: Linus Torvalds Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-soahcn1lz2u4wxj31ch0594j@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 4778172..d203daf 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -30,6 +30,7 @@ struct annotate_browser { int nr_entries; bool hide_src_code; bool use_offset; + bool jump_arrows; bool searching_backwards; u8 offset_width; char search_bf[128]; @@ -144,56 +145,47 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ab->selection = dl; } -static void annotate_browser__draw_current_loop(struct ui_browser *browser) +static void annotate_browser__draw_current_jump(struct ui_browser *browser) { struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); - struct map_symbol *ms = browser->priv; - struct symbol *sym = ms->sym; - struct annotation *notes = symbol__annotation(sym); - struct disasm_line *cursor = ab->selection, *pos = cursor, *target; - struct browser_disasm_line *bcursor = disasm_line__browser(cursor), - *btarget, *bpos; + struct disasm_line *cursor = ab->selection, *target; + struct browser_disasm_line *btarget, *bcursor; unsigned int from, to, start_width = 2; - list_for_each_entry_from(pos, ¬es->src->source, node) { - if (!pos->ins || !ins__is_jump(pos->ins) || - !disasm_line__has_offset(pos)) - continue; - - target = ab->offsets[pos->ops.target.offset]; - if (!target) - continue; + if (!cursor->ins || !ins__is_jump(cursor->ins) || + !disasm_line__has_offset(cursor)) + return; - btarget = disasm_line__browser(target); - if (btarget->idx <= bcursor->idx) - goto found; - } + target = ab->offsets[cursor->ops.target.offset]; + if (!target) + return; - return; + bcursor = disasm_line__browser(cursor); + btarget = disasm_line__browser(target); -found: - bpos = disasm_line__browser(pos); if (ab->hide_src_code) { - from = bpos->idx_asm; + from = bcursor->idx_asm; to = btarget->idx_asm; } else { - from = (u64)bpos->idx; + from = (u64)bcursor->idx; to = (u64)btarget->idx; } ui_browser__set_color(browser, HE_COLORSET_CODE); - if (!bpos->jump_target) + if (!bcursor->jump_target) start_width += ab->offset_width + 1; - __ui_browser__line_arrow_up(browser, 10, from, to, start_width); + __ui_browser__line_arrow(browser, 10, from, to, start_width); } static unsigned int annotate_browser__refresh(struct ui_browser *browser) { + struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); int ret = ui_browser__list_head_refresh(browser); - annotate_browser__draw_current_loop(browser); + if (ab->jump_arrows) + annotate_browser__draw_current_jump(browser); return ret; } @@ -628,6 +620,9 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, case 'o': self->use_offset = !self->use_offset; continue; + case 'j': + self->jump_arrows = !self->jump_arrows; + continue; case '/': if (annotate_browser__search(self, delay_secs)) { show_help: @@ -739,6 +734,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, .use_navkeypressed = true, }, .use_offset = true, + .jump_arrows = true, }; int ret = -1; -- cgit v0.10.2 From 3e8b5ddf17d4639d41bc57ecfb51633815b70e49 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 27 Apr 2012 16:44:56 -0300 Subject: perf annotate browser: Remove the vertical line after the percentages It is confusing when used with jump -> target lines. Requested-by: Linus Torvalds Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-xeiyfsxptwtmlvowledg6wpy@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index d203daf..a90680b 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -72,7 +72,6 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro slsmg_write_nstring(" ", 9); } - ui_browser__write_graph(self, SLSMG_VLINE_CHAR); SLsmg_write_char(' '); /* The scroll bar isn't being used */ @@ -83,9 +82,9 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ui_browser__set_color(self, HE_COLORSET_CODE); if (!*dl->line) - slsmg_write_nstring(" ", width - 10); + slsmg_write_nstring(" ", width - 9); else if (dl->offset == -1) - slsmg_write_nstring(dl->line, width - 10); + slsmg_write_nstring(dl->line, width - 9); else { char bf[256]; u64 addr = dl->offset; @@ -138,7 +137,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro scnprintf(bf, sizeof(bf), "%-6.6s %s", dl->name, dl->ops.raw); } - slsmg_write_nstring(bf, width - 12 - printed); + slsmg_write_nstring(bf, width - 11 - printed); } if (current_entry) @@ -176,7 +175,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) if (!bcursor->jump_target) start_width += ab->offset_width + 1; - __ui_browser__line_arrow(browser, 10, from, to, start_width); + __ui_browser__line_arrow(browser, 9, from, to, start_width); } static unsigned int annotate_browser__refresh(struct ui_browser *browser) -- cgit v0.10.2 From 0822cc80d9aee026b1ebe43c02dc01e0a0227864 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 27 Apr 2012 17:13:53 -0300 Subject: perf annotate browser: Don't display 0.00 percentages Cleaning up more the output. Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-81pimnsnaa9y2j0a9plstu1c@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index a90680b..44fb6a4 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -64,12 +64,12 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro !self->navkeypressed))); int width = self->width; - if (dl->offset != -1) { + if (dl->offset != -1 && bdl->percent != 0.0) { ui_browser__set_percent_color(self, bdl->percent, current_entry); - slsmg_printf(" %7.2f ", bdl->percent); + slsmg_printf("%6.2f ", bdl->percent); } else { ui_browser__set_percent_color(self, 0, current_entry); - slsmg_write_nstring(" ", 9); + slsmg_write_nstring(" ", 7); } SLsmg_write_char(' '); @@ -82,9 +82,9 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ui_browser__set_color(self, HE_COLORSET_CODE); if (!*dl->line) - slsmg_write_nstring(" ", width - 9); + slsmg_write_nstring(" ", width - 7); else if (dl->offset == -1) - slsmg_write_nstring(dl->line, width - 9); + slsmg_write_nstring(dl->line, width - 7); else { char bf[256]; u64 addr = dl->offset; @@ -137,7 +137,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro scnprintf(bf, sizeof(bf), "%-6.6s %s", dl->name, dl->ops.raw); } - slsmg_write_nstring(bf, width - 11 - printed); + slsmg_write_nstring(bf, width - 9 - printed); } if (current_entry) @@ -175,7 +175,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) if (!bcursor->jump_target) start_width += ab->offset_width + 1; - __ui_browser__line_arrow(browser, 9, from, to, start_width); + __ui_browser__line_arrow(browser, 7, from, to, start_width); } static unsigned int annotate_browser__refresh(struct ui_browser *browser) -- cgit v0.10.2 From 4656cca11b07a13785aa8574ed4db6c540e48ed8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 3 May 2012 13:07:05 -0300 Subject: perf ui browser: Introduce routine to draw vertical line Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-umb4jlu0ee8r2rc3x4jkahgk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index f4b2530..b075e09 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -593,6 +593,15 @@ unsigned int ui_browser__argv_refresh(struct ui_browser *browser) return row; } +void __ui_browser__vline(struct ui_browser *browser, unsigned int column, + u16 start, u16 end) +{ + SLsmg_set_char_set(1); + ui_browser__gotorc(browser, start, column); + SLsmg_draw_vline(end - start + 1); + SLsmg_set_char_set(0); +} + void ui_browser__write_graph(struct ui_browser *browser __used, int graph) { SLsmg_set_char_set(1); diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h index 059764b..511e24d 100644 --- a/tools/perf/ui/browser.h +++ b/tools/perf/ui/browser.h @@ -49,6 +49,8 @@ int ui_browser__refresh(struct ui_browser *self); int ui_browser__run(struct ui_browser *browser, int delay_secs); void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); void ui_browser__handle_resize(struct ui_browser *browser); +void __ui_browser__vline(struct ui_browser *browser, unsigned int column, + u16 start, u16 end); int ui_browser__warning(struct ui_browser *browser, int timeout, const char *format, ...); -- cgit v0.10.2 From 83b1f2aad46c4af7df5ba6071fbba2d5cb025985 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 3 May 2012 13:12:49 -0300 Subject: perf annotate browser: More clearly separate columns The first column (columns in the near future) are for the per line event overhead(s), that only appear when they are not zero. To clearly separate it, add back a solid vertical line, with just one colour, not influenced by the per line overheads. Then have the addr/offset column, then optionally the dynamic (static in the future) jump->target arrows, if 'j' enables it. Then the instructions. Requested-by: Peter Zijlstra Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-r415t4sps0oyr9y8kd9j7clz@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index b075e09..cde4d0f 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -611,7 +611,7 @@ void ui_browser__write_graph(struct ui_browser *browser __used, int graph) static void __ui_browser__line_arrow_up(struct ui_browser *browser, unsigned int column, - u64 start, u64 end, int start_width) + u64 start, u64 end) { unsigned int row, end_row; @@ -622,7 +622,7 @@ static void __ui_browser__line_arrow_up(struct ui_browser *browser, ui_browser__gotorc(browser, row, column); SLsmg_write_char(SLSMG_LLCORN_CHAR); ui_browser__gotorc(browser, row, column + 1); - SLsmg_draw_hline(start_width); + SLsmg_draw_hline(2); if (row-- == 0) goto out; @@ -651,7 +651,7 @@ out: static void __ui_browser__line_arrow_down(struct ui_browser *browser, unsigned int column, - u64 start, u64 end, int start_width) + u64 start, u64 end) { unsigned int row, end_row; @@ -662,7 +662,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser, ui_browser__gotorc(browser, row, column); SLsmg_write_char(SLSMG_ULCORN_CHAR); ui_browser__gotorc(browser, row, column + 1); - SLsmg_draw_hline(start_width); + SLsmg_draw_hline(2); if (row++ == 0) goto out; @@ -690,12 +690,12 @@ out: } void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, - u64 start, u64 end, int start_width) + u64 start, u64 end) { if (start > end) - __ui_browser__line_arrow_up(browser, column, start, end, start_width); + __ui_browser__line_arrow_up(browser, column, start, end); else - __ui_browser__line_arrow_down(browser, column, start, end, start_width); + __ui_browser__line_arrow_down(browser, column, start, end); } void ui_browser__init(void) diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h index 511e24d..dd96d82 100644 --- a/tools/perf/ui/browser.h +++ b/tools/perf/ui/browser.h @@ -39,7 +39,7 @@ void ui_browser__reset_index(struct ui_browser *self); void ui_browser__gotorc(struct ui_browser *self, int y, int x); void ui_browser__write_graph(struct ui_browser *browser, int graph); void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, - u64 start, u64 end, int start_width); + u64 start, u64 end); void __ui_browser__show_title(struct ui_browser *browser, const char *title); void ui_browser__show_title(struct ui_browser *browser, const char *title); int ui_browser__show(struct ui_browser *self, const char *title, diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 44fb6a4..74104a4 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -32,7 +32,9 @@ struct annotate_browser { bool use_offset; bool jump_arrows; bool searching_backwards; - u8 offset_width; + u8 addr_width; + u8 min_addr_width; + u8 max_addr_width; char search_bf[128]; }; @@ -62,7 +64,8 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro bool change_color = (!ab->hide_src_code && (!current_entry || (self->use_navkeypressed && !self->navkeypressed))); - int width = self->width; + int width = self->width, printed; + char bf[256]; if (dl->offset != -1 && bdl->percent != 0.0) { ui_browser__set_percent_color(self, bdl->percent, current_entry); @@ -83,25 +86,27 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro if (!*dl->line) slsmg_write_nstring(" ", width - 7); - else if (dl->offset == -1) - slsmg_write_nstring(dl->line, width - 7); - else { - char bf[256]; + else if (dl->offset == -1) { + printed = scnprintf(bf, sizeof(bf), "%*s ", + ab->addr_width, " "); + slsmg_write_nstring(bf, printed); + slsmg_write_nstring(dl->line, width - printed - 6); + } else { u64 addr = dl->offset; - int printed, color = -1; + int color = -1; if (!ab->use_offset) addr += ab->start; if (!ab->use_offset) { - printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr); + printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ": ", addr); } else { if (bdl->jump_target) { - printed = scnprintf(bf, sizeof(bf), " %*" PRIx64 ":", - ab->offset_width, addr); + printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ", + ab->addr_width, addr); } else { - printed = scnprintf(bf, sizeof(bf), " %*s ", - ab->offset_width, " "); + printed = scnprintf(bf, sizeof(bf), "%*s ", + ab->addr_width, " "); } } @@ -137,7 +142,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro scnprintf(bf, sizeof(bf), "%-6.6s %s", dl->name, dl->ops.raw); } - slsmg_write_nstring(bf, width - 9 - printed); + slsmg_write_nstring(bf, width - 10 - printed); } if (current_entry) @@ -149,7 +154,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); struct disasm_line *cursor = ab->selection, *target; struct browser_disasm_line *btarget, *bcursor; - unsigned int from, to, start_width = 2; + unsigned int from, to; if (!cursor->ins || !ins__is_jump(cursor->ins) || !disasm_line__has_offset(cursor)) @@ -171,11 +176,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) } ui_browser__set_color(browser, HE_COLORSET_CODE); - - if (!bcursor->jump_target) - start_width += ab->offset_width + 1; - - __ui_browser__line_arrow(browser, 7, from, to, start_width); + __ui_browser__line_arrow(browser, 9 + ab->addr_width, from, to); } static unsigned int annotate_browser__refresh(struct ui_browser *browser) @@ -186,6 +187,8 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser) if (ab->jump_arrows) annotate_browser__draw_current_jump(browser); + ui_browser__set_color(browser, HE_COLORSET_NORMAL); + __ui_browser__vline(browser, 7, 0, browser->height - 1); return ret; } @@ -618,6 +621,10 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, case 'O': case 'o': self->use_offset = !self->use_offset; + if (self->use_offset) + self->addr_width = self->min_addr_width; + else + self->addr_width = self->max_addr_width; continue; case 'j': self->jump_arrows = !self->jump_arrows; @@ -784,7 +791,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, annotate_browser__mark_jump_targets(&browser, size); - browser.offset_width = hex_width(size); + browser.addr_width = browser.min_addr_width = hex_width(size); + browser.max_addr_width = hex_width(sym->end); browser.b.nr_entries = browser.nr_entries; browser.b.entries = ¬es->src->source, browser.b.width += 18; /* Percentage */ -- cgit v0.10.2 From 64aa17ca5a4e428fcb6d0806823a99a18c548506 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 3 May 2012 13:23:00 -0300 Subject: perf annotate browser: Don't change the asm line color when toggling source Gets confusing. Remains to be chosen an appropriate different color for source code. This effectively reverts 58e817d997d1 ("perf annotate: Print asm code as blue when source code is displayed") Requested-by: Peter Zijlstra Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-qy9iq32nj3uqe5dbiuq9e3j9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 74104a4..b94da57 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -81,9 +81,6 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro if (!self->navkeypressed) width += 1; - if (dl->offset != -1 && change_color) - ui_browser__set_color(self, HE_COLORSET_CODE); - if (!*dl->line) slsmg_write_nstring(" ", width - 7); else if (dl->offset == -1) { -- cgit v0.10.2 From 5417072bf6b17eaa31f21f12906f381f148b5200 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 7 May 2012 18:54:16 -0300 Subject: perf annotate browser: Do raw printing in 'o'ffset in a single place Instead of doing the same in all ins scnprintf methods. Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-8mfairi2n1nentoa852alazv@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index b94da57..f171b46 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -125,9 +125,6 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro } else { slsmg_write_nstring(" ", 2); } - - dl->ins->ops->scnprintf(dl->ins, bf, sizeof(bf), &dl->ops, - !ab->use_offset); } else { if (strcmp(dl->name, "retq")) { slsmg_write_nstring(" ", 2); @@ -135,10 +132,9 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ui_browser__write_graph(self, SLSMG_LARROW_CHAR); SLsmg_write_char(' '); } - - scnprintf(bf, sizeof(bf), "%-6.6s %s", dl->name, dl->ops.raw); } + disasm_line__scnprintf(dl, bf, sizeof(bf), !ab->use_offset); slsmg_write_nstring(bf, width - 10 - printed); } diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 5eb3412..0905db4 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -18,6 +18,21 @@ const char *disassembler_style; +static int ins__raw_scnprintf(struct ins *ins, char *bf, size_t size, + struct ins_operands *ops) +{ + return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw); +} + +int ins__scnprintf(struct ins *ins, char *bf, size_t size, + struct ins_operands *ops) +{ + if (ins->ops->scnprintf) + return ins->ops->scnprintf(ins, bf, size, ops); + + return ins__raw_scnprintf(ins, bf, size, ops); +} + static int call__parse(struct ins_operands *ops) { char *endptr, *tok, *name; @@ -50,11 +65,8 @@ indirect_call: } static int call__scnprintf(struct ins *ins, char *bf, size_t size, - struct ins_operands *ops, bool addrs) + struct ins_operands *ops) { - if (addrs) - return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw); - if (ops->target.name) return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->target.name); @@ -86,11 +98,8 @@ static int jump__parse(struct ins_operands *ops) } static int jump__scnprintf(struct ins *ins, char *bf, size_t size, - struct ins_operands *ops, bool addrs) + struct ins_operands *ops) { - if (addrs) - return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw); - return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset); } @@ -296,6 +305,14 @@ void disasm_line__free(struct disasm_line *dl) free(dl); } +int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw) +{ + if (raw || !dl->ins) + return scnprintf(bf, size, "%-6.6s %s", dl->name, dl->ops.raw); + + return ins__scnprintf(dl->ins, bf, size, &dl->ops); +} + static void disasm__add(struct list_head *head, struct disasm_line *line) { list_add_tail(&line->node, head); diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 13a21f1..bb0a9f2 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -22,7 +22,7 @@ struct ins_operands { struct ins_ops { int (*parse)(struct ins_operands *ops); int (*scnprintf)(struct ins *ins, char *bf, size_t size, - struct ins_operands *ops, bool addrs); + struct ins_operands *ops); }; struct ins { @@ -32,6 +32,7 @@ struct ins { bool ins__is_jump(const struct ins *ins); bool ins__is_call(const struct ins *ins); +int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops); struct disasm_line { struct list_head node; @@ -49,6 +50,7 @@ static inline bool disasm_line__has_offset(const struct disasm_line *dl) void disasm_line__free(struct disasm_line *dl); struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos); +int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); size_t disasm__fprintf(struct list_head *head, FILE *fp); struct sym_hist { -- cgit v0.10.2 From b9818e93759c30c8942391f4f5fadaa36659ee33 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 7 May 2012 18:57:02 -0300 Subject: perf annotate browser: Compact 'nop' output Just suppress the nop operands, future infrastructure that will record the instruction lenght (and its contents) in struct ins will allow rendering them as nopN, i.e. nop5 for a 5-byte nop. Suggested-by: Linus Torvalds Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-qddbeglfzqdlal8vj2yaj67y@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 0905db4..6b4146b 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -113,6 +113,16 @@ bool ins__is_jump(const struct ins *ins) return ins->ops == &jump_ops; } +static int nop__scnprintf(struct ins *ins __used, char *bf, size_t size, + struct ins_operands *ops __used) +{ + return scnprintf(bf, size, "%-6.6s", "nop"); +} + +static struct ins_ops nop_ops = { + .scnprintf = nop__scnprintf, +}; + /* * Must be sorted by name! */ @@ -154,6 +164,9 @@ static struct ins instructions[] = { { .name = "jrcxz", .ops = &jump_ops, }, { .name = "js", .ops = &jump_ops, }, { .name = "jz", .ops = &jump_ops, }, + { .name = "nop", .ops = &nop_ops, }, + { .name = "nopl", .ops = &nop_ops, }, + { .name = "nopw", .ops = &nop_ops, }, }; static int ins__cmp(const void *name, const void *insp) -- cgit v0.10.2