Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304839
b: refs/heads/master
c: 887c006
h: refs/heads/master
i:
  304837: fce7520
  304835: 9f1eb11
  304831: 681c633
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Apr 19, 2012
1 parent 9b23b87 commit d387b59
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 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: 28548d78ad521310f0ae58f791aa796d3d685151
refs/heads/master: 887c0066a810234cfae9927b3781b6a1c617fb39
76 changes: 38 additions & 38 deletions trunk/tools/perf/ui/browsers/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ struct annotate_browser {
char search_bf[128];
};

struct disasm_line_rb_node {
struct browser_disasm_line {
struct rb_node rb_node;
double percent;
u32 idx;
int idx_asm;
};

static inline struct disasm_line_rb_node *disasm_line__rb(struct disasm_line *dl)
static inline struct browser_disasm_line *disasm_line__browser(struct disasm_line *dl)
{
return (struct disasm_line_rb_node *)(dl + 1);
return (struct browser_disasm_line *)(dl + 1);
}

static bool disasm_line__filter(struct ui_browser *browser, void *entry)
Expand All @@ -60,9 +60,9 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
int width = self->width;

if (dl->offset != -1) {
struct disasm_line_rb_node *dlrb = disasm_line__rb(dl);
ui_browser__set_percent_color(self, dlrb->percent, current_entry);
slsmg_printf(" %7.2f ", dlrb->percent);
struct browser_disasm_line *bdl = disasm_line__browser(dl);
ui_browser__set_percent_color(self, bdl->percent, current_entry);
slsmg_printf(" %7.2f ", bdl->percent);
} else {
ui_browser__set_percent_color(self, 0, current_entry);
slsmg_write_nstring(" ", 9);
Expand Down Expand Up @@ -146,22 +146,22 @@ static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *s
return percent;
}

static void disasm_rb_tree__insert(struct rb_root *root, struct disasm_line_rb_node *dlrb)
static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_line *bdl)
{
struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL;
struct disasm_line_rb_node *l;
struct browser_disasm_line *l;

while (*p != NULL) {
parent = *p;
l = rb_entry(parent, struct disasm_line_rb_node, rb_node);
if (dlrb->percent < l->percent)
l = rb_entry(parent, struct browser_disasm_line, rb_node);
if (bdl->percent < l->percent)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
rb_link_node(&dlrb->rb_node, parent, p);
rb_insert_color(&dlrb->rb_node, root);
rb_link_node(&bdl->rb_node, parent, p);
rb_insert_color(&bdl->rb_node, root);
}

static void annotate_browser__set_top(struct annotate_browser *self,
Expand Down Expand Up @@ -190,12 +190,12 @@ static void annotate_browser__set_top(struct annotate_browser *self,
static void annotate_browser__set_rb_top(struct annotate_browser *browser,
struct rb_node *nd)
{
struct disasm_line_rb_node *rbpos;
struct browser_disasm_line *bpos;
struct disasm_line *pos;

rbpos = rb_entry(nd, struct disasm_line_rb_node, rb_node);
pos = ((struct disasm_line *)rbpos) - 1;
annotate_browser__set_top(browser, pos, rbpos->idx);
bpos = rb_entry(nd, struct browser_disasm_line, rb_node);
pos = ((struct disasm_line *)bpos) - 1;
annotate_browser__set_top(browser, pos, bpos->idx);
browser->curr_hot = nd;
}

Expand All @@ -212,13 +212,13 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
pthread_mutex_lock(&notes->lock);

list_for_each_entry(pos, &notes->src->source, node) {
struct disasm_line_rb_node *rbpos = disasm_line__rb(pos);
rbpos->percent = disasm_line__calc_percent(pos, sym, evidx);
if (rbpos->percent < 0.01) {
RB_CLEAR_NODE(&rbpos->rb_node);
struct browser_disasm_line *bpos = disasm_line__browser(pos);
bpos->percent = disasm_line__calc_percent(pos, sym, evidx);
if (bpos->percent < 0.01) {
RB_CLEAR_NODE(&bpos->rb_node);
continue;
}
disasm_rb_tree__insert(&browser->entries, rbpos);
disasm_rb_tree__insert(&browser->entries, bpos);
}
pthread_mutex_unlock(&notes->lock);

Expand All @@ -228,37 +228,37 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
static bool annotate_browser__toggle_source(struct annotate_browser *browser)
{
struct disasm_line *dl;
struct disasm_line_rb_node *dlrb;
struct browser_disasm_line *bdl;
off_t offset = browser->b.index - browser->b.top_idx;

browser->b.seek(&browser->b, offset, SEEK_CUR);
dl = list_entry(browser->b.top, struct disasm_line, node);
dlrb = disasm_line__rb(dl);
bdl = disasm_line__browser(dl);

if (browser->hide_src_code) {
if (dlrb->idx_asm < offset)
offset = dlrb->idx;
if (bdl->idx_asm < offset)
offset = bdl->idx;

browser->b.nr_entries = browser->nr_entries;
browser->hide_src_code = false;
browser->b.seek(&browser->b, -offset, SEEK_CUR);
browser->b.top_idx = dlrb->idx - offset;
browser->b.index = dlrb->idx;
browser->b.top_idx = bdl->idx - offset;
browser->b.index = bdl->idx;
} else {
if (dlrb->idx_asm < 0) {
if (bdl->idx_asm < 0) {
ui_helpline__puts("Only available for assembly lines.");
browser->b.seek(&browser->b, -offset, SEEK_CUR);
return false;
}

if (dlrb->idx_asm < offset)
offset = dlrb->idx_asm;
if (bdl->idx_asm < offset)
offset = bdl->idx_asm;

browser->b.nr_entries = browser->nr_asm_entries;
browser->hide_src_code = true;
browser->b.seek(&browser->b, -offset, SEEK_CUR);
browser->b.top_idx = dlrb->idx_asm - offset;
browser->b.index = dlrb->idx_asm;
browser->b.top_idx = bdl->idx_asm - offset;
browser->b.index = bdl->idx_asm;
}

return true;
Expand Down Expand Up @@ -621,7 +621,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
if (map->dso->annotate_warned)
return -1;

if (symbol__annotate(sym, map, sizeof(struct disasm_line_rb_node)) < 0) {
if (symbol__annotate(sym, map, sizeof(struct browser_disasm_line)) < 0) {
ui__error("%s", ui_helpline__last_msg);
return -1;
}
Expand All @@ -632,17 +632,17 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
browser.start = map__rip_2objdump(map, sym->start);

list_for_each_entry(pos, &notes->src->source, node) {
struct disasm_line_rb_node *rbpos;
struct browser_disasm_line *bpos;
size_t line_len = strlen(pos->line);

if (browser.b.width < line_len)
browser.b.width = line_len;
rbpos = disasm_line__rb(pos);
rbpos->idx = browser.nr_entries++;
bpos = disasm_line__browser(pos);
bpos->idx = browser.nr_entries++;
if (pos->offset != -1)
rbpos->idx_asm = browser.nr_asm_entries++;
bpos->idx_asm = browser.nr_asm_entries++;
else
rbpos->idx_asm = -1;
bpos->idx_asm = -1;
}

browser.b.nr_entries = browser.nr_entries;
Expand Down

0 comments on commit d387b59

Please sign in to comment.