aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/browsers/annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/ui/browsers/annotate.c')
-rw-r--r--tools/perf/util/ui/browsers/annotate.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 82b78f99251..daa7138d801 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -1,9 +1,11 @@
1#include "../browser.h" 1#include "../browser.h"
2#include "../helpline.h" 2#include "../helpline.h"
3#include "../libslang.h" 3#include "../libslang.h"
4#include "../../annotate.h"
4#include "../../hist.h" 5#include "../../hist.h"
5#include "../../sort.h" 6#include "../../sort.h"
6#include "../../symbol.h" 7#include "../../symbol.h"
8#include "../../annotate.h"
7 9
8static void ui__error_window(const char *fmt, ...) 10static void ui__error_window(const char *fmt, ...)
9{ 11{
@@ -66,24 +68,26 @@ static double objdump_line__calc_percent(struct objdump_line *self,
66 if (self->offset != -1) { 68 if (self->offset != -1) {
67 int len = sym->end - sym->start; 69 int len = sym->end - sym->start;
68 unsigned int hits = 0; 70 unsigned int hits = 0;
69 struct sym_priv *priv = symbol__priv(sym); 71 struct annotation *notes = symbol__annotation(sym);
70 struct sym_ext *sym_ext = priv->ext; 72 struct source_line *src_line = notes->src_line;
71 struct sym_hist *h = priv->hist; 73 struct sym_hist *h = notes->histogram;
72 s64 offset = self->offset; 74 s64 offset = self->offset;
73 struct objdump_line *next = objdump__get_next_ip_line(head, self); 75 struct objdump_line *next = objdump__get_next_ip_line(head, self);
74 76
75
76 while (offset < (s64)len && 77 while (offset < (s64)len &&
77 (next == NULL || offset < next->offset)) { 78 (next == NULL || offset < next->offset)) {
78 if (sym_ext) { 79 if (src_line) {
79 percent += sym_ext[offset].percent; 80 percent += src_line[offset].percent;
80 } else 81 } else
81 hits += h->ip[offset]; 82 hits += h->addr[offset];
82 83
83 ++offset; 84 ++offset;
84 } 85 }
85 86 /*
86 if (sym_ext == NULL && h->sum) 87 * If the percentage wasn't already calculated in
88 * symbol__get_source_line, do it now:
89 */
90 if (src_line == NULL && h->sum)
87 percent = 100.0 * hits / h->sum; 91 percent = 100.0 * hits / h->sum;
88 } 92 }
89 93
@@ -136,10 +140,10 @@ static void annotate_browser__set_top(struct annotate_browser *self,
136static int annotate_browser__run(struct annotate_browser *self) 140static int annotate_browser__run(struct annotate_browser *self)
137{ 141{
138 struct rb_node *nd; 142 struct rb_node *nd;
139 struct hist_entry *he = self->b.priv; 143 struct symbol *sym = self->b.priv;
140 int key; 144 int key;
141 145
142 if (ui_browser__show(&self->b, he->ms.sym->name, 146 if (ui_browser__show(&self->b, sym->name,
143 "<-, -> or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0) 147 "<-, -> or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0)
144 return -1; 148 return -1;
145 /* 149 /*
@@ -179,7 +183,12 @@ out:
179 return key; 183 return key;
180} 184}
181 185
182int hist_entry__tui_annotate(struct hist_entry *self) 186int hist_entry__tui_annotate(struct hist_entry *he)
187{
188 return symbol__tui_annotate(he->ms.sym, he->ms.map);
189}
190
191int symbol__tui_annotate(struct symbol *sym, struct map *map)
183{ 192{
184 struct objdump_line *pos, *n; 193 struct objdump_line *pos, *n;
185 struct objdump_line_rb_node *rbpos; 194 struct objdump_line_rb_node *rbpos;
@@ -190,18 +199,18 @@ int hist_entry__tui_annotate(struct hist_entry *self)
190 .refresh = ui_browser__list_head_refresh, 199 .refresh = ui_browser__list_head_refresh,
191 .seek = ui_browser__list_head_seek, 200 .seek = ui_browser__list_head_seek,
192 .write = annotate_browser__write, 201 .write = annotate_browser__write,
193 .priv = self, 202 .priv = sym,
194 }, 203 },
195 }; 204 };
196 int ret; 205 int ret;
197 206
198 if (self->ms.sym == NULL) 207 if (sym == NULL)
199 return -1; 208 return -1;
200 209
201 if (self->ms.map->dso->annotate_warned) 210 if (map->dso->annotate_warned)
202 return -1; 211 return -1;
203 212
204 if (hist_entry__annotate(self, &head, sizeof(*rbpos)) < 0) { 213 if (symbol__annotate(sym, map, &head, sizeof(*rbpos)) < 0) {
205 ui__error_window(ui_helpline__last_msg); 214 ui__error_window(ui_helpline__last_msg);
206 return -1; 215 return -1;
207 } 216 }
@@ -214,7 +223,7 @@ int hist_entry__tui_annotate(struct hist_entry *self)
214 browser.b.width = line_len; 223 browser.b.width = line_len;
215 rbpos = objdump_line__rb(pos); 224 rbpos = objdump_line__rb(pos);
216 rbpos->idx = browser.b.nr_entries++; 225 rbpos->idx = browser.b.nr_entries++;
217 rbpos->percent = objdump_line__calc_percent(pos, &head, self->ms.sym); 226 rbpos->percent = objdump_line__calc_percent(pos, &head, sym);
218 if (rbpos->percent < 0.01) 227 if (rbpos->percent < 0.01)
219 continue; 228 continue;
220 objdump__insert_line(&browser.entries, rbpos); 229 objdump__insert_line(&browser.entries, rbpos);