summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-10-03 17:42:45 +0400
committerIngo Molnar <mingo@elte.hu>2009-10-03 18:01:59 +0400
commit9735abf11bec48bfbbb1b54772a02deb2ae0c403 (patch)
tree9bb3c292419443619311b0eedb121149d33e7f59 /tools/perf/builtin-annotate.c
parent439d473b4777de510e1322168ac6f2f377ecd5bc (diff)
downloadlinux-9735abf11bec48bfbbb1b54772a02deb2ae0c403.tar.xz
perf tools: Move hist_entry__add common code to hist.c
Now perf report and annotate do the callgraph/hit processing in their specialized hist_entry__add functions. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Mike Galbraith <efault@gmx.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c50
1 files changed, 9 insertions, 41 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 7d5a3b1bcda9..855094234f2d 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -80,48 +80,16 @@ static void hist_hit(struct hist_entry *he, u64 ip)
sym->hist[offset]);
}
-static int
-hist_entry__add(struct thread *thread, struct map *map,
- struct symbol *sym, u64 ip, char level)
+static int hist_entry__add(struct thread *thread, struct map *map,
+ struct symbol *sym, u64 ip, u64 count, char level)
{
- struct rb_node **p = &hist.rb_node;
- struct rb_node *parent = NULL;
- struct hist_entry *he;
- struct hist_entry entry = {
- .thread = thread,
- .map = map,
- .sym = sym,
- .ip = ip,
- .level = level,
- .count = 1,
- };
- int cmp;
-
- while (*p != NULL) {
- parent = *p;
- he = rb_entry(parent, struct hist_entry, rb_node);
-
- cmp = hist_entry__cmp(&entry, he);
-
- if (!cmp) {
- hist_hit(he, ip);
-
- return 0;
- }
-
- if (cmp < 0)
- p = &(*p)->rb_left;
- else
- p = &(*p)->rb_right;
- }
-
- he = malloc(sizeof(*he));
- if (!he)
+ bool hit;
+ struct hist_entry *he = __hist_entry__add(thread, map, sym, NULL, ip,
+ count, level, &hit);
+ if (he == NULL)
return -ENOMEM;
- *he = entry;
- rb_link_node(&he->rb_node, parent, p);
- rb_insert_color(&he->rb_node, &hist);
-
+ if (hit)
+ hist_hit(he, ip);
return 0;
}
@@ -191,7 +159,7 @@ got_map:
}
if (show & show_mask) {
- if (hist_entry__add(thread, map, sym, ip, level)) {
+ if (hist_entry__add(thread, map, sym, ip, 1, level)) {
fprintf(stderr,
"problem incrementing symbol count, skipping event\n");
return -1;