blob: 0905db4390c1dfa177d176beb6ac435329ed0a30 [file] [log] [blame]
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -02001/*
2 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
3 *
4 * Parts came from builtin-annotate.c, see those files for further
5 * copyright notes.
6 *
7 * Released under the GPL v2. (and only v2, not any later version)
8 */
9
10#include "util.h"
11#include "build-id.h"
12#include "color.h"
13#include "cache.h"
14#include "symbol.h"
15#include "debug.h"
16#include "annotate.h"
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -020017#include <pthread.h>
18
Andi Kleenf69b64f2011-09-15 14:31:41 -070019const char *disassembler_style;
20
Arnaldo Carvalho de Melo54170722012-05-07 18:54:16 -030021static int ins__raw_scnprintf(struct ins *ins, char *bf, size_t size,
22 struct ins_operands *ops)
23{
24 return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
25}
26
27int ins__scnprintf(struct ins *ins, char *bf, size_t size,
28 struct ins_operands *ops)
29{
30 if (ins->ops->scnprintf)
31 return ins->ops->scnprintf(ins, bf, size, ops);
32
33 return ins__raw_scnprintf(ins, bf, size, ops);
34}
35
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -030036static int call__parse(struct ins_operands *ops)
Arnaldo Carvalho de Melod86b0592012-04-18 16:07:38 -030037{
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030038 char *endptr, *tok, *name;
39
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -030040 ops->target.addr = strtoull(ops->raw, &endptr, 16);
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030041
42 name = strchr(endptr, '<');
43 if (name == NULL)
44 goto indirect_call;
45
46 name++;
47
48 tok = strchr(name, '>');
49 if (tok == NULL)
50 return -1;
51
52 *tok = '\0';
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -030053 ops->target.name = strdup(name);
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030054 *tok = '>';
55
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -030056 return ops->target.name == NULL ? -1 : 0;
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030057
58indirect_call:
59 tok = strchr(endptr, '*');
60 if (tok == NULL)
61 return -1;
62
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -030063 ops->target.addr = strtoull(tok + 1, NULL, 16);
Arnaldo Carvalho de Melod86b0592012-04-18 16:07:38 -030064 return 0;
65}
66
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030067static int call__scnprintf(struct ins *ins, char *bf, size_t size,
Arnaldo Carvalho de Melo54170722012-05-07 18:54:16 -030068 struct ins_operands *ops)
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030069{
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -030070 if (ops->target.name)
71 return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->target.name);
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030072
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -030073 return scnprintf(bf, size, "%-6.6s *%" PRIx64, ins->name, ops->target.addr);
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030074}
75
Arnaldo Carvalho de Melod86b0592012-04-18 16:07:38 -030076static struct ins_ops call_ops = {
Arnaldo Carvalho de Melod2232882012-04-20 15:26:47 -030077 .parse = call__parse,
78 .scnprintf = call__scnprintf,
Arnaldo Carvalho de Melod86b0592012-04-18 16:07:38 -030079};
80
81bool ins__is_call(const struct ins *ins)
82{
83 return ins->ops == &call_ops;
84}
85
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -030086static int jump__parse(struct ins_operands *ops)
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -030087{
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -030088 const char *s = strchr(ops->raw, '+');
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -030089
Arnaldo Carvalho de Melofb29fa582012-04-25 14:16:03 -030090 ops->target.addr = strtoll(ops->raw, NULL, 16);
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -030091
Arnaldo Carvalho de Melofb29fa582012-04-25 14:16:03 -030092 if (s++ != NULL)
93 ops->target.offset = strtoll(s, NULL, 16);
94 else
95 ops->target.offset = UINT64_MAX;
96
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -030097 return 0;
98}
99
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300100static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
Arnaldo Carvalho de Melo54170722012-05-07 18:54:16 -0300101 struct ins_operands *ops)
Arnaldo Carvalho de Melo28548d72012-04-19 10:16:27 -0300102{
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -0300103 return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset);
Arnaldo Carvalho de Melo28548d72012-04-19 10:16:27 -0300104}
105
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300106static struct ins_ops jump_ops = {
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300107 .parse = jump__parse,
108 .scnprintf = jump__scnprintf,
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300109};
110
111bool ins__is_jump(const struct ins *ins)
112{
113 return ins->ops == &jump_ops;
114}
115
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300116/*
117 * Must be sorted by name!
118 */
119static struct ins instructions[] = {
Arnaldo Carvalho de Melod86b0592012-04-18 16:07:38 -0300120 { .name = "call", .ops = &call_ops, },
121 { .name = "callq", .ops = &call_ops, },
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300122 { .name = "ja", .ops = &jump_ops, },
Arnaldo Carvalho de Melo3f862fd2012-04-19 17:10:12 -0300123 { .name = "jae", .ops = &jump_ops, },
124 { .name = "jb", .ops = &jump_ops, },
125 { .name = "jbe", .ops = &jump_ops, },
126 { .name = "jc", .ops = &jump_ops, },
127 { .name = "jcxz", .ops = &jump_ops, },
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300128 { .name = "je", .ops = &jump_ops, },
Arnaldo Carvalho de Melo3f862fd2012-04-19 17:10:12 -0300129 { .name = "jecxz", .ops = &jump_ops, },
130 { .name = "jg", .ops = &jump_ops, },
131 { .name = "jge", .ops = &jump_ops, },
132 { .name = "jl", .ops = &jump_ops, },
133 { .name = "jle", .ops = &jump_ops, },
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300134 { .name = "jmp", .ops = &jump_ops, },
135 { .name = "jmpq", .ops = &jump_ops, },
Arnaldo Carvalho de Melo3f862fd2012-04-19 17:10:12 -0300136 { .name = "jna", .ops = &jump_ops, },
137 { .name = "jnae", .ops = &jump_ops, },
138 { .name = "jnb", .ops = &jump_ops, },
139 { .name = "jnbe", .ops = &jump_ops, },
140 { .name = "jnc", .ops = &jump_ops, },
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300141 { .name = "jne", .ops = &jump_ops, },
Arnaldo Carvalho de Melo3f862fd2012-04-19 17:10:12 -0300142 { .name = "jng", .ops = &jump_ops, },
143 { .name = "jnge", .ops = &jump_ops, },
144 { .name = "jnl", .ops = &jump_ops, },
145 { .name = "jnle", .ops = &jump_ops, },
146 { .name = "jno", .ops = &jump_ops, },
147 { .name = "jnp", .ops = &jump_ops, },
148 { .name = "jns", .ops = &jump_ops, },
149 { .name = "jnz", .ops = &jump_ops, },
150 { .name = "jo", .ops = &jump_ops, },
151 { .name = "jp", .ops = &jump_ops, },
152 { .name = "jpe", .ops = &jump_ops, },
153 { .name = "jpo", .ops = &jump_ops, },
154 { .name = "jrcxz", .ops = &jump_ops, },
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300155 { .name = "js", .ops = &jump_ops, },
Arnaldo Carvalho de Melo3f862fd2012-04-19 17:10:12 -0300156 { .name = "jz", .ops = &jump_ops, },
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300157};
158
159static int ins__cmp(const void *name, const void *insp)
160{
161 const struct ins *ins = insp;
162
163 return strcmp(name, ins->name);
164}
165
166static struct ins *ins__find(const char *name)
167{
168 const int nmemb = ARRAY_SIZE(instructions);
169
170 return bsearch(name, instructions, nmemb, sizeof(struct ins), ins__cmp);
171}
172
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200173int symbol__annotate_init(struct map *map __used, struct symbol *sym)
174{
175 struct annotation *notes = symbol__annotation(sym);
176 pthread_mutex_init(&notes->lock, NULL);
177 return 0;
178}
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200179
Arnaldo Carvalho de Melod04b35f2011-11-11 22:17:32 -0200180int symbol__alloc_hist(struct symbol *sym)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200181{
182 struct annotation *notes = symbol__annotation(sym);
Arnaldo Carvalho de Melo1b2e2df2012-04-19 10:57:06 -0300183 const size_t size = symbol__size(sym);
Arnaldo Carvalho de Melo64c17be2012-03-28 12:49:35 -0300184 size_t sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200185
Arnaldo Carvalho de Melod04b35f2011-11-11 22:17:32 -0200186 notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist);
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200187 if (notes->src == NULL)
188 return -1;
189 notes->src->sizeof_sym_hist = sizeof_sym_hist;
Arnaldo Carvalho de Melod04b35f2011-11-11 22:17:32 -0200190 notes->src->nr_histograms = symbol_conf.nr_events;
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200191 INIT_LIST_HEAD(&notes->src->source);
192 return 0;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200193}
194
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200195void symbol__annotate_zero_histograms(struct symbol *sym)
196{
197 struct annotation *notes = symbol__annotation(sym);
198
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200199 pthread_mutex_lock(&notes->lock);
200 if (notes->src != NULL)
201 memset(notes->src->histograms, 0,
202 notes->src->nr_histograms * notes->src->sizeof_sym_hist);
203 pthread_mutex_unlock(&notes->lock);
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200204}
205
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200206int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
207 int evidx, u64 addr)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200208{
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200209 unsigned offset;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200210 struct annotation *notes;
211 struct sym_hist *h;
212
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200213 notes = symbol__annotation(sym);
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200214 if (notes->src == NULL)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200215 return -ENOMEM;
216
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200217 pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
218
Arnaldo Carvalho de Melo31d68e72012-03-27 12:55:57 -0300219 if (addr < sym->start || addr > sym->end)
220 return -ERANGE;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200221
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200222 offset = addr - sym->start;
223 h = annotation__histogram(notes, evidx);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200224 h->sum++;
225 h->addr[offset]++;
226
227 pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200228 ", evidx=%d] => %" PRIu64 "\n", sym->start, sym->name,
229 addr, addr - sym->start, evidx, h->addr[offset]);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200230 return 0;
231}
232
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300233static void disasm_line__init_ins(struct disasm_line *dl)
234{
235 dl->ins = ins__find(dl->name);
236
237 if (dl->ins == NULL)
238 return;
239
240 if (!dl->ins->ops)
241 return;
242
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300243 if (dl->ins->ops->parse)
244 dl->ins->ops->parse(&dl->ops);
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300245}
246
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300247static struct disasm_line *disasm_line__new(s64 offset, char *line, size_t privsize)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200248{
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300249 struct disasm_line *dl = zalloc(sizeof(*dl) + privsize);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200250
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300251 if (dl != NULL) {
252 dl->offset = offset;
253 dl->line = strdup(line);
254 if (dl->line == NULL)
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300255 goto out_delete;
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300256
257 if (offset != -1) {
258 char *name = dl->line, tmp;
259
260 while (isspace(name[0]))
261 ++name;
262
263 if (name[0] == '\0')
264 goto out_delete;
265
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300266 dl->ops.raw = name + 1;
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300267
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300268 while (dl->ops.raw[0] != '\0' &&
269 !isspace(dl->ops.raw[0]))
270 ++dl->ops.raw;
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300271
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300272 tmp = dl->ops.raw[0];
273 dl->ops.raw[0] = '\0';
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300274 dl->name = strdup(name);
275
276 if (dl->name == NULL)
277 goto out_free_line;
278
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300279 dl->ops.raw[0] = tmp;
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300280
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300281 if (dl->ops.raw[0] != '\0') {
282 dl->ops.raw++;
283 while (isspace(dl->ops.raw[0]))
284 ++dl->ops.raw;
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300285 }
Arnaldo Carvalho de Melo4f9d0322012-04-18 13:58:34 -0300286
287 disasm_line__init_ins(dl);
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300288 }
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200289 }
290
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300291 return dl;
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300292
293out_free_line:
294 free(dl->line);
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300295out_delete:
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300296 free(dl);
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300297 return NULL;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200298}
299
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300300void disasm_line__free(struct disasm_line *dl)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200301{
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300302 free(dl->line);
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300303 free(dl->name);
Arnaldo Carvalho de Melo44d1a3e2012-04-25 08:00:23 -0300304 free(dl->ops.target.name);
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300305 free(dl);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200306}
307
Arnaldo Carvalho de Melo54170722012-05-07 18:54:16 -0300308int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw)
309{
310 if (raw || !dl->ins)
311 return scnprintf(bf, size, "%-6.6s %s", dl->name, dl->ops.raw);
312
313 return ins__scnprintf(dl->ins, bf, size, &dl->ops);
314}
315
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300316static void disasm__add(struct list_head *head, struct disasm_line *line)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200317{
318 list_add_tail(&line->node, head);
319}
320
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300321struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200322{
323 list_for_each_entry_continue(pos, head, node)
324 if (pos->offset >= 0)
325 return pos;
326
327 return NULL;
328}
329
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300330static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 start,
331 int evidx, u64 len, int min_pcnt, int printed,
332 int max_lines, struct disasm_line *queue)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200333{
334 static const char *prev_line;
335 static const char *prev_color;
336
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300337 if (dl->offset != -1) {
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200338 const char *path = NULL;
339 unsigned int hits = 0;
340 double percent = 0.0;
341 const char *color;
342 struct annotation *notes = symbol__annotation(sym);
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200343 struct source_line *src_line = notes->src->lines;
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200344 struct sym_hist *h = annotation__histogram(notes, evidx);
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300345 s64 offset = dl->offset;
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300346 const u64 addr = start + offset;
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300347 struct disasm_line *next;
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200348
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300349 next = disasm__get_next_ip_line(&notes->src->source, dl);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200350
351 while (offset < (s64)len &&
352 (next == NULL || offset < next->offset)) {
353 if (src_line) {
354 if (path == NULL)
355 path = src_line[offset].path;
356 percent += src_line[offset].percent;
357 } else
358 hits += h->addr[offset];
359
360 ++offset;
361 }
362
363 if (src_line == NULL && h->sum)
364 percent = 100.0 * hits / h->sum;
365
Arnaldo Carvalho de Melod040bd32011-02-05 15:37:31 -0200366 if (percent < min_pcnt)
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200367 return -1;
368
Arnaldo Carvalho de Meloe3087b82011-02-08 15:01:39 -0200369 if (max_lines && printed >= max_lines)
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200370 return 1;
Arnaldo Carvalho de Melod040bd32011-02-05 15:37:31 -0200371
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200372 if (queue != NULL) {
373 list_for_each_entry_from(queue, &notes->src->source, node) {
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300374 if (queue == dl)
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200375 break;
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300376 disasm_line__print(queue, sym, start, evidx, len,
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200377 0, 0, 1, NULL);
378 }
379 }
380
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200381 color = get_percent_color(percent);
382
383 /*
384 * Also color the filename and line if needed, with
385 * the same color than the percentage. Don't print it
386 * twice for close colored addr with the same filename:line
387 */
388 if (path) {
389 if (!prev_line || strcmp(prev_line, path)
390 || color != prev_color) {
391 color_fprintf(stdout, color, " %s", path);
392 prev_line = path;
393 prev_color = color;
394 }
395 }
396
397 color_fprintf(stdout, color, " %7.2f", percent);
398 printf(" : ");
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300399 color_fprintf(stdout, PERF_COLOR_MAGENTA, " %" PRIx64 ":", addr);
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300400 color_fprintf(stdout, PERF_COLOR_BLUE, "%s\n", dl->line);
Arnaldo Carvalho de Meloe3087b82011-02-08 15:01:39 -0200401 } else if (max_lines && printed >= max_lines)
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200402 return 1;
403 else {
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200404 if (queue)
405 return -1;
406
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300407 if (!*dl->line)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200408 printf(" :\n");
409 else
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300410 printf(" : %s\n", dl->line);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200411 }
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200412
413 return 0;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200414}
415
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200416static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
417 FILE *file, size_t privsize)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200418{
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200419 struct annotation *notes = symbol__annotation(sym);
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300420 struct disasm_line *dl;
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300421 char *line = NULL, *parsed_line, *tmp, *tmp2, *c;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200422 size_t line_len;
423 s64 line_ip, offset = -1;
424
425 if (getline(&line, &line_len, file) < 0)
426 return -1;
427
428 if (!line)
429 return -1;
430
431 while (line_len != 0 && isspace(line[line_len - 1]))
432 line[--line_len] = '\0';
433
434 c = strchr(line, '\n');
435 if (c)
436 *c = 0;
437
438 line_ip = -1;
Namhyung Kima31b7cc2012-04-11 17:04:59 -0300439 parsed_line = line;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200440
441 /*
442 * Strip leading spaces:
443 */
444 tmp = line;
445 while (*tmp) {
446 if (*tmp != ' ')
447 break;
448 tmp++;
449 }
450
451 if (*tmp) {
452 /*
453 * Parse hexa addresses followed by ':'
454 */
455 line_ip = strtoull(tmp, &tmp2, 16);
456 if (*tmp2 != ':' || tmp == tmp2 || tmp2[1] == '\0')
457 line_ip = -1;
458 }
459
460 if (line_ip != -1) {
461 u64 start = map__rip_2objdump(map, sym->start),
462 end = map__rip_2objdump(map, sym->end);
463
464 offset = line_ip - start;
465 if (offset < 0 || (u64)line_ip > end)
466 offset = -1;
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300467 else
468 parsed_line = tmp2 + 1;
Namhyung Kima31b7cc2012-04-11 17:04:59 -0300469 }
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200470
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300471 dl = disasm_line__new(offset, parsed_line, privsize);
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300472 free(line);
473
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300474 if (dl == NULL)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200475 return -1;
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300476
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300477 disasm__add(&notes->src->source, dl);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200478
479 return 0;
480}
481
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200482int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200483{
484 struct dso *dso = map->dso;
485 char *filename = dso__build_id_filename(dso, NULL, 0);
486 bool free_filename = true;
487 char command[PATH_MAX * 2];
488 FILE *file;
489 int err = 0;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200490 char symfs_filename[PATH_MAX];
491
492 if (filename) {
493 snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
494 symbol_conf.symfs, filename);
495 }
496
497 if (filename == NULL) {
498 if (dso->has_build_id) {
499 pr_err("Can't annotate %s: not enough memory\n",
500 sym->name);
501 return -ENOMEM;
502 }
503 goto fallback;
504 } else if (readlink(symfs_filename, command, sizeof(command)) < 0 ||
505 strstr(command, "[kernel.kallsyms]") ||
506 access(symfs_filename, R_OK)) {
507 free(filename);
508fallback:
509 /*
510 * If we don't have build-ids or the build-id file isn't in the
511 * cache, or is just a kallsyms file, well, lets hope that this
512 * DSO is the same as when 'perf record' ran.
513 */
514 filename = dso->long_name;
515 snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
516 symbol_conf.symfs, filename);
517 free_filename = false;
518 }
519
Arnaldo Carvalho de Melo878b4392011-03-11 13:13:36 -0300520 if (dso->symtab_type == SYMTAB__KALLSYMS) {
Arnaldo Carvalho de Melo170ae6b2011-02-23 11:08:59 -0300521 char bf[BUILD_ID_SIZE * 2 + 16] = " with build id ";
522 char *build_id_msg = NULL;
523
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200524 if (dso->annotate_warned)
525 goto out_free_filename;
Arnaldo Carvalho de Melo170ae6b2011-02-23 11:08:59 -0300526
527 if (dso->has_build_id) {
528 build_id__sprintf(dso->build_id,
529 sizeof(dso->build_id), bf + 15);
530 build_id_msg = bf;
531 }
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200532 err = -ENOENT;
533 dso->annotate_warned = 1;
Arnaldo Carvalho de Meloae557952011-10-26 08:00:55 -0200534 pr_err("Can't annotate %s:\n\n"
535 "No vmlinux file%s\nwas found in the path.\n\n"
536 "Please use:\n\n"
537 " perf buildid-cache -av vmlinux\n\n"
538 "or:\n\n"
Namhyung Kimff2a6612012-02-23 17:46:24 +0900539 " --vmlinux vmlinux\n",
Arnaldo Carvalho de Melo170ae6b2011-02-23 11:08:59 -0300540 sym->name, build_id_msg ?: "");
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200541 goto out_free_filename;
542 }
543
544 pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
545 filename, sym->name, map->unmap_ip(map, sym->start),
546 map->unmap_ip(map, sym->end));
547
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200548 pr_debug("annotating [%p] %30s : [%p] %30s\n",
549 dso, dso->long_name, sym, sym->name);
550
551 snprintf(command, sizeof(command),
Andi Kleenf69b64f2011-09-15 14:31:41 -0700552 "objdump %s%s --start-address=0x%016" PRIx64
Stephane Eranian3e6a2a72011-05-17 17:32:07 +0200553 " --stop-address=0x%016" PRIx64
554 " -d %s %s -C %s|grep -v %s|expand",
Andi Kleenf69b64f2011-09-15 14:31:41 -0700555 disassembler_style ? "-M " : "",
556 disassembler_style ? disassembler_style : "",
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200557 map__rip_2objdump(map, sym->start),
Ingo Molnarf41612f2011-12-23 14:08:04 +0100558 map__rip_2objdump(map, sym->end+1),
Stephane Eranian3e6a2a72011-05-17 17:32:07 +0200559 symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
560 symbol_conf.annotate_src ? "-S" : "",
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200561 symfs_filename, filename);
562
563 pr_debug("Executing: %s\n", command);
564
565 file = popen(command, "r");
566 if (!file)
567 goto out_free_filename;
568
569 while (!feof(file))
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200570 if (symbol__parse_objdump_line(sym, map, file, privsize) < 0)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200571 break;
572
573 pclose(file);
574out_free_filename:
575 if (free_filename)
576 free(filename);
577 return err;
578}
579
580static void insert_source_line(struct rb_root *root, struct source_line *src_line)
581{
582 struct source_line *iter;
583 struct rb_node **p = &root->rb_node;
584 struct rb_node *parent = NULL;
585
586 while (*p != NULL) {
587 parent = *p;
588 iter = rb_entry(parent, struct source_line, node);
589
590 if (src_line->percent > iter->percent)
591 p = &(*p)->rb_left;
592 else
593 p = &(*p)->rb_right;
594 }
595
596 rb_link_node(&src_line->node, parent, p);
597 rb_insert_color(&src_line->node, root);
598}
599
600static void symbol__free_source_line(struct symbol *sym, int len)
601{
602 struct annotation *notes = symbol__annotation(sym);
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200603 struct source_line *src_line = notes->src->lines;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200604 int i;
605
606 for (i = 0; i < len; i++)
607 free(src_line[i].path);
608
609 free(src_line);
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200610 notes->src->lines = NULL;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200611}
612
613/* Get the filename:line for the colored entries */
614static int symbol__get_source_line(struct symbol *sym, struct map *map,
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200615 int evidx, struct rb_root *root, int len,
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200616 const char *filename)
617{
618 u64 start;
619 int i;
620 char cmd[PATH_MAX * 2];
621 struct source_line *src_line;
622 struct annotation *notes = symbol__annotation(sym);
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200623 struct sym_hist *h = annotation__histogram(notes, evidx);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200624
625 if (!h->sum)
626 return 0;
627
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200628 src_line = notes->src->lines = calloc(len, sizeof(struct source_line));
629 if (!notes->src->lines)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200630 return -1;
631
David Millerf40a0632012-03-25 16:28:12 -0400632 start = map__rip_2objdump(map, sym->start);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200633
634 for (i = 0; i < len; i++) {
635 char *path = NULL;
636 size_t line_len;
637 u64 offset;
638 FILE *fp;
639
640 src_line[i].percent = 100.0 * h->addr[i] / h->sum;
641 if (src_line[i].percent <= 0.5)
642 continue;
643
644 offset = start + i;
645 sprintf(cmd, "addr2line -e %s %016" PRIx64, filename, offset);
646 fp = popen(cmd, "r");
647 if (!fp)
648 continue;
649
650 if (getline(&path, &line_len, fp) < 0 || !line_len)
651 goto next;
652
653 src_line[i].path = malloc(sizeof(char) * line_len + 1);
654 if (!src_line[i].path)
655 goto next;
656
657 strcpy(src_line[i].path, path);
658 insert_source_line(root, &src_line[i]);
659
660 next:
661 pclose(fp);
662 }
663
664 return 0;
665}
666
667static void print_summary(struct rb_root *root, const char *filename)
668{
669 struct source_line *src_line;
670 struct rb_node *node;
671
672 printf("\nSorted summary for file %s\n", filename);
673 printf("----------------------------------------------\n\n");
674
675 if (RB_EMPTY_ROOT(root)) {
676 printf(" Nothing higher than %1.1f%%\n", MIN_GREEN);
677 return;
678 }
679
680 node = rb_first(root);
681 while (node) {
682 double percent;
683 const char *color;
684 char *path;
685
686 src_line = rb_entry(node, struct source_line, node);
687 percent = src_line->percent;
688 color = get_percent_color(percent);
689 path = src_line->path;
690
691 color_fprintf(stdout, color, " %7.2f %s", percent, path);
692 node = rb_next(node);
693 }
694}
695
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200696static void symbol__annotate_hits(struct symbol *sym, int evidx)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200697{
698 struct annotation *notes = symbol__annotation(sym);
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200699 struct sym_hist *h = annotation__histogram(notes, evidx);
Arnaldo Carvalho de Melo1b2e2df2012-04-19 10:57:06 -0300700 u64 len = symbol__size(sym), offset;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200701
702 for (offset = 0; offset < len; ++offset)
703 if (h->addr[offset] != 0)
704 printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2,
705 sym->start + offset, h->addr[offset]);
706 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum);
707}
708
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200709int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200710 bool full_paths, int min_pcnt, int max_lines,
711 int context)
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200712{
713 struct dso *dso = map->dso;
714 const char *filename = dso->long_name, *d_filename;
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200715 struct annotation *notes = symbol__annotation(sym);
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300716 struct disasm_line *pos, *queue = NULL;
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300717 u64 start = map__rip_2objdump(map, sym->start);
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200718 int printed = 2, queue_len = 0;
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200719 int more = 0;
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200720 u64 len;
721
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200722 if (full_paths)
723 d_filename = filename;
724 else
725 d_filename = basename(filename);
726
Arnaldo Carvalho de Melo1b2e2df2012-04-19 10:57:06 -0300727 len = symbol__size(sym);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200728
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200729 printf(" Percent | Source code & Disassembly of %s\n", d_filename);
730 printf("------------------------------------------------\n");
731
732 if (verbose)
733 symbol__annotate_hits(sym, evidx);
734
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200735 list_for_each_entry(pos, &notes->src->source, node) {
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200736 if (context && queue == NULL) {
737 queue = pos;
738 queue_len = 0;
739 }
740
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300741 switch (disasm_line__print(pos, sym, start, evidx, len,
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -0300742 min_pcnt, printed, max_lines,
743 queue)) {
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200744 case 0:
745 ++printed;
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200746 if (context) {
747 printed += queue_len;
748 queue = NULL;
749 queue_len = 0;
750 }
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200751 break;
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200752 case 1:
753 /* filtered by max_lines */
754 ++more;
755 break;
756 case -1:
757 default:
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200758 /*
759 * Filtered by min_pcnt or non IP lines when
760 * context != 0
761 */
762 if (!context)
763 break;
764 if (queue_len == context)
765 queue = list_entry(queue->node.next, typeof(*queue), node);
766 else
767 ++queue_len;
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200768 break;
769 }
770 }
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200771
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200772 return more;
773}
774
775void symbol__annotate_zero_histogram(struct symbol *sym, int evidx)
776{
777 struct annotation *notes = symbol__annotation(sym);
778 struct sym_hist *h = annotation__histogram(notes, evidx);
779
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200780 memset(h, 0, notes->src->sizeof_sym_hist);
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200781}
782
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200783void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200784{
785 struct annotation *notes = symbol__annotation(sym);
786 struct sym_hist *h = annotation__histogram(notes, evidx);
Arnaldo Carvalho de Melo1b2e2df2012-04-19 10:57:06 -0300787 int len = symbol__size(sym), offset;
Arnaldo Carvalho de Melo36532462011-02-06 14:54:44 -0200788
789 h->sum = 0;
Arnaldo Carvalho de Melo8b84a562012-04-05 16:15:59 -0300790 for (offset = 0; offset < len; ++offset) {
791 h->addr[offset] = h->addr[offset] * 7 / 8;
792 h->sum += h->addr[offset];
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200793 }
794}
795
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300796void disasm__purge(struct list_head *head)
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200797{
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300798 struct disasm_line *pos, *n;
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200799
800 list_for_each_entry_safe(pos, n, head, node) {
801 list_del(&pos->node);
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300802 disasm_line__free(pos);
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200803 }
804}
805
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300806static size_t disasm_line__fprintf(struct disasm_line *dl, FILE *fp)
807{
808 size_t printed;
809
810 if (dl->offset == -1)
811 return fprintf(fp, "%s\n", dl->line);
812
813 printed = fprintf(fp, "%#" PRIx64 " %s", dl->offset, dl->name);
814
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300815 if (dl->ops.raw[0] != '\0') {
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300816 printed += fprintf(fp, "%.*s %s\n", 6 - (int)printed, " ",
Arnaldo Carvalho de Meloc7e6ead2012-04-20 14:38:46 -0300817 dl->ops.raw);
Arnaldo Carvalho de Melo51454182012-04-15 15:52:18 -0300818 }
819
820 return printed + fprintf(fp, "\n");
821}
822
823size_t disasm__fprintf(struct list_head *head, FILE *fp)
824{
825 struct disasm_line *pos;
826 size_t printed = 0;
827
828 list_for_each_entry(pos, head, node)
829 printed += disasm_line__fprintf(pos, fp);
830
831 return printed;
832}
833
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200834int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
835 bool print_lines, bool full_paths, int min_pcnt,
836 int max_lines)
837{
838 struct dso *dso = map->dso;
839 const char *filename = dso->long_name;
840 struct rb_root source_line = RB_ROOT;
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200841 u64 len;
842
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200843 if (symbol__annotate(sym, map, 0) < 0)
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200844 return -1;
845
Arnaldo Carvalho de Melo1b2e2df2012-04-19 10:57:06 -0300846 len = symbol__size(sym);
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200847
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200848 if (print_lines) {
Arnaldo Carvalho de Melo2f525d02011-02-04 13:43:24 -0200849 symbol__get_source_line(sym, map, evidx, &source_line,
850 len, filename);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200851 print_summary(&source_line, filename);
852 }
853
Arnaldo Carvalho de Meloce6f4fa2011-02-08 13:27:39 -0200854 symbol__annotate_printf(sym, map, evidx, full_paths,
Arnaldo Carvalho de Melod5e3d742011-02-08 15:29:25 -0200855 min_pcnt, max_lines, 0);
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200856 if (print_lines)
857 symbol__free_source_line(sym, len);
858
Arnaldo Carvalho de Melo29ed6e72012-04-15 15:24:39 -0300859 disasm__purge(&symbol__annotation(sym)->src->source);
Arnaldo Carvalho de Melof1e27012011-02-05 18:51:38 -0200860
Arnaldo Carvalho de Melo78f7def2011-02-04 09:45:46 -0200861 return 0;
862}