summaryrefslogtreecommitdiffstats
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 @@
#include "../browser.h"
#include "../helpline.h"
#include "../libslang.h"
+#include "../../annotate.h"
#include "../../hist.h"
#include "../../sort.h"
#include "../../symbol.h"
+#include "../../annotate.h"
static void ui__error_window(const char *fmt, ...)
{
@@ -66,24 +68,26 @@ static double objdump_line__calc_percent(struct objdump_line *self,
if (self->offset != -1) {
int len = sym->end - sym->start;
unsigned int hits = 0;
- struct sym_priv *priv = symbol__priv(sym);
- struct sym_ext *sym_ext = priv->ext;
- struct sym_hist *h = priv->hist;
+ struct annotation *notes = symbol__annotation(sym);
+ struct source_line *src_line = notes->src_line;
+ struct sym_hist *h = notes->histogram;
s64 offset = self->offset;
struct objdump_line *next = objdump__get_next_ip_line(head, self);
-
while (offset < (s64)len &&
(next == NULL || offset < next->offset)) {
- if (sym_ext) {
- percent += sym_ext[offset].percent;
+ if (src_line) {
+ percent += src_line[offset].percent;
} else
- hits += h->ip[offset];
+ hits += h->addr[offset];
++offset;
}
-
- if (sym_ext == NULL && h->sum)
+ /*
+ * If the percentage wasn't already calculated in
+ * symbol__get_source_line, do it now:
+ */
+ if (src_line == NULL && h->sum)
percent = 100.0 * hits / h->sum;
}
@@ -136,10 +140,10 @@ static void annotate_browser__set_top(struct annotate_browser *self,
static int annotate_browser__run(struct annotate_browser *self)
{
struct rb_node *nd;
- struct hist_entry *he = self->b.priv;
+ struct symbol *sym = self->b.priv;
int key;
- if (ui_browser__show(&self->b, he->ms.sym->name,
+ if (ui_browser__show(&self->b, sym->name,
"<-, -> or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0)
return -1;
/*
@@ -179,7 +183,12 @@ out:
return key;
}
-int hist_entry__tui_annotate(struct hist_entry *self)
+int hist_entry__tui_annotate(struct hist_entry *he)
+{
+ return symbol__tui_annotate(he->ms.sym, he->ms.map);
+}
+
+int symbol__tui_annotate(struct symbol *sym, struct map *map)
{
struct objdump_line *pos, *n;
struct objdump_line_rb_node *rbpos;
@@ -190,18 +199,18 @@ int hist_entry__tui_annotate(struct hist_entry *self)
.refresh = ui_browser__list_head_refresh,
.seek = ui_browser__list_head_seek,
.write = annotate_browser__write,
- .priv = self,
+ .priv = sym,
},
};
int ret;
- if (self->ms.sym == NULL)
+ if (sym == NULL)
return -1;
- if (self->ms.map->dso->annotate_warned)
+ if (map->dso->annotate_warned)
return -1;
- if (hist_entry__annotate(self, &head, sizeof(*rbpos)) < 0) {
+ if (symbol__annotate(sym, map, &head, sizeof(*rbpos)) < 0) {
ui__error_window(ui_helpline__last_msg);
return -1;
}
@@ -214,7 +223,7 @@ int hist_entry__tui_annotate(struct hist_entry *self)
browser.b.width = line_len;
rbpos = objdump_line__rb(pos);
rbpos->idx = browser.b.nr_entries++;
- rbpos->percent = objdump_line__calc_percent(pos, &head, self->ms.sym);
+ rbpos->percent = objdump_line__calc_percent(pos, &head, sym);
if (rbpos->percent < 0.01)
continue;
objdump__insert_line(&browser.entries, rbpos);