aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-04-15 14:24:39 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-04-16 11:09:59 -0400
commit29ed6e76b4ca81103f31c8316f9e4cfcf134572f (patch)
tree899c3a3262d5f84ecdb7e45d2f21f33c8dea827e /tools/perf/util
parenta385ec4f11bdcf81af094c03e2444ee9b7fad2e5 (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/perf/util')
-rw-r--r--tools/perf/util/annotate.c72
-rw-r--r--tools/perf/util/annotate.h11
2 files changed, 40 insertions, 43 deletions
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
81static struct objdump_line *objdump_line__new(s64 offset, char *line, size_t privsize) 81static 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;
93out_delete: 93out_delete:
94 free(self); 94 free(dl);
95 return NULL; 95 return NULL;
96} 96}
97 97
98void objdump_line__free(struct objdump_line *self) 98void 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
104static void objdump__add_line(struct list_head *head, struct objdump_line *line) 104static 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
109struct objdump_line *objdump__get_next_ip_line(struct list_head *head, 109struct 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
119static int objdump_line__print(struct objdump_line *oline, struct symbol *sym, 118static 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(&notes->src->source, oline); 137 next = disasm__get_next_ip_line(&notes->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, &notes->src->source, node) { 161 list_for_each_entry_from(queue, &notes->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(&notes->src->source, objdump_line); 265 disasm__add(&notes->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
586void objdump_line_list__purge(struct list_head *head) 584void 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
10struct objdump_line { 10struct 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
16void objdump_line__free(struct objdump_line *self); 16void disasm_line__free(struct disasm_line *dl);
17struct objdump_line *objdump__get_next_ip_line(struct list_head *head, 17struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos);
18 struct objdump_line *pos);
19 18
20struct sym_hist { 19struct 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);
83void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); 82void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
84void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); 83void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
85void objdump_line_list__purge(struct list_head *head); 84void disasm__purge(struct list_head *head);
86 85
87int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, 86int 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,