Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304842
b: refs/heads/master
c: 61e04b3
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Apr 19, 2012
1 parent 2de02f0 commit c22f962
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b793a40185b246c2690e06c6d86d12c35f24ab4c
refs/heads/master: 61e04b332e9417720c331eb39c96a4ccb1aa0460
17 changes: 13 additions & 4 deletions trunk/tools/perf/ui/browsers/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct annotate_browser {
bool hide_src_code;
bool use_offset;
bool searching_backwards;
u8 offset_width;
char search_bf[128];
};

Expand Down Expand Up @@ -92,10 +93,17 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
if (!ab->use_offset)
addr += ab->start;

if (bdl->jump_target || !ab->use_offset)
printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr);
else
printed = scnprintf(bf, sizeof(bf), " ");
if (!ab->use_offset) {
printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ":", addr);
} else {
if (bdl->jump_target) {
printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ":",
ab->offset_width, addr);
} else {
printed = scnprintf(bf, sizeof(bf), "%*s ",
ab->offset_width, " ");
}
}

if (change_color)
color = ui_browser__set_color(self, HE_COLORSET_ADDR);
Expand Down Expand Up @@ -687,6 +695,7 @@ 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.b.nr_entries = browser.nr_entries;
browser.b.entries = &notes->src->source,
browser.b.width += 18; /* Percentage */
Expand Down
10 changes: 10 additions & 0 deletions trunk/tools/perf/util/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,13 @@ int readn(int fd, void *buf, size_t n)

return buf - buf_start;
}

size_t hex_width(u64 v)
{
size_t n = 1;

while ((v >>= 4))
++n;

return n;
}
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,6 @@ bool is_power_of_2(unsigned long n)
return (n != 0 && ((n & (n - 1)) == 0));
}

size_t hex_width(u64 v);

#endif

0 comments on commit c22f962

Please sign in to comment.