aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
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)
80 sym->hist[offset]); 80 sym->hist[offset]);
81} 81}
82 82
83static int 83static int hist_entry__add(struct thread *thread, struct map *map,
84hist_entry__add(struct thread *thread, struct map *map, 84 struct symbol *sym, u64 ip, u64 count, char level)
85 struct symbol *sym, u64 ip, char level)
86{ 85{
87 struct rb_node **p = &hist.rb_node; 86 bool hit;
88 struct rb_node *parent = NULL; 87 struct hist_entry *he = __hist_entry__add(thread, map, sym, NULL, ip,
89 struct hist_entry *he; 88 count, level, &hit);
90 struct hist_entry entry = { 89 if (he == NULL)
91 .thread = thread,
92 .map = map,
93 .sym = sym,
94 .ip = ip,
95 .level = level,
96 .count = 1,
97 };
98 int cmp;
99
100 while (*p != NULL) {
101 parent = *p;
102 he = rb_entry(parent, struct hist_entry, rb_node);
103
104 cmp = hist_entry__cmp(&entry, he);
105
106 if (!cmp) {
107 hist_hit(he, ip);
108
109 return 0;
110 }
111
112 if (cmp < 0)
113 p = &(*p)->rb_left;
114 else
115 p = &(*p)->rb_right;
116 }
117
118 he = malloc(sizeof(*he));
119 if (!he)
120 return -ENOMEM; 90 return -ENOMEM;
121 *he = entry; 91 if (hit)
122 rb_link_node(&he->rb_node, parent, p); 92 hist_hit(he, ip);
123 rb_insert_color(&he->rb_node, &hist);
124
125 return 0; 93 return 0;
126} 94}
127 95
@@ -191,7 +159,7 @@ got_map:
191 } 159 }
192 160
193 if (show & show_mask) { 161 if (show & show_mask) {
194 if (hist_entry__add(thread, map, sym, ip, level)) { 162 if (hist_entry__add(thread, map, sym, ip, 1, level)) {
195 fprintf(stderr, 163 fprintf(stderr,
196 "problem incrementing symbol count, skipping event\n"); 164 "problem incrementing symbol count, skipping event\n");
197 return -1; 165 return -1;