Skip to content

Commit 0c5a0f9

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Arjan & Linus Annotation Edition - Fix indirect calls beautifier, reported by Linus. - Use the objdump comments to nuke specificities about how access to a well know variable is encoded, suggested by Linus. - Show the number of places that jump to a target, requested by Arjan. Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 5dcefda + 54e7a4e commit 0c5a0f9

File tree

3 files changed

+369
-43
lines changed

3 files changed

+369
-43
lines changed

tools/perf/ui/browsers/annotate.c

Lines changed: 80 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct browser_disasm_line {
1616
double percent;
1717
u32 idx;
1818
int idx_asm;
19-
bool jump_target;
19+
int jump_sources;
2020
};
2121

2222
struct annotate_browser {
@@ -28,11 +28,16 @@ struct annotate_browser {
2828
u64 start;
2929
int nr_asm_entries;
3030
int nr_entries;
31+
int max_jump_sources;
32+
int nr_jumps;
3133
bool hide_src_code;
3234
bool use_offset;
3335
bool jump_arrows;
36+
bool show_nr_jumps;
3437
bool searching_backwards;
3538
u8 addr_width;
39+
u8 jumps_width;
40+
u8 target_width;
3641
u8 min_addr_width;
3742
u8 max_addr_width;
3843
char search_bf[128];
@@ -55,6 +60,25 @@ static bool disasm_line__filter(struct ui_browser *browser, void *entry)
5560
return false;
5661
}
5762

63+
static int annotate_browser__jumps_percent_color(struct annotate_browser *browser,
64+
int nr, bool current)
65+
{
66+
if (current && (!browser->b.use_navkeypressed || browser->b.navkeypressed))
67+
return HE_COLORSET_SELECTED;
68+
if (nr == browser->max_jump_sources)
69+
return HE_COLORSET_TOP;
70+
if (nr > 1)
71+
return HE_COLORSET_MEDIUM;
72+
return HE_COLORSET_NORMAL;
73+
}
74+
75+
static int annotate_browser__set_jumps_percent_color(struct annotate_browser *browser,
76+
int nr, bool current)
77+
{
78+
int color = annotate_browser__jumps_percent_color(browser, nr, current);
79+
return ui_browser__set_color(&browser->b, color);
80+
}
81+
5882
static void annotate_browser__write(struct ui_browser *self, void *entry, int row)
5983
{
6084
struct annotate_browser *ab = container_of(self, struct annotate_browser, b);
@@ -98,9 +122,20 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
98122
if (!ab->use_offset) {
99123
printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ": ", addr);
100124
} else {
101-
if (bdl->jump_target) {
125+
if (bdl->jump_sources) {
126+
if (ab->show_nr_jumps) {
127+
int prev;
128+
printed = scnprintf(bf, sizeof(bf), "%*d ",
129+
ab->jumps_width,
130+
bdl->jump_sources);
131+
prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources,
132+
current_entry);
133+
slsmg_write_nstring(bf, printed);
134+
ui_browser__set_color(self, prev);
135+
}
136+
102137
printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ",
103-
ab->addr_width, addr);
138+
ab->target_width, addr);
104139
} else {
105140
printed = scnprintf(bf, sizeof(bf), "%*s ",
106141
ab->addr_width, " ");
@@ -546,10 +581,7 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
546581
struct rb_node *nd = NULL;
547582
struct map_symbol *ms = self->b.priv;
548583
struct symbol *sym = ms->sym;
549-
const char *help = "<-/ESC: Exit, TAB/shift+TAB: Cycle hot lines, "
550-
"H: Hottest line, ->/ENTER: Line action, "
551-
"O: Offset view, "
552-
"S: Source view";
584+
const char *help = "Press 'h' for help on key bindings";
553585
int key;
554586

555587
if (ui_browser__show(&self->b, sym->name, help) < 0)
@@ -602,26 +634,47 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
602634
else
603635
nd = self->curr_hot;
604636
break;
605-
case 'H':
637+
case K_F1:
606638
case 'h':
639+
ui_browser__help_window(&self->b,
640+
"UP/DOWN/PGUP\n"
641+
"PGDN/SPACE Navigate\n"
642+
"q/ESC/CTRL+C Exit\n\n"
643+
"-> Go to target\n"
644+
"<- Exit\n"
645+
"h Cycle thru hottest instructions\n"
646+
"j Toggle showing jump to target arrows\n"
647+
"J Toggle showing number of jump sources on targets\n"
648+
"n Search next string\n"
649+
"o Toggle disassembler output/simplified view\n"
650+
"s Toggle source code view\n"
651+
"/ Search string\n"
652+
"? Search previous string\n");
653+
continue;
654+
case 'H':
607655
nd = self->curr_hot;
608656
break;
609-
case 'S':
610657
case 's':
611658
if (annotate_browser__toggle_source(self))
612659
ui_helpline__puts(help);
613660
continue;
614-
case 'O':
615661
case 'o':
616662
self->use_offset = !self->use_offset;
617663
if (self->use_offset)
618-
self->addr_width = self->min_addr_width;
664+
self->target_width = self->min_addr_width;
619665
else
620-
self->addr_width = self->max_addr_width;
666+
self->target_width = self->max_addr_width;
667+
update_addr_width:
668+
self->addr_width = self->target_width;
669+
if (self->show_nr_jumps)
670+
self->addr_width += self->jumps_width + 1;
621671
continue;
622672
case 'j':
623673
self->jump_arrows = !self->jump_arrows;
624674
continue;
675+
case 'J':
676+
self->show_nr_jumps = !self->show_nr_jumps;
677+
goto update_addr_width;
625678
case '/':
626679
if (annotate_browser__search(self, delay_secs)) {
627680
show_help:
@@ -707,11 +760,23 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser
707760
continue;
708761

709762
bdlt = disasm_line__browser(dlt);
710-
bdlt->jump_target = true;
763+
if (++bdlt->jump_sources > browser->max_jump_sources)
764+
browser->max_jump_sources = bdlt->jump_sources;
765+
766+
++browser->nr_jumps;
711767
}
712768

713769
}
714770

771+
static inline int width_jumps(int n)
772+
{
773+
if (n >= 100)
774+
return 5;
775+
if (n / 10)
776+
return 2;
777+
return 1;
778+
}
779+
715780
int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
716781
void(*timer)(void *arg), void *arg,
717782
int delay_secs)
@@ -784,8 +849,9 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
784849

785850
annotate_browser__mark_jump_targets(&browser, size);
786851

787-
browser.addr_width = browser.min_addr_width = hex_width(size);
852+
browser.addr_width = browser.target_width = browser.min_addr_width = hex_width(size);
788853
browser.max_addr_width = hex_width(sym->end);
854+
browser.jumps_width = width_jumps(browser.max_jump_sources);
789855
browser.b.nr_entries = browser.nr_entries;
790856
browser.b.entries = &notes->src->source,
791857
browser.b.width += 18; /* Percentage */

0 commit comments

Comments
 (0)