aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2009-06-19 08:21:42 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-19 12:25:47 -0400
commit9cffa8d53335d891cc0ecb3824a67118b3ee4b2f (patch)
tree420e0f96198f0e78aedd006280826b8cf0839820 /tools/perf/builtin-annotate.c
parentb49a9e7e72103ea91946453c19703a4dfa1994fe (diff)
perf_counter tools: Define and use our own u64, s64 etc. definitions
On 64-bit powerpc, __u64 is defined to be unsigned long rather than unsigned long long. This causes compiler warnings every time we print a __u64 value with %Lx. Rather than changing __u64, we define our own u64 to be unsigned long long on all architectures, and similarly s64 as signed long long. For consistency we also define u32, s32, u16, s16, u8 and s8. These definitions are put in a new header, types.h, because these definitions are needed in util/string.h and util/symbol.h. The main change here is the mechanical change of __[us]{64,32,16,8} to remove the "__". The other changes are: * Create types.h * Include types.h in perf.h, util/string.h and util/symbol.h * Add types.h to the LIB_H definition in Makefile * Added (u64) casts in process_overflow_event() and print_sym_table() to kill two remaining warnings. Signed-off-by: Paul Mackerras <paulus@samba.org> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: benh@kernel.crashing.org LKML-Reference: <19003.33494.495844.956580@cargo.ozlabs.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 94cea678fd7e..7e58e3ad1508 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -50,35 +50,35 @@ static unsigned long mmap_window = 32;
50 50
51struct ip_event { 51struct ip_event {
52 struct perf_event_header header; 52 struct perf_event_header header;
53 __u64 ip; 53 u64 ip;
54 __u32 pid, tid; 54 u32 pid, tid;
55}; 55};
56 56
57struct mmap_event { 57struct mmap_event {
58 struct perf_event_header header; 58 struct perf_event_header header;
59 __u32 pid, tid; 59 u32 pid, tid;
60 __u64 start; 60 u64 start;
61 __u64 len; 61 u64 len;
62 __u64 pgoff; 62 u64 pgoff;
63 char filename[PATH_MAX]; 63 char filename[PATH_MAX];
64}; 64};
65 65
66struct comm_event { 66struct comm_event {
67 struct perf_event_header header; 67 struct perf_event_header header;
68 __u32 pid, tid; 68 u32 pid, tid;
69 char comm[16]; 69 char comm[16];
70}; 70};
71 71
72struct fork_event { 72struct fork_event {
73 struct perf_event_header header; 73 struct perf_event_header header;
74 __u32 pid, ppid; 74 u32 pid, ppid;
75}; 75};
76 76
77struct period_event { 77struct period_event {
78 struct perf_event_header header; 78 struct perf_event_header header;
79 __u64 time; 79 u64 time;
80 __u64 id; 80 u64 id;
81 __u64 sample_period; 81 u64 sample_period;
82}; 82};
83 83
84typedef union event_union { 84typedef union event_union {
@@ -158,7 +158,7 @@ static void dsos__fprintf(FILE *fp)
158 dso__fprintf(pos, fp); 158 dso__fprintf(pos, fp);
159} 159}
160 160
161static struct symbol *vdso__find_symbol(struct dso *dso, __u64 ip) 161static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
162{ 162{
163 return dso__find_symbol(kernel_dso, ip); 163 return dso__find_symbol(kernel_dso, ip);
164} 164}
@@ -191,19 +191,19 @@ static int load_kernel(void)
191 191
192struct map { 192struct map {
193 struct list_head node; 193 struct list_head node;
194 __u64 start; 194 u64 start;
195 __u64 end; 195 u64 end;
196 __u64 pgoff; 196 u64 pgoff;
197 __u64 (*map_ip)(struct map *, __u64); 197 u64 (*map_ip)(struct map *, u64);
198 struct dso *dso; 198 struct dso *dso;
199}; 199};
200 200
201static __u64 map__map_ip(struct map *map, __u64 ip) 201static u64 map__map_ip(struct map *map, u64 ip)
202{ 202{
203 return ip - map->start + map->pgoff; 203 return ip - map->start + map->pgoff;
204} 204}
205 205
206static __u64 vdso__map_ip(struct map *map, __u64 ip) 206static u64 vdso__map_ip(struct map *map, u64 ip)
207{ 207{
208 return ip; 208 return ip;
209} 209}
@@ -386,7 +386,7 @@ static int thread__fork(struct thread *self, struct thread *parent)
386 return 0; 386 return 0;
387} 387}
388 388
389static struct map *thread__find_map(struct thread *self, __u64 ip) 389static struct map *thread__find_map(struct thread *self, u64 ip)
390{ 390{
391 struct map *pos; 391 struct map *pos;
392 392
@@ -427,7 +427,7 @@ struct hist_entry {
427 struct map *map; 427 struct map *map;
428 struct dso *dso; 428 struct dso *dso;
429 struct symbol *sym; 429 struct symbol *sym;
430 __u64 ip; 430 u64 ip;
431 char level; 431 char level;
432 432
433 uint32_t count; 433 uint32_t count;
@@ -532,7 +532,7 @@ sort__dso_print(FILE *fp, struct hist_entry *self)
532 if (self->dso) 532 if (self->dso)
533 return fprintf(fp, "%-25s", self->dso->name); 533 return fprintf(fp, "%-25s", self->dso->name);
534 534
535 return fprintf(fp, "%016llx ", (__u64)self->ip); 535 return fprintf(fp, "%016llx ", (u64)self->ip);
536} 536}
537 537
538static struct sort_entry sort_dso = { 538static struct sort_entry sort_dso = {
@@ -546,7 +546,7 @@ static struct sort_entry sort_dso = {
546static int64_t 546static int64_t
547sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) 547sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
548{ 548{
549 __u64 ip_l, ip_r; 549 u64 ip_l, ip_r;
550 550
551 if (left->sym == right->sym) 551 if (left->sym == right->sym)
552 return 0; 552 return 0;
@@ -563,13 +563,13 @@ sort__sym_print(FILE *fp, struct hist_entry *self)
563 size_t ret = 0; 563 size_t ret = 0;
564 564
565 if (verbose) 565 if (verbose)
566 ret += fprintf(fp, "%#018llx ", (__u64)self->ip); 566 ret += fprintf(fp, "%#018llx ", (u64)self->ip);
567 567
568 if (self->sym) { 568 if (self->sym) {
569 ret += fprintf(fp, "[%c] %s", 569 ret += fprintf(fp, "[%c] %s",
570 self->dso == kernel_dso ? 'k' : '.', self->sym->name); 570 self->dso == kernel_dso ? 'k' : '.', self->sym->name);
571 } else { 571 } else {
572 ret += fprintf(fp, "%#016llx", (__u64)self->ip); 572 ret += fprintf(fp, "%#016llx", (u64)self->ip);
573 } 573 }
574 574
575 return ret; 575 return ret;
@@ -660,7 +660,7 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
660/* 660/*
661 * collect histogram counts 661 * collect histogram counts
662 */ 662 */
663static void hist_hit(struct hist_entry *he, __u64 ip) 663static void hist_hit(struct hist_entry *he, u64 ip)
664{ 664{
665 unsigned int sym_size, offset; 665 unsigned int sym_size, offset;
666 struct symbol *sym = he->sym; 666 struct symbol *sym = he->sym;
@@ -689,7 +689,7 @@ static void hist_hit(struct hist_entry *he, __u64 ip)
689 689
690static int 690static int
691hist_entry__add(struct thread *thread, struct map *map, struct dso *dso, 691hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
692 struct symbol *sym, __u64 ip, char level) 692 struct symbol *sym, u64 ip, char level)
693{ 693{
694 struct rb_node **p = &hist.rb_node; 694 struct rb_node **p = &hist.rb_node;
695 struct rb_node *parent = NULL; 695 struct rb_node *parent = NULL;
@@ -861,7 +861,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
861 int show = 0; 861 int show = 0;
862 struct dso *dso = NULL; 862 struct dso *dso = NULL;
863 struct thread *thread = threads__findnew(event->ip.pid); 863 struct thread *thread = threads__findnew(event->ip.pid);
864 __u64 ip = event->ip.ip; 864 u64 ip = event->ip.ip;
865 struct map *map = NULL; 865 struct map *map = NULL;
866 866
867 dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n", 867 dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n",
@@ -1062,14 +1062,14 @@ static char *get_color(double percent)
1062} 1062}
1063 1063
1064static int 1064static int
1065parse_line(FILE *file, struct symbol *sym, __u64 start, __u64 len) 1065parse_line(FILE *file, struct symbol *sym, u64 start, u64 len)
1066{ 1066{
1067 char *line = NULL, *tmp, *tmp2; 1067 char *line = NULL, *tmp, *tmp2;
1068 static const char *prev_line; 1068 static const char *prev_line;
1069 static const char *prev_color; 1069 static const char *prev_color;
1070 unsigned int offset; 1070 unsigned int offset;
1071 size_t line_len; 1071 size_t line_len;
1072 __u64 line_ip; 1072 u64 line_ip;
1073 int ret; 1073 int ret;
1074 char *c; 1074 char *c;
1075 1075
@@ -1191,7 +1191,7 @@ static void free_source_line(struct symbol *sym, int len)
1191 1191
1192/* Get the filename:line for the colored entries */ 1192/* Get the filename:line for the colored entries */
1193static void 1193static void
1194get_source_line(struct symbol *sym, __u64 start, int len, char *filename) 1194get_source_line(struct symbol *sym, u64 start, int len, char *filename)
1195{ 1195{
1196 int i; 1196 int i;
1197 char cmd[PATH_MAX * 2]; 1197 char cmd[PATH_MAX * 2];
@@ -1209,7 +1209,7 @@ get_source_line(struct symbol *sym, __u64 start, int len, char *filename)
1209 for (i = 0; i < len; i++) { 1209 for (i = 0; i < len; i++) {
1210 char *path = NULL; 1210 char *path = NULL;
1211 size_t line_len; 1211 size_t line_len;
1212 __u64 offset; 1212 u64 offset;
1213 FILE *fp; 1213 FILE *fp;
1214 1214
1215 sym_ext[i].percent = 100.0 * sym->hist[i] / sym->hist_sum; 1215 sym_ext[i].percent = 100.0 * sym->hist[i] / sym->hist_sum;
@@ -1269,7 +1269,7 @@ static void print_summary(char *filename)
1269static void annotate_sym(struct dso *dso, struct symbol *sym) 1269static void annotate_sym(struct dso *dso, struct symbol *sym)
1270{ 1270{
1271 char *filename = dso->name; 1271 char *filename = dso->name;
1272 __u64 start, end, len; 1272 u64 start, end, len;
1273 char command[PATH_MAX*2]; 1273 char command[PATH_MAX*2];
1274 FILE *file; 1274 FILE *file;
1275 1275
@@ -1297,7 +1297,7 @@ static void annotate_sym(struct dso *dso, struct symbol *sym)
1297 if (verbose >= 2) 1297 if (verbose >= 2)
1298 printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name); 1298 printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name);
1299 1299
1300 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s", (__u64)start, (__u64)end, filename); 1300 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s", (u64)start, (u64)end, filename);
1301 1301
1302 if (verbose >= 3) 1302 if (verbose >= 3)
1303 printf("doing: %s\n", command); 1303 printf("doing: %s\n", command);