diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-22 20:37:02 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-22 23:41:57 -0200 |
commit | 9486aa38771661e96fbb51c549b9901b5df609d8 (patch) | |
tree | 72cecbff0cb5124c960feeec3a6ac1fff75c649a /tools/perf/util | |
parent | 57b84e53171ce672683faf1cab2e660965a6bdaf (diff) |
perf tools: Fix 64 bit integer format strings
Using %L[uxd] has issues in some architectures, like on ppc64. Fix it
by making our 64 bit integers typedefs of stdint.h types and using
PRI[ux]64 like, for instance, git does.
Reported by Denis Kirjanov that provided a patch for one case, I went
and changed all cases.
Reported-by: Denis Kirjanov <dkirjanov@kernel.org>
Tested-by: Denis Kirjanov <dkirjanov@kernel.org>
LKML-Reference: <20110120093246.GA8031@hera.kernel.org>
Cc: Denis Kirjanov <dkirjanov@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Pingtian Han <phan@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/event.c | 5 | ||||
-rw-r--r-- | tools/perf/util/header.c | 4 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 17 | ||||
-rw-r--r-- | tools/perf/util/map.c | 3 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 2 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 2 | ||||
-rw-r--r-- | tools/perf/util/session.c | 28 | ||||
-rw-r--r-- | tools/perf/util/svghelper.c | 5 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 9 | ||||
-rw-r--r-- | tools/perf/util/types.h | 10 | ||||
-rw-r--r-- | tools/perf/util/ui/browsers/hists.c | 2 | ||||
-rw-r--r-- | tools/perf/util/ui/browsers/map.c | 5 | ||||
-rw-r--r-- | tools/perf/util/values.c | 10 |
13 files changed, 56 insertions, 46 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 2302ec051bb4..1478ab4ee222 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -459,7 +459,8 @@ int event__process_comm(event_t *self, struct sample_data *sample __used, int event__process_lost(event_t *self, struct sample_data *sample __used, struct perf_session *session) { - dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); + dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n", + self->lost.id, self->lost.lost); session->hists.stats.total_lost += self->lost.lost; return 0; } @@ -575,7 +576,7 @@ int event__process_mmap(event_t *self, struct sample_data *sample __used, u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; int ret = 0; - dump_printf(" %d/%d: [%#Lx(%#Lx) @ %#Lx]: %s\n", + dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n", self->mmap.pid, self->mmap.tid, self->mmap.start, self->mmap.len, self->mmap.pgoff, self->mmap.filename); diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 989fa2dee2fd..f6a929e74981 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -798,8 +798,8 @@ static int perf_file_section__process(struct perf_file_section *self, int feat, int fd) { if (lseek(fd, self->offset, SEEK_SET) == (off_t)-1) { - pr_debug("Failed to lseek to %Ld offset for feature %d, " - "continuing...\n", self->offset, feat); + pr_debug("Failed to lseek to %" PRIu64 " offset for feature " + "%d, continuing...\n", self->offset, feat); return 0; } diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index c749ba6136a0..32f4f1f2f6e4 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -636,13 +636,13 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size, } } } else - ret = snprintf(s, size, sep ? "%lld" : "%12lld ", period); + ret = snprintf(s, size, sep ? "%" PRIu64 : "%12" PRIu64 " ", period); if (symbol_conf.show_nr_samples) { if (sep) - ret += snprintf(s + ret, size - ret, "%c%lld", *sep, period); + ret += snprintf(s + ret, size - ret, "%c%" PRIu64, *sep, period); else - ret += snprintf(s + ret, size - ret, "%11lld", period); + ret += snprintf(s + ret, size - ret, "%11" PRIu64, period); } if (pair_hists) { @@ -971,7 +971,7 @@ int hist_entry__inc_addr_samples(struct hist_entry *self, u64 ip) sym_size = sym->end - sym->start; offset = ip - sym->start; - pr_debug3("%s: ip=%#Lx\n", __func__, self->ms.map->unmap_ip(self->ms.map, ip)); + pr_debug3("%s: ip=%#" PRIx64 "\n", __func__, self->ms.map->unmap_ip(self->ms.map, ip)); if (offset >= sym_size) return 0; @@ -980,8 +980,9 @@ int hist_entry__inc_addr_samples(struct hist_entry *self, u64 ip) h->sum++; h->ip[offset]++; - pr_debug3("%#Lx %s: period++ [ip: %#Lx, %#Lx] => %Ld\n", self->ms.sym->start, - self->ms.sym->name, ip, ip - self->ms.sym->start, h->ip[offset]); + pr_debug3("%#" PRIx64 " %s: period++ [ip: %#" PRIx64 ", %#" PRIx64 + "] => %" PRIu64 "\n", self->ms.sym->start, self->ms.sym->name, + ip, ip - self->ms.sym->start, h->ip[offset]); return 0; } @@ -1132,7 +1133,7 @@ fallback: goto out_free_filename; } - pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__, + pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__, filename, sym->name, map->unmap_ip(map, sym->start), map->unmap_ip(map, sym->end)); @@ -1142,7 +1143,7 @@ fallback: dso, dso->long_name, sym, sym->name); snprintf(command, sizeof(command), - "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS -C %s|grep -v %s|expand", + "objdump --start-address=0x%016" PRIx64 " --stop-address=0x%016" PRIx64 " -dS -C %s|grep -v %s|expand", map__rip_2objdump(map, sym->start), map__rip_2objdump(map, sym->end), symfs_filename, filename); diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 3a7eb6ec0eec..a16ecab5229d 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -1,5 +1,6 @@ #include "symbol.h" #include <errno.h> +#include <inttypes.h> #include <limits.h> #include <stdlib.h> #include <string.h> @@ -195,7 +196,7 @@ int map__overlap(struct map *l, struct map *r) size_t map__fprintf(struct map *self, FILE *fp) { - return fprintf(fp, " %Lx-%Lx %Lx %s\n", + return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n", self->start, self->end, self->pgoff, self->dso->name); } diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index bc2732ee23eb..135f69baf966 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -279,7 +279,7 @@ const char *__event_name(int type, u64 config) static char buf[32]; if (type == PERF_TYPE_RAW) { - sprintf(buf, "raw 0x%llx", config); + sprintf(buf, "raw 0x%" PRIx64, config); return buf; } diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 128aaab0aeda..6e29d9c9dccc 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -172,7 +172,7 @@ static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp, sym = __find_kernel_function_by_name(tp->symbol, &map); if (sym) { addr = map->unmap_ip(map, sym->start + tp->offset); - pr_debug("try to find %s+%ld@%llx\n", tp->symbol, + pr_debug("try to find %s+%ld@%" PRIx64 "\n", tp->symbol, tp->offset, addr); ret = find_perf_probe_point((unsigned long)addr, pp); } diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 313dac2d94ce..105f00bfd555 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -652,10 +652,11 @@ static void callchain__printf(struct sample_data *sample) { unsigned int i; - printf("... chain: nr:%Lu\n", sample->callchain->nr); + printf("... chain: nr:%" PRIu64 "\n", sample->callchain->nr); for (i = 0; i < sample->callchain->nr; i++) - printf("..... %2d: %016Lx\n", i, sample->callchain->ips[i]); + printf("..... %2d: %016" PRIx64 "\n", + i, sample->callchain->ips[i]); } static void perf_session__print_tstamp(struct perf_session *session, @@ -672,7 +673,7 @@ static void perf_session__print_tstamp(struct perf_session *session, printf("%u ", sample->cpu); if (session->sample_type & PERF_SAMPLE_TIME) - printf("%Lu ", sample->time); + printf("%" PRIu64 " ", sample->time); } static void dump_event(struct perf_session *session, event_t *event, @@ -681,16 +682,16 @@ static void dump_event(struct perf_session *session, event_t *event, if (!dump_trace) return; - printf("\n%#Lx [%#x]: event: %d\n", file_offset, event->header.size, - event->header.type); + printf("\n%#" PRIx64 " [%#x]: event: %d\n", + file_offset, event->header.size, event->header.type); trace_event(event); if (sample) perf_session__print_tstamp(session, event, sample); - printf("%#Lx [%#x]: PERF_RECORD_%s", file_offset, event->header.size, - event__get_event_name(event->header.type)); + printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset, + event->header.size, event__get_event_name(event->header.type)); } static void dump_sample(struct perf_session *session, event_t *event, @@ -699,8 +700,9 @@ static void dump_sample(struct perf_session *session, event_t *event, if (!dump_trace) return; - printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc, - sample->pid, sample->tid, sample->ip, sample->period); + printf("(IP, %d): %d/%d: %#" PRIx64 " period: %" PRIu64 "\n", + event->header.misc, sample->pid, sample->tid, sample->ip, + sample->period); if (session->sample_type & PERF_SAMPLE_CALLCHAIN) callchain__printf(sample); @@ -843,8 +845,8 @@ static void perf_session__warn_about_errors(const struct perf_session *session, { if (ops->lost == event__process_lost && session->hists.stats.total_lost != 0) { - ui__warning("Processed %Lu events and LOST %Lu!\n\n" - "Check IO/CPU overload!\n\n", + ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64 + "!\n\nCheck IO/CPU overload!\n\n", session->hists.stats.total_period, session->hists.stats.total_lost); } @@ -918,7 +920,7 @@ more: if (size == 0 || (skip = perf_session__process_event(self, &event, ops, head)) < 0) { - dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n", + dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n", head, event.header.size, event.header.type); /* * assume we lost track of the stream, check alignment, and @@ -1023,7 +1025,7 @@ more: if (size == 0 || perf_session__process_event(session, event, ops, file_pos) < 0) { - dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n", + dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n", file_offset + head, event->header.size, event->header.type); /* diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index b3637db025a2..805220afc083 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c @@ -12,6 +12,7 @@ * of the License. */ +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -94,7 +95,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end) total_height = (1 + rows + cpu2slot(cpus)) * SLOT_MULT; fprintf(svgfile, "<?xml version=\"1.0\" standalone=\"no\"?> \n"); - fprintf(svgfile, "<svg width=\"%i\" height=\"%llu\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", svg_page_width, total_height); + fprintf(svgfile, "<svg width=\"%i\" height=\"%" PRIu64 "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", svg_page_width, total_height); fprintf(svgfile, "<defs>\n <style type=\"text/css\">\n <![CDATA[\n"); @@ -483,7 +484,7 @@ void svg_time_grid(void) color = 128; } - fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%llu\" style=\"stroke:rgb(%i,%i,%i);stroke-width:%1.3f\"/>\n", + fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%" PRIu64 "\" style=\"stroke:rgb(%i,%i,%i);stroke-width:%1.3f\"/>\n", time2pixels(i), SLOT_MULT/2, time2pixels(i), total_height, color, color, color, thickness); i += 10000000; diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index e32478effed8..7821d0e6866f 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -11,6 +11,7 @@ #include <sys/param.h> #include <fcntl.h> #include <unistd.h> +#include <inttypes.h> #include "build-id.h" #include "debug.h" #include "symbol.h" @@ -153,7 +154,7 @@ static struct symbol *symbol__new(u64 start, u64 len, u8 binding, self->binding = binding; self->namelen = namelen - 1; - pr_debug4("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); + pr_debug4("%s: %s %#" PRIx64 "-%#" PRIx64 "\n", __func__, name, start, self->end); memcpy(self->name, name, namelen); @@ -167,7 +168,7 @@ void symbol__delete(struct symbol *self) static size_t symbol__fprintf(struct symbol *self, FILE *fp) { - return fprintf(fp, " %llx-%llx %c %s\n", + return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %c %s\n", self->start, self->end, self->binding == STB_GLOBAL ? 'g' : self->binding == STB_LOCAL ? 'l' : 'w', @@ -1215,8 +1216,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, } if (curr_dso->adjust_symbols) { - pr_debug4("%s: adjusting symbol: st_value: %#Lx " - "sh_addr: %#Lx sh_offset: %#Lx\n", __func__, + pr_debug4("%s: adjusting symbol: st_value: %#" PRIx64 " " + "sh_addr: %#" PRIx64 " sh_offset: %#" PRIx64 "\n", __func__, (u64)sym.st_value, (u64)shdr.sh_addr, (u64)shdr.sh_offset); sym.st_value -= shdr.sh_addr - shdr.sh_offset; diff --git a/tools/perf/util/types.h b/tools/perf/util/types.h index 7d6b8331f898..5f3689a3d085 100644 --- a/tools/perf/util/types.h +++ b/tools/perf/util/types.h @@ -1,12 +1,14 @@ #ifndef __PERF_TYPES_H #define __PERF_TYPES_H +#include <stdint.h> + /* - * We define u64 as unsigned long long for every architecture - * so that we can print it with %Lx without getting warnings. + * We define u64 as uint64_t for every architecture + * so that we can print it with "%"PRIx64 without getting warnings. */ -typedef unsigned long long u64; -typedef signed long long s64; +typedef uint64_t u64; +typedef int64_t s64; typedef unsigned int u32; typedef signed int s32; typedef unsigned short u16; diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c index ebda8c3fde9e..60c463c16028 100644 --- a/tools/perf/util/ui/browsers/hists.c +++ b/tools/perf/util/ui/browsers/hists.c @@ -350,7 +350,7 @@ static char *callchain_list__sym_name(struct callchain_list *self, if (self->ms.sym) return self->ms.sym->name; - snprintf(bf, bfsize, "%#Lx", self->ip); + snprintf(bf, bfsize, "%#" PRIx64, self->ip); return bf; } diff --git a/tools/perf/util/ui/browsers/map.c b/tools/perf/util/ui/browsers/map.c index e35437dfa5b4..e5158369106e 100644 --- a/tools/perf/util/ui/browsers/map.c +++ b/tools/perf/util/ui/browsers/map.c @@ -1,5 +1,6 @@ #include "../libslang.h" #include <elf.h> +#include <inttypes.h> #include <sys/ttydefaults.h> #include <ctype.h> #include <string.h> @@ -57,7 +58,7 @@ static void map_browser__write(struct ui_browser *self, void *nd, int row) int width; ui_browser__set_percent_color(self, 0, current_entry); - slsmg_printf("%*llx %*llx %c ", + slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", mb->addrlen, sym->start, mb->addrlen, sym->end, sym->binding == STB_GLOBAL ? 'g' : sym->binding == STB_LOCAL ? 'l' : 'w'); @@ -150,6 +151,6 @@ int map__browse(struct map *self) ++mb.b.nr_entries; } - mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr); + mb.addrlen = snprintf(tmp, sizeof(tmp), "%" PRIx64, maxaddr); return map_browser__run(&mb); } diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c index cfa55d686e3b..bdd33470b235 100644 --- a/tools/perf/util/values.c +++ b/tools/perf/util/values.c @@ -150,7 +150,7 @@ static void perf_read_values__display_pretty(FILE *fp, if (width > tidwidth) tidwidth = width; for (j = 0; j < values->counters; j++) { - width = snprintf(NULL, 0, "%Lu", values->value[i][j]); + width = snprintf(NULL, 0, "%" PRIu64, values->value[i][j]); if (width > counterwidth[j]) counterwidth[j] = width; } @@ -165,7 +165,7 @@ static void perf_read_values__display_pretty(FILE *fp, fprintf(fp, " %*d %*d", pidwidth, values->pid[i], tidwidth, values->tid[i]); for (j = 0; j < values->counters; j++) - fprintf(fp, " %*Lu", + fprintf(fp, " %*" PRIu64, counterwidth[j], values->value[i][j]); fprintf(fp, "\n"); } @@ -196,13 +196,13 @@ static void perf_read_values__display_raw(FILE *fp, width = strlen(values->countername[j]); if (width > namewidth) namewidth = width; - width = snprintf(NULL, 0, "%llx", values->counterrawid[j]); + width = snprintf(NULL, 0, "%" PRIx64, values->counterrawid[j]); if (width > rawwidth) rawwidth = width; } for (i = 0; i < values->threads; i++) { for (j = 0; j < values->counters; j++) { - width = snprintf(NULL, 0, "%Lu", values->value[i][j]); + width = snprintf(NULL, 0, "%" PRIu64, values->value[i][j]); if (width > countwidth) countwidth = width; } @@ -214,7 +214,7 @@ static void perf_read_values__display_raw(FILE *fp, countwidth, "Count"); for (i = 0; i < values->threads; i++) for (j = 0; j < values->counters; j++) - fprintf(fp, " %*d %*d %*s %*llx %*Lu\n", + fprintf(fp, " %*d %*d %*s %*" PRIx64 " %*" PRIu64, pidwidth, values->pid[i], tidwidth, values->tid[i], namewidth, values->countername[j], |