diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-03 14:32:45 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-07 15:11:33 -0400 |
commit | b0ffb2c48a924fdacb65a2320554ddc779a65eb2 (patch) | |
tree | 0be24b2017f2995a573a27726bfa9ddb181c9141 /tools | |
parent | 6052170249d6696bc297d61e83b78fcfe64532d8 (diff) |
perf ui annotate browser: Add list based search for addr offset
From the hit sorted rb_tree, so that we can use it in the upcoming jump
instruction support.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-44a7kl2atf9jxlg9npmotzdg@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/ui/browsers/annotate.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c index dbf8d3f6b567..c52543c69ae0 100644 --- a/tools/perf/util/ui/browsers/annotate.c +++ b/tools/perf/util/ui/browsers/annotate.c | |||
@@ -157,17 +157,13 @@ static void objdump__insert_line(struct rb_root *self, | |||
157 | } | 157 | } |
158 | 158 | ||
159 | static void annotate_browser__set_top(struct annotate_browser *self, | 159 | static void annotate_browser__set_top(struct annotate_browser *self, |
160 | struct rb_node *nd) | 160 | struct objdump_line *pos, u32 idx) |
161 | { | 161 | { |
162 | struct objdump_line_rb_node *rbpos; | ||
163 | struct objdump_line *pos; | ||
164 | unsigned back; | 162 | unsigned back; |
165 | 163 | ||
166 | ui_browser__refresh_dimensions(&self->b); | 164 | ui_browser__refresh_dimensions(&self->b); |
167 | back = self->b.height / 2; | 165 | back = self->b.height / 2; |
168 | rbpos = rb_entry(nd, struct objdump_line_rb_node, rb_node); | 166 | self->b.top_idx = self->b.index = idx; |
169 | pos = ((struct objdump_line *)rbpos) - 1; | ||
170 | self->b.top_idx = self->b.index = rbpos->idx; | ||
171 | 167 | ||
172 | while (self->b.top_idx != 0 && back != 0) { | 168 | while (self->b.top_idx != 0 && back != 0) { |
173 | pos = list_entry(pos->node.prev, struct objdump_line, node); | 169 | pos = list_entry(pos->node.prev, struct objdump_line, node); |
@@ -177,7 +173,18 @@ static void annotate_browser__set_top(struct annotate_browser *self, | |||
177 | } | 173 | } |
178 | 174 | ||
179 | self->b.top = pos; | 175 | self->b.top = pos; |
180 | self->curr_hot = nd; | 176 | } |
177 | |||
178 | static void annotate_browser__set_rb_top(struct annotate_browser *browser, | ||
179 | struct rb_node *nd) | ||
180 | { | ||
181 | struct objdump_line_rb_node *rbpos; | ||
182 | struct objdump_line *pos; | ||
183 | |||
184 | rbpos = rb_entry(nd, struct objdump_line_rb_node, rb_node); | ||
185 | pos = ((struct objdump_line *)rbpos) - 1; | ||
186 | annotate_browser__set_top(browser, pos, rbpos->idx); | ||
187 | browser->curr_hot = nd; | ||
181 | } | 188 | } |
182 | 189 | ||
183 | static void annotate_browser__calc_percent(struct annotate_browser *browser, | 190 | static void annotate_browser__calc_percent(struct annotate_browser *browser, |
@@ -308,7 +315,7 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, | |||
308 | annotate_browser__calc_percent(self, evidx); | 315 | annotate_browser__calc_percent(self, evidx); |
309 | 316 | ||
310 | if (self->curr_hot) | 317 | if (self->curr_hot) |
311 | annotate_browser__set_top(self, self->curr_hot); | 318 | annotate_browser__set_rb_top(self, self->curr_hot); |
312 | 319 | ||
313 | nd = self->curr_hot; | 320 | nd = self->curr_hot; |
314 | 321 | ||
@@ -382,7 +389,7 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, | |||
382 | } | 389 | } |
383 | 390 | ||
384 | if (nd != NULL) | 391 | if (nd != NULL) |
385 | annotate_browser__set_top(self, nd); | 392 | annotate_browser__set_rb_top(self, nd); |
386 | } | 393 | } |
387 | out: | 394 | out: |
388 | ui_browser__hide(&self->b); | 395 | ui_browser__hide(&self->b); |