aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-02-08 10:27:39 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-02-08 12:03:36 -0500
commitce6f4fab4059cd72638a0cfa596a8ee2c79c1c8e (patch)
tree00416d7a54d9ef265b9358022e804217dcb5d870 /tools/perf/util/ui/browsers/annotate.c
parente3087b80aa0bceda9863f33307460f3ba79f2b15 (diff)
perf annotate: Move locking to struct annotation
Since we'll need it when implementing the live annotate TUI browser. This also simplifies things a bit by having the list head for the source code to be in the dynamicly allocated part of struct annotation, that way we don't have to pass it around, it can be found from the struct symbol that is passed everywhere. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/ui/browsers/annotate.c')
-rw-r--r--tools/perf/util/ui/browsers/annotate.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 8d8a16895af..1aa39658539 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -60,7 +60,6 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
60} 60}
61 61
62static double objdump_line__calc_percent(struct objdump_line *self, 62static double objdump_line__calc_percent(struct objdump_line *self,
63 struct list_head *head,
64 struct symbol *sym, int evidx) 63 struct symbol *sym, int evidx)
65{ 64{
66 double percent = 0.0; 65 double percent = 0.0;
@@ -69,11 +68,12 @@ static double objdump_line__calc_percent(struct objdump_line *self,
69 int len = sym->end - sym->start; 68 int len = sym->end - sym->start;
70 unsigned int hits = 0; 69 unsigned int hits = 0;
71 struct annotation *notes = symbol__annotation(sym); 70 struct annotation *notes = symbol__annotation(sym);
72 struct source_line *src_line = notes->src_line; 71 struct source_line *src_line = notes->src->lines;
73 struct sym_hist *h = annotation__histogram(notes, evidx); 72 struct sym_hist *h = annotation__histogram(notes, evidx);
74 s64 offset = self->offset; 73 s64 offset = self->offset;
75 struct objdump_line *next = objdump__get_next_ip_line(head, self); 74 struct objdump_line *next;
76 75
76 next = objdump__get_next_ip_line(&notes->src->source, self);
77 while (offset < (s64)len && 77 while (offset < (s64)len &&
78 (next == NULL || offset < next->offset)) { 78 (next == NULL || offset < next->offset)) {
79 if (src_line) { 79 if (src_line) {
@@ -192,10 +192,10 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx)
192{ 192{
193 struct objdump_line *pos, *n; 193 struct objdump_line *pos, *n;
194 struct objdump_line_rb_node *rbpos; 194 struct objdump_line_rb_node *rbpos;
195 LIST_HEAD(head); 195 struct annotation *notes = symbol__annotation(sym);
196 struct annotate_browser browser = { 196 struct annotate_browser browser = {
197 .b = { 197 .b = {
198 .entries = &head, 198 .entries = &notes->src->source,
199 .refresh = ui_browser__list_head_refresh, 199 .refresh = ui_browser__list_head_refresh,
200 .seek = ui_browser__list_head_seek, 200 .seek = ui_browser__list_head_seek,
201 .write = annotate_browser__write, 201 .write = annotate_browser__write,
@@ -210,20 +210,20 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx)
210 if (map->dso->annotate_warned) 210 if (map->dso->annotate_warned)
211 return -1; 211 return -1;
212 212
213 if (symbol__annotate(sym, map, &head, sizeof(*rbpos)) < 0) { 213 if (symbol__annotate(sym, map, sizeof(*rbpos)) < 0) {
214 ui__error_window(ui_helpline__last_msg); 214 ui__error_window(ui_helpline__last_msg);
215 return -1; 215 return -1;
216 } 216 }
217 217
218 ui_helpline__push("Press <- or ESC to exit"); 218 ui_helpline__push("Press <- or ESC to exit");
219 219
220 list_for_each_entry(pos, &head, node) { 220 list_for_each_entry(pos, &notes->src->source, node) {
221 size_t line_len = strlen(pos->line); 221 size_t line_len = strlen(pos->line);
222 if (browser.b.width < line_len) 222 if (browser.b.width < line_len)
223 browser.b.width = line_len; 223 browser.b.width = line_len;
224 rbpos = objdump_line__rb(pos); 224 rbpos = objdump_line__rb(pos);
225 rbpos->idx = browser.b.nr_entries++; 225 rbpos->idx = browser.b.nr_entries++;
226 rbpos->percent = objdump_line__calc_percent(pos, &head, sym, evidx); 226 rbpos->percent = objdump_line__calc_percent(pos, sym, evidx);
227 if (rbpos->percent < 0.01) 227 if (rbpos->percent < 0.01)
228 continue; 228 continue;
229 objdump__insert_line(&browser.entries, rbpos); 229 objdump__insert_line(&browser.entries, rbpos);
@@ -238,7 +238,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx)
238 238
239 browser.b.width += 18; /* Percentage */ 239 browser.b.width += 18; /* Percentage */
240 ret = annotate_browser__run(&browser); 240 ret = annotate_browser__run(&browser);
241 list_for_each_entry_safe(pos, n, &head, node) { 241 list_for_each_entry_safe(pos, n, &notes->src->source, node) {
242 list_del(&pos->node); 242 list_del(&pos->node);
243 objdump_line__free(pos); 243 objdump_line__free(pos);
244 } 244 }