aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-04-19 09:29:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-04-19 09:29:53 -0400
commit887c0066a810234cfae9927b3781b6a1c617fb39 (patch)
tree6d247f9ace023012c2345a7cb6a418512f3dead7 /tools/perf/ui/browsers/annotate.c
parent28548d78ad521310f0ae58f791aa796d3d685151 (diff)
perf annotate browser: Rename disasm_line_rb_node
Its not just an rb_node, it carries extra state that is private to the browser. And will carry some more in the next patches. Better name it browser_disasm_line, i.e. something derived from disasm_line, that specializes it. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-nev4b97vdvv35we1qmooym52@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r--tools/perf/ui/browsers/annotate.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index f7d2db3e8464..58ebfd0ac1e8 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -25,16 +25,16 @@ struct annotate_browser {
25 char search_bf[128]; 25 char search_bf[128];
26}; 26};
27 27
28struct disasm_line_rb_node { 28struct browser_disasm_line {
29 struct rb_node rb_node; 29 struct rb_node rb_node;
30 double percent; 30 double percent;
31 u32 idx; 31 u32 idx;
32 int idx_asm; 32 int idx_asm;
33}; 33};
34 34
35static inline struct disasm_line_rb_node *disasm_line__rb(struct disasm_line *dl) 35static inline struct browser_disasm_line *disasm_line__browser(struct disasm_line *dl)
36{ 36{
37 return (struct disasm_line_rb_node *)(dl + 1); 37 return (struct browser_disasm_line *)(dl + 1);
38} 38}
39 39
40static bool disasm_line__filter(struct ui_browser *browser, void *entry) 40static bool disasm_line__filter(struct ui_browser *browser, void *entry)
@@ -60,9 +60,9 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
60 int width = self->width; 60 int width = self->width;
61 61
62 if (dl->offset != -1) { 62 if (dl->offset != -1) {
63 struct disasm_line_rb_node *dlrb = disasm_line__rb(dl); 63 struct browser_disasm_line *bdl = disasm_line__browser(dl);
64 ui_browser__set_percent_color(self, dlrb->percent, current_entry); 64 ui_browser__set_percent_color(self, bdl->percent, current_entry);
65 slsmg_printf(" %7.2f ", dlrb->percent); 65 slsmg_printf(" %7.2f ", bdl->percent);
66 } else { 66 } else {
67 ui_browser__set_percent_color(self, 0, current_entry); 67 ui_browser__set_percent_color(self, 0, current_entry);
68 slsmg_write_nstring(" ", 9); 68 slsmg_write_nstring(" ", 9);
@@ -146,22 +146,22 @@ static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *s
146 return percent; 146 return percent;
147} 147}
148 148
149static void disasm_rb_tree__insert(struct rb_root *root, struct disasm_line_rb_node *dlrb) 149static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_line *bdl)
150{ 150{
151 struct rb_node **p = &root->rb_node; 151 struct rb_node **p = &root->rb_node;
152 struct rb_node *parent = NULL; 152 struct rb_node *parent = NULL;
153 struct disasm_line_rb_node *l; 153 struct browser_disasm_line *l;
154 154
155 while (*p != NULL) { 155 while (*p != NULL) {
156 parent = *p; 156 parent = *p;
157 l = rb_entry(parent, struct disasm_line_rb_node, rb_node); 157 l = rb_entry(parent, struct browser_disasm_line, rb_node);
158 if (dlrb->percent < l->percent) 158 if (bdl->percent < l->percent)
159 p = &(*p)->rb_left; 159 p = &(*p)->rb_left;
160 else 160 else
161 p = &(*p)->rb_right; 161 p = &(*p)->rb_right;
162 } 162 }
163 rb_link_node(&dlrb->rb_node, parent, p); 163 rb_link_node(&bdl->rb_node, parent, p);
164 rb_insert_color(&dlrb->rb_node, root); 164 rb_insert_color(&bdl->rb_node, root);
165} 165}
166 166
167static void annotate_browser__set_top(struct annotate_browser *self, 167static void annotate_browser__set_top(struct annotate_browser *self,
@@ -190,12 +190,12 @@ static void annotate_browser__set_top(struct annotate_browser *self,
190static void annotate_browser__set_rb_top(struct annotate_browser *browser, 190static void annotate_browser__set_rb_top(struct annotate_browser *browser,
191 struct rb_node *nd) 191 struct rb_node *nd)
192{ 192{
193 struct disasm_line_rb_node *rbpos; 193 struct browser_disasm_line *bpos;
194 struct disasm_line *pos; 194 struct disasm_line *pos;
195 195
196 rbpos = rb_entry(nd, struct disasm_line_rb_node, rb_node); 196 bpos = rb_entry(nd, struct browser_disasm_line, rb_node);
197 pos = ((struct disasm_line *)rbpos) - 1; 197 pos = ((struct disasm_line *)bpos) - 1;
198 annotate_browser__set_top(browser, pos, rbpos->idx); 198 annotate_browser__set_top(browser, pos, bpos->idx);
199 browser->curr_hot = nd; 199 browser->curr_hot = nd;
200} 200}
201 201
@@ -212,13 +212,13 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
212 pthread_mutex_lock(&notes->lock); 212 pthread_mutex_lock(&notes->lock);
213 213
214 list_for_each_entry(pos, &notes->src->source, node) { 214 list_for_each_entry(pos, &notes->src->source, node) {
215 struct disasm_line_rb_node *rbpos = disasm_line__rb(pos); 215 struct browser_disasm_line *bpos = disasm_line__browser(pos);
216 rbpos->percent = disasm_line__calc_percent(pos, sym, evidx); 216 bpos->percent = disasm_line__calc_percent(pos, sym, evidx);
217 if (rbpos->percent < 0.01) { 217 if (bpos->percent < 0.01) {
218 RB_CLEAR_NODE(&rbpos->rb_node); 218 RB_CLEAR_NODE(&bpos->rb_node);
219 continue; 219 continue;
220 } 220 }
221 disasm_rb_tree__insert(&browser->entries, rbpos); 221 disasm_rb_tree__insert(&browser->entries, bpos);
222 } 222 }
223 pthread_mutex_unlock(&notes->lock); 223 pthread_mutex_unlock(&notes->lock);
224 224
@@ -228,37 +228,37 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
228static bool annotate_browser__toggle_source(struct annotate_browser *browser) 228static bool annotate_browser__toggle_source(struct annotate_browser *browser)
229{ 229{
230 struct disasm_line *dl; 230 struct disasm_line *dl;
231 struct disasm_line_rb_node *dlrb; 231 struct browser_disasm_line *bdl;
232 off_t offset = browser->b.index - browser->b.top_idx; 232 off_t offset = browser->b.index - browser->b.top_idx;
233 233
234 browser->b.seek(&browser->b, offset, SEEK_CUR); 234 browser->b.seek(&browser->b, offset, SEEK_CUR);
235 dl = list_entry(browser->b.top, struct disasm_line, node); 235 dl = list_entry(browser->b.top, struct disasm_line, node);
236 dlrb = disasm_line__rb(dl); 236 bdl = disasm_line__browser(dl);
237 237
238 if (browser->hide_src_code) { 238 if (browser->hide_src_code) {
239 if (dlrb->idx_asm < offset) 239 if (bdl->idx_asm < offset)
240 offset = dlrb->idx; 240 offset = bdl->idx;
241 241
242 browser->b.nr_entries = browser->nr_entries; 242 browser->b.nr_entries = browser->nr_entries;
243 browser->hide_src_code = false; 243 browser->hide_src_code = false;
244 browser->b.seek(&browser->b, -offset, SEEK_CUR); 244 browser->b.seek(&browser->b, -offset, SEEK_CUR);
245 browser->b.top_idx = dlrb->idx - offset; 245 browser->b.top_idx = bdl->idx - offset;
246 browser->b.index = dlrb->idx; 246 browser->b.index = bdl->idx;
247 } else { 247 } else {
248 if (dlrb->idx_asm < 0) { 248 if (bdl->idx_asm < 0) {
249 ui_helpline__puts("Only available for assembly lines."); 249 ui_helpline__puts("Only available for assembly lines.");
250 browser->b.seek(&browser->b, -offset, SEEK_CUR); 250 browser->b.seek(&browser->b, -offset, SEEK_CUR);
251 return false; 251 return false;
252 } 252 }
253 253
254 if (dlrb->idx_asm < offset) 254 if (bdl->idx_asm < offset)
255 offset = dlrb->idx_asm; 255 offset = bdl->idx_asm;
256 256
257 browser->b.nr_entries = browser->nr_asm_entries; 257 browser->b.nr_entries = browser->nr_asm_entries;
258 browser->hide_src_code = true; 258 browser->hide_src_code = true;
259 browser->b.seek(&browser->b, -offset, SEEK_CUR); 259 browser->b.seek(&browser->b, -offset, SEEK_CUR);
260 browser->b.top_idx = dlrb->idx_asm - offset; 260 browser->b.top_idx = bdl->idx_asm - offset;
261 browser->b.index = dlrb->idx_asm; 261 browser->b.index = bdl->idx_asm;
262 } 262 }
263 263
264 return true; 264 return true;
@@ -621,7 +621,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
621 if (map->dso->annotate_warned) 621 if (map->dso->annotate_warned)
622 return -1; 622 return -1;
623 623
624 if (symbol__annotate(sym, map, sizeof(struct disasm_line_rb_node)) < 0) { 624 if (symbol__annotate(sym, map, sizeof(struct browser_disasm_line)) < 0) {
625 ui__error("%s", ui_helpline__last_msg); 625 ui__error("%s", ui_helpline__last_msg);
626 return -1; 626 return -1;
627 } 627 }
@@ -632,17 +632,17 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
632 browser.start = map__rip_2objdump(map, sym->start); 632 browser.start = map__rip_2objdump(map, sym->start);
633 633
634 list_for_each_entry(pos, &notes->src->source, node) { 634 list_for_each_entry(pos, &notes->src->source, node) {
635 struct disasm_line_rb_node *rbpos; 635 struct browser_disasm_line *bpos;
636 size_t line_len = strlen(pos->line); 636 size_t line_len = strlen(pos->line);
637 637
638 if (browser.b.width < line_len) 638 if (browser.b.width < line_len)
639 browser.b.width = line_len; 639 browser.b.width = line_len;
640 rbpos = disasm_line__rb(pos); 640 bpos = disasm_line__browser(pos);
641 rbpos->idx = browser.nr_entries++; 641 bpos->idx = browser.nr_entries++;
642 if (pos->offset != -1) 642 if (pos->offset != -1)
643 rbpos->idx_asm = browser.nr_asm_entries++; 643 bpos->idx_asm = browser.nr_asm_entries++;
644 else 644 else
645 rbpos->idx_asm = -1; 645 bpos->idx_asm = -1;
646 } 646 }
647 647
648 browser.b.nr_entries = browser.nr_entries; 648 browser.b.nr_entries = browser.nr_entries;