diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-15 14:24:39 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-16 11:09:59 -0400 |
commit | 29ed6e76b4ca81103f31c8316f9e4cfcf134572f (patch) | |
tree | 899c3a3262d5f84ecdb7e45d2f21f33c8dea827e /tools | |
parent | a385ec4f11bdcf81af094c03e2444ee9b7fad2e5 (diff) |
perf annotate: Rename objdump_line to disasm_line
We want to move away from using 'objdump -dS' as the only disassembler
supported.
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-lsn9pjuxxm5ezsubyhkmprw7@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 179 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 72 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 11 |
3 files changed, 128 insertions, 134 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 4db5186472b5..bc540b1576c3 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -15,7 +15,7 @@ struct annotate_browser { | |||
15 | struct ui_browser b; | 15 | struct ui_browser b; |
16 | struct rb_root entries; | 16 | struct rb_root entries; |
17 | struct rb_node *curr_hot; | 17 | struct rb_node *curr_hot; |
18 | struct objdump_line *selection; | 18 | struct disasm_line *selection; |
19 | u64 start; | 19 | u64 start; |
20 | int nr_asm_entries; | 20 | int nr_asm_entries; |
21 | int nr_entries; | 21 | int nr_entries; |
@@ -25,26 +25,25 @@ struct annotate_browser { | |||
25 | char search_bf[128]; | 25 | char search_bf[128]; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | struct objdump_line_rb_node { | 28 | struct disasm_line_rb_node { |
29 | struct rb_node rb_node; | 29 | struct rb_node rb_node; |
30 | double percent; | 30 | double percent; |
31 | u32 idx; | 31 | u32 idx; |
32 | int idx_asm; | 32 | int idx_asm; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | static inline | 35 | static inline struct disasm_line_rb_node *disasm_line__rb(struct disasm_line *dl) |
36 | struct objdump_line_rb_node *objdump_line__rb(struct objdump_line *self) | ||
37 | { | 36 | { |
38 | return (struct objdump_line_rb_node *)(self + 1); | 37 | return (struct disasm_line_rb_node *)(dl + 1); |
39 | } | 38 | } |
40 | 39 | ||
41 | static bool objdump_line__filter(struct ui_browser *browser, void *entry) | 40 | static bool disasm_line__filter(struct ui_browser *browser, void *entry) |
42 | { | 41 | { |
43 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); | 42 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); |
44 | 43 | ||
45 | if (ab->hide_src_code) { | 44 | if (ab->hide_src_code) { |
46 | struct objdump_line *ol = list_entry(entry, struct objdump_line, node); | 45 | struct disasm_line *dl = list_entry(entry, struct disasm_line, node); |
47 | return ol->offset == -1; | 46 | return dl->offset == -1; |
48 | } | 47 | } |
49 | 48 | ||
50 | return false; | 49 | return false; |
@@ -53,17 +52,17 @@ static bool objdump_line__filter(struct ui_browser *browser, void *entry) | |||
53 | static void annotate_browser__write(struct ui_browser *self, void *entry, int row) | 52 | static void annotate_browser__write(struct ui_browser *self, void *entry, int row) |
54 | { | 53 | { |
55 | struct annotate_browser *ab = container_of(self, struct annotate_browser, b); | 54 | struct annotate_browser *ab = container_of(self, struct annotate_browser, b); |
56 | struct objdump_line *ol = list_entry(entry, struct objdump_line, node); | 55 | struct disasm_line *dl = list_entry(entry, struct disasm_line, node); |
57 | bool current_entry = ui_browser__is_current_entry(self, row); | 56 | bool current_entry = ui_browser__is_current_entry(self, row); |
58 | bool change_color = (!ab->hide_src_code && | 57 | bool change_color = (!ab->hide_src_code && |
59 | (!current_entry || (self->use_navkeypressed && | 58 | (!current_entry || (self->use_navkeypressed && |
60 | !self->navkeypressed))); | 59 | !self->navkeypressed))); |
61 | int width = self->width; | 60 | int width = self->width; |
62 | 61 | ||
63 | if (ol->offset != -1) { | 62 | if (dl->offset != -1) { |
64 | struct objdump_line_rb_node *olrb = objdump_line__rb(ol); | 63 | struct disasm_line_rb_node *dlrb = disasm_line__rb(dl); |
65 | ui_browser__set_percent_color(self, olrb->percent, current_entry); | 64 | ui_browser__set_percent_color(self, dlrb->percent, current_entry); |
66 | slsmg_printf(" %7.2f ", olrb->percent); | 65 | slsmg_printf(" %7.2f ", dlrb->percent); |
67 | } else { | 66 | } else { |
68 | ui_browser__set_percent_color(self, 0, current_entry); | 67 | ui_browser__set_percent_color(self, 0, current_entry); |
69 | slsmg_write_nstring(" ", 9); | 68 | slsmg_write_nstring(" ", 9); |
@@ -76,16 +75,16 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro | |||
76 | if (!self->navkeypressed) | 75 | if (!self->navkeypressed) |
77 | width += 1; | 76 | width += 1; |
78 | 77 | ||
79 | if (ol->offset != -1 && change_color) | 78 | if (dl->offset != -1 && change_color) |
80 | ui_browser__set_color(self, HE_COLORSET_CODE); | 79 | ui_browser__set_color(self, HE_COLORSET_CODE); |
81 | 80 | ||
82 | if (!*ol->line) | 81 | if (!*dl->line) |
83 | slsmg_write_nstring(" ", width - 18); | 82 | slsmg_write_nstring(" ", width - 18); |
84 | else if (ol->offset == -1) | 83 | else if (dl->offset == -1) |
85 | slsmg_write_nstring(ol->line, width - 18); | 84 | slsmg_write_nstring(dl->line, width - 18); |
86 | else { | 85 | else { |
87 | char bf[64]; | 86 | char bf[64]; |
88 | u64 addr = ol->offset; | 87 | u64 addr = dl->offset; |
89 | int printed, color = -1; | 88 | int printed, color = -1; |
90 | 89 | ||
91 | if (!ab->use_offset) | 90 | if (!ab->use_offset) |
@@ -97,28 +96,27 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro | |||
97 | slsmg_write_nstring(bf, printed); | 96 | slsmg_write_nstring(bf, printed); |
98 | if (change_color) | 97 | if (change_color) |
99 | ui_browser__set_color(self, color); | 98 | ui_browser__set_color(self, color); |
100 | slsmg_write_nstring(ol->line, width - 18 - printed); | 99 | slsmg_write_nstring(dl->line, width - 18 - printed); |
101 | } | 100 | } |
102 | 101 | ||
103 | if (current_entry) | 102 | if (current_entry) |
104 | ab->selection = ol; | 103 | ab->selection = dl; |
105 | } | 104 | } |
106 | 105 | ||
107 | static double objdump_line__calc_percent(struct objdump_line *self, | 106 | static double disasm_line__calc_percent(struct disasm_line *dl, struct symbol *sym, int evidx) |
108 | struct symbol *sym, int evidx) | ||
109 | { | 107 | { |
110 | double percent = 0.0; | 108 | double percent = 0.0; |
111 | 109 | ||
112 | if (self->offset != -1) { | 110 | if (dl->offset != -1) { |
113 | int len = sym->end - sym->start; | 111 | int len = sym->end - sym->start; |
114 | unsigned int hits = 0; | 112 | unsigned int hits = 0; |
115 | struct annotation *notes = symbol__annotation(sym); | 113 | struct annotation *notes = symbol__annotation(sym); |
116 | struct source_line *src_line = notes->src->lines; | 114 | struct source_line *src_line = notes->src->lines; |
117 | struct sym_hist *h = annotation__histogram(notes, evidx); | 115 | struct sym_hist *h = annotation__histogram(notes, evidx); |
118 | s64 offset = self->offset; | 116 | s64 offset = dl->offset; |
119 | struct objdump_line *next; | 117 | struct disasm_line *next; |
120 | 118 | ||
121 | next = objdump__get_next_ip_line(¬es->src->source, self); | 119 | next = disasm__get_next_ip_line(¬es->src->source, dl); |
122 | while (offset < (s64)len && | 120 | while (offset < (s64)len && |
123 | (next == NULL || offset < next->offset)) { | 121 | (next == NULL || offset < next->offset)) { |
124 | if (src_line) { | 122 | if (src_line) { |
@@ -139,27 +137,26 @@ static double objdump_line__calc_percent(struct objdump_line *self, | |||
139 | return percent; | 137 | return percent; |
140 | } | 138 | } |
141 | 139 | ||
142 | static void objdump__insert_line(struct rb_root *self, | 140 | static void disasm_rb_tree__insert(struct rb_root *root, struct disasm_line_rb_node *dlrb) |
143 | struct objdump_line_rb_node *line) | ||
144 | { | 141 | { |
145 | struct rb_node **p = &self->rb_node; | 142 | struct rb_node **p = &root->rb_node; |
146 | struct rb_node *parent = NULL; | 143 | struct rb_node *parent = NULL; |
147 | struct objdump_line_rb_node *l; | 144 | struct disasm_line_rb_node *l; |
148 | 145 | ||
149 | while (*p != NULL) { | 146 | while (*p != NULL) { |
150 | parent = *p; | 147 | parent = *p; |
151 | l = rb_entry(parent, struct objdump_line_rb_node, rb_node); | 148 | l = rb_entry(parent, struct disasm_line_rb_node, rb_node); |
152 | if (line->percent < l->percent) | 149 | if (dlrb->percent < l->percent) |
153 | p = &(*p)->rb_left; | 150 | p = &(*p)->rb_left; |
154 | else | 151 | else |
155 | p = &(*p)->rb_right; | 152 | p = &(*p)->rb_right; |
156 | } | 153 | } |
157 | rb_link_node(&line->rb_node, parent, p); | 154 | rb_link_node(&dlrb->rb_node, parent, p); |
158 | rb_insert_color(&line->rb_node, self); | 155 | rb_insert_color(&dlrb->rb_node, root); |
159 | } | 156 | } |
160 | 157 | ||
161 | static void annotate_browser__set_top(struct annotate_browser *self, | 158 | static void annotate_browser__set_top(struct annotate_browser *self, |
162 | struct objdump_line *pos, u32 idx) | 159 | struct disasm_line *pos, u32 idx) |
163 | { | 160 | { |
164 | unsigned back; | 161 | unsigned back; |
165 | 162 | ||
@@ -168,9 +165,9 @@ static void annotate_browser__set_top(struct annotate_browser *self, | |||
168 | self->b.top_idx = self->b.index = idx; | 165 | self->b.top_idx = self->b.index = idx; |
169 | 166 | ||
170 | while (self->b.top_idx != 0 && back != 0) { | 167 | while (self->b.top_idx != 0 && back != 0) { |
171 | pos = list_entry(pos->node.prev, struct objdump_line, node); | 168 | pos = list_entry(pos->node.prev, struct disasm_line, node); |
172 | 169 | ||
173 | if (objdump_line__filter(&self->b, &pos->node)) | 170 | if (disasm_line__filter(&self->b, &pos->node)) |
174 | continue; | 171 | continue; |
175 | 172 | ||
176 | --self->b.top_idx; | 173 | --self->b.top_idx; |
@@ -184,11 +181,11 @@ static void annotate_browser__set_top(struct annotate_browser *self, | |||
184 | static void annotate_browser__set_rb_top(struct annotate_browser *browser, | 181 | static void annotate_browser__set_rb_top(struct annotate_browser *browser, |
185 | struct rb_node *nd) | 182 | struct rb_node *nd) |
186 | { | 183 | { |
187 | struct objdump_line_rb_node *rbpos; | 184 | struct disasm_line_rb_node *rbpos; |
188 | struct objdump_line *pos; | 185 | struct disasm_line *pos; |
189 | 186 | ||
190 | rbpos = rb_entry(nd, struct objdump_line_rb_node, rb_node); | 187 | rbpos = rb_entry(nd, struct disasm_line_rb_node, rb_node); |
191 | pos = ((struct objdump_line *)rbpos) - 1; | 188 | pos = ((struct disasm_line *)rbpos) - 1; |
192 | annotate_browser__set_top(browser, pos, rbpos->idx); | 189 | annotate_browser__set_top(browser, pos, rbpos->idx); |
193 | browser->curr_hot = nd; | 190 | browser->curr_hot = nd; |
194 | } | 191 | } |
@@ -199,20 +196,20 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
199 | struct map_symbol *ms = browser->b.priv; | 196 | struct map_symbol *ms = browser->b.priv; |
200 | struct symbol *sym = ms->sym; | 197 | struct symbol *sym = ms->sym; |
201 | struct annotation *notes = symbol__annotation(sym); | 198 | struct annotation *notes = symbol__annotation(sym); |
202 | struct objdump_line *pos; | 199 | struct disasm_line *pos; |
203 | 200 | ||
204 | browser->entries = RB_ROOT; | 201 | browser->entries = RB_ROOT; |
205 | 202 | ||
206 | pthread_mutex_lock(¬es->lock); | 203 | pthread_mutex_lock(¬es->lock); |
207 | 204 | ||
208 | list_for_each_entry(pos, ¬es->src->source, node) { | 205 | list_for_each_entry(pos, ¬es->src->source, node) { |
209 | struct objdump_line_rb_node *rbpos = objdump_line__rb(pos); | 206 | struct disasm_line_rb_node *rbpos = disasm_line__rb(pos); |
210 | rbpos->percent = objdump_line__calc_percent(pos, sym, evidx); | 207 | rbpos->percent = disasm_line__calc_percent(pos, sym, evidx); |
211 | if (rbpos->percent < 0.01) { | 208 | if (rbpos->percent < 0.01) { |
212 | RB_CLEAR_NODE(&rbpos->rb_node); | 209 | RB_CLEAR_NODE(&rbpos->rb_node); |
213 | continue; | 210 | continue; |
214 | } | 211 | } |
215 | objdump__insert_line(&browser->entries, rbpos); | 212 | disasm_rb_tree__insert(&browser->entries, rbpos); |
216 | } | 213 | } |
217 | pthread_mutex_unlock(¬es->lock); | 214 | pthread_mutex_unlock(¬es->lock); |
218 | 215 | ||
@@ -221,38 +218,38 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
221 | 218 | ||
222 | static bool annotate_browser__toggle_source(struct annotate_browser *browser) | 219 | static bool annotate_browser__toggle_source(struct annotate_browser *browser) |
223 | { | 220 | { |
224 | struct objdump_line *ol; | 221 | struct disasm_line *dl; |
225 | struct objdump_line_rb_node *olrb; | 222 | struct disasm_line_rb_node *dlrb; |
226 | off_t offset = browser->b.index - browser->b.top_idx; | 223 | off_t offset = browser->b.index - browser->b.top_idx; |
227 | 224 | ||
228 | browser->b.seek(&browser->b, offset, SEEK_CUR); | 225 | browser->b.seek(&browser->b, offset, SEEK_CUR); |
229 | ol = list_entry(browser->b.top, struct objdump_line, node); | 226 | dl = list_entry(browser->b.top, struct disasm_line, node); |
230 | olrb = objdump_line__rb(ol); | 227 | dlrb = disasm_line__rb(dl); |
231 | 228 | ||
232 | if (browser->hide_src_code) { | 229 | if (browser->hide_src_code) { |
233 | if (olrb->idx_asm < offset) | 230 | if (dlrb->idx_asm < offset) |
234 | offset = olrb->idx; | 231 | offset = dlrb->idx; |
235 | 232 | ||
236 | browser->b.nr_entries = browser->nr_entries; | 233 | browser->b.nr_entries = browser->nr_entries; |
237 | browser->hide_src_code = false; | 234 | browser->hide_src_code = false; |
238 | browser->b.seek(&browser->b, -offset, SEEK_CUR); | 235 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
239 | browser->b.top_idx = olrb->idx - offset; | 236 | browser->b.top_idx = dlrb->idx - offset; |
240 | browser->b.index = olrb->idx; | 237 | browser->b.index = dlrb->idx; |
241 | } else { | 238 | } else { |
242 | if (olrb->idx_asm < 0) { | 239 | if (dlrb->idx_asm < 0) { |
243 | ui_helpline__puts("Only available for assembly lines."); | 240 | ui_helpline__puts("Only available for assembly lines."); |
244 | browser->b.seek(&browser->b, -offset, SEEK_CUR); | 241 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
245 | return false; | 242 | return false; |
246 | } | 243 | } |
247 | 244 | ||
248 | if (olrb->idx_asm < offset) | 245 | if (dlrb->idx_asm < offset) |
249 | offset = olrb->idx_asm; | 246 | offset = dlrb->idx_asm; |
250 | 247 | ||
251 | browser->b.nr_entries = browser->nr_asm_entries; | 248 | browser->b.nr_entries = browser->nr_asm_entries; |
252 | browser->hide_src_code = true; | 249 | browser->hide_src_code = true; |
253 | browser->b.seek(&browser->b, -offset, SEEK_CUR); | 250 | browser->b.seek(&browser->b, -offset, SEEK_CUR); |
254 | browser->b.top_idx = olrb->idx_asm - offset; | 251 | browser->b.top_idx = dlrb->idx_asm - offset; |
255 | browser->b.index = olrb->idx_asm; | 252 | browser->b.index = dlrb->idx_asm; |
256 | } | 253 | } |
257 | 254 | ||
258 | return true; | 255 | return true; |
@@ -302,20 +299,20 @@ static bool annotate_browser__callq(struct annotate_browser *browser, | |||
302 | return true; | 299 | return true; |
303 | } | 300 | } |
304 | 301 | ||
305 | static struct objdump_line * | 302 | static |
306 | annotate_browser__find_offset(struct annotate_browser *browser, | 303 | struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser, |
307 | s64 offset, s64 *idx) | 304 | s64 offset, s64 *idx) |
308 | { | 305 | { |
309 | struct map_symbol *ms = browser->b.priv; | 306 | struct map_symbol *ms = browser->b.priv; |
310 | struct symbol *sym = ms->sym; | 307 | struct symbol *sym = ms->sym; |
311 | struct annotation *notes = symbol__annotation(sym); | 308 | struct annotation *notes = symbol__annotation(sym); |
312 | struct objdump_line *pos; | 309 | struct disasm_line *pos; |
313 | 310 | ||
314 | *idx = 0; | 311 | *idx = 0; |
315 | list_for_each_entry(pos, ¬es->src->source, node) { | 312 | list_for_each_entry(pos, ¬es->src->source, node) { |
316 | if (pos->offset == offset) | 313 | if (pos->offset == offset) |
317 | return pos; | 314 | return pos; |
318 | if (!objdump_line__filter(&browser->b, &pos->node)) | 315 | if (!disasm_line__filter(&browser->b, &pos->node)) |
319 | ++*idx; | 316 | ++*idx; |
320 | } | 317 | } |
321 | 318 | ||
@@ -325,7 +322,7 @@ static struct objdump_line * | |||
325 | static bool annotate_browser__jump(struct annotate_browser *browser) | 322 | static bool annotate_browser__jump(struct annotate_browser *browser) |
326 | { | 323 | { |
327 | const char *jumps[] = { "je ", "jne ", "ja ", "jmpq ", "js ", "jmp ", NULL }; | 324 | const char *jumps[] = { "je ", "jne ", "ja ", "jmpq ", "js ", "jmp ", NULL }; |
328 | struct objdump_line *line; | 325 | struct disasm_line *dl; |
329 | s64 idx, offset; | 326 | s64 idx, offset; |
330 | char *s = NULL; | 327 | char *s = NULL; |
331 | int i = 0; | 328 | int i = 0; |
@@ -346,29 +343,29 @@ static bool annotate_browser__jump(struct annotate_browser *browser) | |||
346 | } | 343 | } |
347 | 344 | ||
348 | offset = strtoll(s, NULL, 16); | 345 | offset = strtoll(s, NULL, 16); |
349 | line = annotate_browser__find_offset(browser, offset, &idx); | 346 | dl = annotate_browser__find_offset(browser, offset, &idx); |
350 | if (line == NULL) { | 347 | if (dl == NULL) { |
351 | ui_helpline__puts("Invallid jump offset"); | 348 | ui_helpline__puts("Invallid jump offset"); |
352 | return true; | 349 | return true; |
353 | } | 350 | } |
354 | 351 | ||
355 | annotate_browser__set_top(browser, line, idx); | 352 | annotate_browser__set_top(browser, dl, idx); |
356 | 353 | ||
357 | return true; | 354 | return true; |
358 | } | 355 | } |
359 | 356 | ||
360 | static struct objdump_line * | 357 | static |
361 | annotate_browser__find_string(struct annotate_browser *browser, | 358 | struct disasm_line *annotate_browser__find_string(struct annotate_browser *browser, |
362 | char *s, s64 *idx) | 359 | char *s, s64 *idx) |
363 | { | 360 | { |
364 | struct map_symbol *ms = browser->b.priv; | 361 | struct map_symbol *ms = browser->b.priv; |
365 | struct symbol *sym = ms->sym; | 362 | struct symbol *sym = ms->sym; |
366 | struct annotation *notes = symbol__annotation(sym); | 363 | struct annotation *notes = symbol__annotation(sym); |
367 | struct objdump_line *pos = browser->selection; | 364 | struct disasm_line *pos = browser->selection; |
368 | 365 | ||
369 | *idx = browser->b.index; | 366 | *idx = browser->b.index; |
370 | list_for_each_entry_continue(pos, ¬es->src->source, node) { | 367 | list_for_each_entry_continue(pos, ¬es->src->source, node) { |
371 | if (objdump_line__filter(&browser->b, &pos->node)) | 368 | if (disasm_line__filter(&browser->b, &pos->node)) |
372 | continue; | 369 | continue; |
373 | 370 | ||
374 | ++*idx; | 371 | ++*idx; |
@@ -382,32 +379,32 @@ static struct objdump_line * | |||
382 | 379 | ||
383 | static bool __annotate_browser__search(struct annotate_browser *browser) | 380 | static bool __annotate_browser__search(struct annotate_browser *browser) |
384 | { | 381 | { |
385 | struct objdump_line *line; | 382 | struct disasm_line *dl; |
386 | s64 idx; | 383 | s64 idx; |
387 | 384 | ||
388 | line = annotate_browser__find_string(browser, browser->search_bf, &idx); | 385 | dl = annotate_browser__find_string(browser, browser->search_bf, &idx); |
389 | if (line == NULL) { | 386 | if (dl == NULL) { |
390 | ui_helpline__puts("String not found!"); | 387 | ui_helpline__puts("String not found!"); |
391 | return false; | 388 | return false; |
392 | } | 389 | } |
393 | 390 | ||
394 | annotate_browser__set_top(browser, line, idx); | 391 | annotate_browser__set_top(browser, dl, idx); |
395 | browser->searching_backwards = false; | 392 | browser->searching_backwards = false; |
396 | return true; | 393 | return true; |
397 | } | 394 | } |
398 | 395 | ||
399 | static struct objdump_line * | 396 | static |
400 | annotate_browser__find_string_reverse(struct annotate_browser *browser, | 397 | struct disasm_line *annotate_browser__find_string_reverse(struct annotate_browser *browser, |
401 | char *s, s64 *idx) | 398 | char *s, s64 *idx) |
402 | { | 399 | { |
403 | struct map_symbol *ms = browser->b.priv; | 400 | struct map_symbol *ms = browser->b.priv; |
404 | struct symbol *sym = ms->sym; | 401 | struct symbol *sym = ms->sym; |
405 | struct annotation *notes = symbol__annotation(sym); | 402 | struct annotation *notes = symbol__annotation(sym); |
406 | struct objdump_line *pos = browser->selection; | 403 | struct disasm_line *pos = browser->selection; |
407 | 404 | ||
408 | *idx = browser->b.index; | 405 | *idx = browser->b.index; |
409 | list_for_each_entry_continue_reverse(pos, ¬es->src->source, node) { | 406 | list_for_each_entry_continue_reverse(pos, ¬es->src->source, node) { |
410 | if (objdump_line__filter(&browser->b, &pos->node)) | 407 | if (disasm_line__filter(&browser->b, &pos->node)) |
411 | continue; | 408 | continue; |
412 | 409 | ||
413 | --*idx; | 410 | --*idx; |
@@ -421,16 +418,16 @@ static struct objdump_line * | |||
421 | 418 | ||
422 | static bool __annotate_browser__search_reverse(struct annotate_browser *browser) | 419 | static bool __annotate_browser__search_reverse(struct annotate_browser *browser) |
423 | { | 420 | { |
424 | struct objdump_line *line; | 421 | struct disasm_line *dl; |
425 | s64 idx; | 422 | s64 idx; |
426 | 423 | ||
427 | line = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx); | 424 | dl = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx); |
428 | if (line == NULL) { | 425 | if (dl == NULL) { |
429 | ui_helpline__puts("String not found!"); | 426 | ui_helpline__puts("String not found!"); |
430 | return false; | 427 | return false; |
431 | } | 428 | } |
432 | 429 | ||
433 | annotate_browser__set_top(browser, line, idx); | 430 | annotate_browser__set_top(browser, dl, idx); |
434 | browser->searching_backwards = true; | 431 | browser->searching_backwards = true; |
435 | return true; | 432 | return true; |
436 | } | 433 | } |
@@ -613,7 +610,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
613 | void(*timer)(void *arg), void *arg, | 610 | void(*timer)(void *arg), void *arg, |
614 | int delay_secs) | 611 | int delay_secs) |
615 | { | 612 | { |
616 | struct objdump_line *pos, *n; | 613 | struct disasm_line *pos, *n; |
617 | struct annotation *notes; | 614 | struct annotation *notes; |
618 | struct map_symbol ms = { | 615 | struct map_symbol ms = { |
619 | .map = map, | 616 | .map = map, |
@@ -624,7 +621,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
624 | .refresh = ui_browser__list_head_refresh, | 621 | .refresh = ui_browser__list_head_refresh, |
625 | .seek = ui_browser__list_head_seek, | 622 | .seek = ui_browser__list_head_seek, |
626 | .write = annotate_browser__write, | 623 | .write = annotate_browser__write, |
627 | .filter = objdump_line__filter, | 624 | .filter = disasm_line__filter, |
628 | .priv = &ms, | 625 | .priv = &ms, |
629 | .use_navkeypressed = true, | 626 | .use_navkeypressed = true, |
630 | }, | 627 | }, |
@@ -637,7 +634,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
637 | if (map->dso->annotate_warned) | 634 | if (map->dso->annotate_warned) |
638 | return -1; | 635 | return -1; |
639 | 636 | ||
640 | if (symbol__annotate(sym, map, sizeof(struct objdump_line_rb_node)) < 0) { | 637 | if (symbol__annotate(sym, map, sizeof(struct disasm_line_rb_node)) < 0) { |
641 | ui__error("%s", ui_helpline__last_msg); | 638 | ui__error("%s", ui_helpline__last_msg); |
642 | return -1; | 639 | return -1; |
643 | } | 640 | } |
@@ -648,12 +645,12 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
648 | browser.start = map__rip_2objdump(map, sym->start); | 645 | browser.start = map__rip_2objdump(map, sym->start); |
649 | 646 | ||
650 | list_for_each_entry(pos, ¬es->src->source, node) { | 647 | list_for_each_entry(pos, ¬es->src->source, node) { |
651 | struct objdump_line_rb_node *rbpos; | 648 | struct disasm_line_rb_node *rbpos; |
652 | size_t line_len = strlen(pos->line); | 649 | size_t line_len = strlen(pos->line); |
653 | 650 | ||
654 | if (browser.b.width < line_len) | 651 | if (browser.b.width < line_len) |
655 | browser.b.width = line_len; | 652 | browser.b.width = line_len; |
656 | rbpos = objdump_line__rb(pos); | 653 | rbpos = disasm_line__rb(pos); |
657 | rbpos->idx = browser.nr_entries++; | 654 | rbpos->idx = browser.nr_entries++; |
658 | if (pos->offset != -1) | 655 | if (pos->offset != -1) |
659 | rbpos->idx_asm = browser.nr_asm_entries++; | 656 | rbpos->idx_asm = browser.nr_asm_entries++; |
@@ -667,7 +664,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
667 | ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); | 664 | ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); |
668 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { | 665 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { |
669 | list_del(&pos->node); | 666 | list_del(&pos->node); |
670 | objdump_line__free(pos); | 667 | disasm_line__free(pos); |
671 | } | 668 | } |
672 | return ret; | 669 | return ret; |
673 | } | 670 | } |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 1e7fd52bd29d..ef1d57def76d 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -78,36 +78,35 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map, | |||
78 | return 0; | 78 | return 0; |
79 | } | 79 | } |
80 | 80 | ||
81 | static struct objdump_line *objdump_line__new(s64 offset, char *line, size_t privsize) | 81 | static struct disasm_line *disasm_line__new(s64 offset, char *line, size_t privsize) |
82 | { | 82 | { |
83 | struct objdump_line *self = malloc(sizeof(*self) + privsize); | 83 | struct disasm_line *dl = malloc(sizeof(*dl) + privsize); |
84 | 84 | ||
85 | if (self != NULL) { | 85 | if (dl != NULL) { |
86 | self->offset = offset; | 86 | dl->offset = offset; |
87 | self->line = strdup(line); | 87 | dl->line = strdup(line); |
88 | if (self->line == NULL) | 88 | if (dl->line == NULL) |
89 | goto out_delete; | 89 | goto out_delete; |
90 | } | 90 | } |
91 | 91 | ||
92 | return self; | 92 | return dl; |
93 | out_delete: | 93 | out_delete: |
94 | free(self); | 94 | free(dl); |
95 | return NULL; | 95 | return NULL; |
96 | } | 96 | } |
97 | 97 | ||
98 | void objdump_line__free(struct objdump_line *self) | 98 | void disasm_line__free(struct disasm_line *dl) |
99 | { | 99 | { |
100 | free(self->line); | 100 | free(dl->line); |
101 | free(self); | 101 | free(dl); |
102 | } | 102 | } |
103 | 103 | ||
104 | static void objdump__add_line(struct list_head *head, struct objdump_line *line) | 104 | static void disasm__add(struct list_head *head, struct disasm_line *line) |
105 | { | 105 | { |
106 | list_add_tail(&line->node, head); | 106 | list_add_tail(&line->node, head); |
107 | } | 107 | } |
108 | 108 | ||
109 | struct objdump_line *objdump__get_next_ip_line(struct list_head *head, | 109 | struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos) |
110 | struct objdump_line *pos) | ||
111 | { | 110 | { |
112 | list_for_each_entry_continue(pos, head, node) | 111 | list_for_each_entry_continue(pos, head, node) |
113 | if (pos->offset >= 0) | 112 | if (pos->offset >= 0) |
@@ -116,15 +115,14 @@ struct objdump_line *objdump__get_next_ip_line(struct list_head *head, | |||
116 | return NULL; | 115 | return NULL; |
117 | } | 116 | } |
118 | 117 | ||
119 | static int objdump_line__print(struct objdump_line *oline, struct symbol *sym, | 118 | static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 start, |
120 | u64 start, int evidx, u64 len, int min_pcnt, | 119 | int evidx, u64 len, int min_pcnt, int printed, |
121 | int printed, int max_lines, | 120 | int max_lines, struct disasm_line *queue) |
122 | struct objdump_line *queue) | ||
123 | { | 121 | { |
124 | static const char *prev_line; | 122 | static const char *prev_line; |
125 | static const char *prev_color; | 123 | static const char *prev_color; |
126 | 124 | ||
127 | if (oline->offset != -1) { | 125 | if (dl->offset != -1) { |
128 | const char *path = NULL; | 126 | const char *path = NULL; |
129 | unsigned int hits = 0; | 127 | unsigned int hits = 0; |
130 | double percent = 0.0; | 128 | double percent = 0.0; |
@@ -132,11 +130,11 @@ static int objdump_line__print(struct objdump_line *oline, struct symbol *sym, | |||
132 | struct annotation *notes = symbol__annotation(sym); | 130 | struct annotation *notes = symbol__annotation(sym); |
133 | struct source_line *src_line = notes->src->lines; | 131 | struct source_line *src_line = notes->src->lines; |
134 | struct sym_hist *h = annotation__histogram(notes, evidx); | 132 | struct sym_hist *h = annotation__histogram(notes, evidx); |
135 | s64 offset = oline->offset; | 133 | s64 offset = dl->offset; |
136 | const u64 addr = start + offset; | 134 | const u64 addr = start + offset; |
137 | struct objdump_line *next; | 135 | struct disasm_line *next; |
138 | 136 | ||
139 | next = objdump__get_next_ip_line(¬es->src->source, oline); | 137 | next = disasm__get_next_ip_line(¬es->src->source, dl); |
140 | 138 | ||
141 | while (offset < (s64)len && | 139 | while (offset < (s64)len && |
142 | (next == NULL || offset < next->offset)) { | 140 | (next == NULL || offset < next->offset)) { |
@@ -161,9 +159,9 @@ static int objdump_line__print(struct objdump_line *oline, struct symbol *sym, | |||
161 | 159 | ||
162 | if (queue != NULL) { | 160 | if (queue != NULL) { |
163 | list_for_each_entry_from(queue, ¬es->src->source, node) { | 161 | list_for_each_entry_from(queue, ¬es->src->source, node) { |
164 | if (queue == oline) | 162 | if (queue == dl) |
165 | break; | 163 | break; |
166 | objdump_line__print(queue, sym, start, evidx, len, | 164 | disasm_line__print(queue, sym, start, evidx, len, |
167 | 0, 0, 1, NULL); | 165 | 0, 0, 1, NULL); |
168 | } | 166 | } |
169 | } | 167 | } |
@@ -187,17 +185,17 @@ static int objdump_line__print(struct objdump_line *oline, struct symbol *sym, | |||
187 | color_fprintf(stdout, color, " %7.2f", percent); | 185 | color_fprintf(stdout, color, " %7.2f", percent); |
188 | printf(" : "); | 186 | printf(" : "); |
189 | color_fprintf(stdout, PERF_COLOR_MAGENTA, " %" PRIx64 ":", addr); | 187 | color_fprintf(stdout, PERF_COLOR_MAGENTA, " %" PRIx64 ":", addr); |
190 | color_fprintf(stdout, PERF_COLOR_BLUE, "%s\n", oline->line); | 188 | color_fprintf(stdout, PERF_COLOR_BLUE, "%s\n", dl->line); |
191 | } else if (max_lines && printed >= max_lines) | 189 | } else if (max_lines && printed >= max_lines) |
192 | return 1; | 190 | return 1; |
193 | else { | 191 | else { |
194 | if (queue) | 192 | if (queue) |
195 | return -1; | 193 | return -1; |
196 | 194 | ||
197 | if (!*oline->line) | 195 | if (!*dl->line) |
198 | printf(" :\n"); | 196 | printf(" :\n"); |
199 | else | 197 | else |
200 | printf(" : %s\n", oline->line); | 198 | printf(" : %s\n", dl->line); |
201 | } | 199 | } |
202 | 200 | ||
203 | return 0; | 201 | return 0; |
@@ -207,7 +205,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map, | |||
207 | FILE *file, size_t privsize) | 205 | FILE *file, size_t privsize) |
208 | { | 206 | { |
209 | struct annotation *notes = symbol__annotation(sym); | 207 | struct annotation *notes = symbol__annotation(sym); |
210 | struct objdump_line *objdump_line; | 208 | struct disasm_line *dl; |
211 | char *line = NULL, *parsed_line, *tmp, *tmp2, *c; | 209 | char *line = NULL, *parsed_line, *tmp, *tmp2, *c; |
212 | size_t line_len; | 210 | size_t line_len; |
213 | s64 line_ip, offset = -1; | 211 | s64 line_ip, offset = -1; |
@@ -258,13 +256,13 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map, | |||
258 | parsed_line = tmp2 + 1; | 256 | parsed_line = tmp2 + 1; |
259 | } | 257 | } |
260 | 258 | ||
261 | objdump_line = objdump_line__new(offset, parsed_line, privsize); | 259 | dl = disasm_line__new(offset, parsed_line, privsize); |
262 | free(line); | 260 | free(line); |
263 | 261 | ||
264 | if (objdump_line == NULL) | 262 | if (dl == NULL) |
265 | return -1; | 263 | return -1; |
266 | 264 | ||
267 | objdump__add_line(¬es->src->source, objdump_line); | 265 | disasm__add(¬es->src->source, dl); |
268 | 266 | ||
269 | return 0; | 267 | return 0; |
270 | } | 268 | } |
@@ -503,7 +501,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, | |||
503 | struct dso *dso = map->dso; | 501 | struct dso *dso = map->dso; |
504 | const char *filename = dso->long_name, *d_filename; | 502 | const char *filename = dso->long_name, *d_filename; |
505 | struct annotation *notes = symbol__annotation(sym); | 503 | struct annotation *notes = symbol__annotation(sym); |
506 | struct objdump_line *pos, *queue = NULL; | 504 | struct disasm_line *pos, *queue = NULL; |
507 | u64 start = map__rip_2objdump(map, sym->start); | 505 | u64 start = map__rip_2objdump(map, sym->start); |
508 | int printed = 2, queue_len = 0; | 506 | int printed = 2, queue_len = 0; |
509 | int more = 0; | 507 | int more = 0; |
@@ -528,7 +526,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, | |||
528 | queue_len = 0; | 526 | queue_len = 0; |
529 | } | 527 | } |
530 | 528 | ||
531 | switch (objdump_line__print(pos, sym, start, evidx, len, | 529 | switch (disasm_line__print(pos, sym, start, evidx, len, |
532 | min_pcnt, printed, max_lines, | 530 | min_pcnt, printed, max_lines, |
533 | queue)) { | 531 | queue)) { |
534 | case 0: | 532 | case 0: |
@@ -583,13 +581,13 @@ void symbol__annotate_decay_histogram(struct symbol *sym, int evidx) | |||
583 | } | 581 | } |
584 | } | 582 | } |
585 | 583 | ||
586 | void objdump_line_list__purge(struct list_head *head) | 584 | void disasm__purge(struct list_head *head) |
587 | { | 585 | { |
588 | struct objdump_line *pos, *n; | 586 | struct disasm_line *pos, *n; |
589 | 587 | ||
590 | list_for_each_entry_safe(pos, n, head, node) { | 588 | list_for_each_entry_safe(pos, n, head, node) { |
591 | list_del(&pos->node); | 589 | list_del(&pos->node); |
592 | objdump_line__free(pos); | 590 | disasm_line__free(pos); |
593 | } | 591 | } |
594 | } | 592 | } |
595 | 593 | ||
@@ -618,7 +616,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, | |||
618 | if (print_lines) | 616 | if (print_lines) |
619 | symbol__free_source_line(sym, len); | 617 | symbol__free_source_line(sym, len); |
620 | 618 | ||
621 | objdump_line_list__purge(&symbol__annotation(sym)->src->source); | 619 | disasm__purge(&symbol__annotation(sym)->src->source); |
622 | 620 | ||
623 | return 0; | 621 | return 0; |
624 | } | 622 | } |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index efa5dc82bfae..8bb68bb2a04a 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -7,15 +7,14 @@ | |||
7 | #include <linux/list.h> | 7 | #include <linux/list.h> |
8 | #include <linux/rbtree.h> | 8 | #include <linux/rbtree.h> |
9 | 9 | ||
10 | struct objdump_line { | 10 | struct disasm_line { |
11 | struct list_head node; | 11 | struct list_head node; |
12 | s64 offset; | 12 | s64 offset; |
13 | char *line; | 13 | char *line; |
14 | }; | 14 | }; |
15 | 15 | ||
16 | void objdump_line__free(struct objdump_line *self); | 16 | void disasm_line__free(struct disasm_line *dl); |
17 | struct objdump_line *objdump__get_next_ip_line(struct list_head *head, | 17 | struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos); |
18 | struct objdump_line *pos); | ||
19 | 18 | ||
20 | struct sym_hist { | 19 | struct sym_hist { |
21 | u64 sum; | 20 | u64 sum; |
@@ -32,7 +31,7 @@ struct source_line { | |||
32 | * | 31 | * |
33 | * @histogram: Array of addr hit histograms per event being monitored | 32 | * @histogram: Array of addr hit histograms per event being monitored |
34 | * @lines: If 'print_lines' is specified, per source code line percentages | 33 | * @lines: If 'print_lines' is specified, per source code line percentages |
35 | * @source: source parsed from objdump -dS | 34 | * @source: source parsed from a disassembler like objdump -dS |
36 | * | 35 | * |
37 | * lines is allocated, percentages calculated and all sorted by percentage | 36 | * lines is allocated, percentages calculated and all sorted by percentage |
38 | * when the annotation is about to be presented, so the percentages are for | 37 | * when the annotation is about to be presented, so the percentages are for |
@@ -82,7 +81,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, | |||
82 | int context); | 81 | int context); |
83 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); | 82 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); |
84 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); | 83 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); |
85 | void objdump_line_list__purge(struct list_head *head); | 84 | void disasm__purge(struct list_head *head); |
86 | 85 | ||
87 | int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, | 86 | int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, |
88 | bool print_lines, bool full_paths, int min_pcnt, | 87 | bool print_lines, bool full_paths, int min_pcnt, |