diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-10-21 15:34:06 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-23 02:22:47 -0400 |
commit | 6beba7adbe092e63dfe8d09fbd1e3ec140474a13 (patch) | |
tree | d45a3347de224513c6d3d0e1061b78641f9aaf8a /tools/perf/util | |
parent | 802da5f2289bbe363acef084805195c11f453c48 (diff) |
perf tools: Unify debug messages mechanisms
We were using eprintf in some places, that looks at a global
'verbose' level, and at other places passing a 'v' parameter to
specify the verbosity level, unify it by introducing
pr_{err,warning,debug,etc}, just like in the kernel.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1256153646-10097-1-git-send-email-acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/callchain.c | 2 | ||||
-rw-r--r-- | tools/perf/util/debug.c | 4 | ||||
-rw-r--r-- | tools/perf/util/debug.h | 3 | ||||
-rw-r--r-- | tools/perf/util/event.h | 3 | ||||
-rw-r--r-- | tools/perf/util/header.c | 2 | ||||
-rw-r--r-- | tools/perf/util/include/linux/kernel.h | 17 | ||||
-rw-r--r-- | tools/perf/util/map.c | 17 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 134 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 5 | ||||
-rw-r--r-- | tools/perf/util/thread.c | 6 |
10 files changed, 96 insertions, 97 deletions
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 3b8380f1b478..b3b71258272a 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -206,7 +206,7 @@ fill_node(struct callchain_node *node, struct ip_callchain *chain, | |||
206 | } | 206 | } |
207 | node->val_nr = chain->nr - start; | 207 | node->val_nr = chain->nr - start; |
208 | if (!node->val_nr) | 208 | if (!node->val_nr) |
209 | printf("Warning: empty node in callchain tree\n"); | 209 | pr_warning("Warning: empty node in callchain tree\n"); |
210 | } | 210 | } |
211 | 211 | ||
212 | static void | 212 | static void |
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index e8ca98fe0bd4..28d520d5a1fb 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -13,12 +13,12 @@ | |||
13 | int verbose = 0; | 13 | int verbose = 0; |
14 | int dump_trace = 0; | 14 | int dump_trace = 0; |
15 | 15 | ||
16 | int eprintf(const char *fmt, ...) | 16 | int eprintf(int level, const char *fmt, ...) |
17 | { | 17 | { |
18 | va_list args; | 18 | va_list args; |
19 | int ret = 0; | 19 | int ret = 0; |
20 | 20 | ||
21 | if (verbose) { | 21 | if (verbose >= level) { |
22 | va_start(args, fmt); | 22 | va_start(args, fmt); |
23 | ret = vfprintf(stderr, fmt, args); | 23 | ret = vfprintf(stderr, fmt, args); |
24 | va_end(args); | 24 | va_end(args); |
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 02d1fa1c2465..e8b18a1f87a4 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -5,7 +5,8 @@ | |||
5 | extern int verbose; | 5 | extern int verbose; |
6 | extern int dump_trace; | 6 | extern int dump_trace; |
7 | 7 | ||
8 | int eprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | 8 | int eprintf(int level, |
9 | const char *fmt, ...) __attribute__((format(printf, 2, 3))); | ||
9 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | 10 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
10 | void trace_event(event_t *event); | 11 | void trace_event(event_t *event); |
11 | 12 | ||
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index db59c8bbe49a..d972b4b0d38c 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -106,8 +106,7 @@ struct symbol; | |||
106 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | 106 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); |
107 | 107 | ||
108 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | 108 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, |
109 | unsigned int sym_priv_size, symbol_filter_t filter, | 109 | unsigned int sym_priv_size, symbol_filter_t filter); |
110 | int v); | ||
111 | struct map *map__clone(struct map *self); | 110 | struct map *map__clone(struct map *self); |
112 | int map__overlap(struct map *l, struct map *r); | 111 | int map__overlap(struct map *l, struct map *r); |
113 | size_t map__fprintf(struct map *self, FILE *fp); | 112 | size_t map__fprintf(struct map *self, FILE *fp); |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 622c60e45254..7d26659b806c 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -93,7 +93,7 @@ static struct perf_trace_event_type *events; | |||
93 | void perf_header__push_event(u64 id, const char *name) | 93 | void perf_header__push_event(u64 id, const char *name) |
94 | { | 94 | { |
95 | if (strlen(name) > MAX_EVENT_NAME) | 95 | if (strlen(name) > MAX_EVENT_NAME) |
96 | printf("Event %s will be truncated\n", name); | 96 | pr_warning("Event %s will be truncated\n", name); |
97 | 97 | ||
98 | if (!events) { | 98 | if (!events) { |
99 | events = malloc(sizeof(struct perf_trace_event_type)); | 99 | events = malloc(sizeof(struct perf_trace_event_type)); |
diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h index 4b9204d9b266..21c0274c02fa 100644 --- a/tools/perf/util/include/linux/kernel.h +++ b/tools/perf/util/include/linux/kernel.h | |||
@@ -85,4 +85,21 @@ simple_strtoul(const char *nptr, char **endptr, int base) | |||
85 | return strtoul(nptr, endptr, base); | 85 | return strtoul(nptr, endptr, base); |
86 | } | 86 | } |
87 | 87 | ||
88 | #ifndef pr_fmt | ||
89 | #define pr_fmt(fmt) fmt | ||
90 | #endif | ||
91 | |||
92 | #define pr_err(fmt, ...) \ | ||
93 | do { fprintf(stderr, pr_fmt(fmt), ##__VA_ARGS__); } while (0) | ||
94 | #define pr_warning(fmt, ...) \ | ||
95 | do { fprintf(stderr, pr_fmt(fmt), ##__VA_ARGS__); } while (0) | ||
96 | #define pr_info(fmt, ...) \ | ||
97 | do { fprintf(stderr, pr_fmt(fmt), ##__VA_ARGS__); } while (0) | ||
98 | #define pr_debug(fmt, ...) \ | ||
99 | eprintf(1, pr_fmt(fmt), ##__VA_ARGS__) | ||
100 | #define pr_debugN(n, fmt, ...) \ | ||
101 | eprintf(n, pr_fmt(fmt), ##__VA_ARGS__) | ||
102 | #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__) | ||
103 | #define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__) | ||
104 | |||
88 | #endif | 105 | #endif |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 55079c0200e0..c1c556825343 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -21,8 +21,7 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen) | |||
21 | } | 21 | } |
22 | 22 | ||
23 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | 23 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, |
24 | unsigned int sym_priv_size, symbol_filter_t filter, | 24 | unsigned int sym_priv_size, symbol_filter_t filter) |
25 | int v) | ||
26 | { | 25 | { |
27 | struct map *self = malloc(sizeof(*self)); | 26 | struct map *self = malloc(sizeof(*self)); |
28 | 27 | ||
@@ -58,16 +57,16 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | |||
58 | goto out_delete; | 57 | goto out_delete; |
59 | 58 | ||
60 | if (new_dso) { | 59 | if (new_dso) { |
61 | int nr = dso__load(self->dso, self, filter, v); | 60 | int nr = dso__load(self->dso, self, filter); |
62 | 61 | ||
63 | if (nr < 0) | 62 | if (nr < 0) |
64 | eprintf("Failed to open %s, continuing " | 63 | pr_warning("Failed to open %s, continuing " |
65 | "without symbols\n", | 64 | "without symbols\n", |
66 | self->dso->long_name); | 65 | self->dso->long_name); |
67 | else if (nr == 0) | 66 | else if (nr == 0) |
68 | eprintf("No symbols found in %s, maybe " | 67 | pr_warning("No symbols found in %s, maybe " |
69 | "install a debug package?\n", | 68 | "install a debug package?\n", |
70 | self->dso->long_name); | 69 | self->dso->long_name); |
71 | } | 70 | } |
72 | 71 | ||
73 | if (self->dso == vdso || anon) | 72 | if (self->dso == vdso || anon) |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 0a4898480d6d..8f0208ce237a 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -76,7 +76,7 @@ static void kernel_maps__fixup_end(void) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | static struct symbol *symbol__new(u64 start, u64 len, const char *name, | 78 | static struct symbol *symbol__new(u64 start, u64 len, const char *name, |
79 | unsigned int priv_size, int v) | 79 | unsigned int priv_size) |
80 | { | 80 | { |
81 | size_t namelen = strlen(name) + 1; | 81 | size_t namelen = strlen(name) + 1; |
82 | struct symbol *self = calloc(1, priv_size + sizeof(*self) + namelen); | 82 | struct symbol *self = calloc(1, priv_size + sizeof(*self) + namelen); |
@@ -91,8 +91,7 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name, | |||
91 | self->start = start; | 91 | self->start = start; |
92 | self->end = len ? start + len - 1 : start; | 92 | self->end = len ? start + len - 1 : start; |
93 | 93 | ||
94 | if (v > 2) | 94 | pr_debug3("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); |
95 | printf("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); | ||
96 | 95 | ||
97 | memcpy(self->name, name, namelen); | 96 | memcpy(self->name, name, namelen); |
98 | 97 | ||
@@ -209,7 +208,7 @@ size_t dso__fprintf(struct dso *self, FILE *fp) | |||
209 | * so that we can in the next step set the symbol ->end address and then | 208 | * so that we can in the next step set the symbol ->end address and then |
210 | * call kernel_maps__split_kallsyms. | 209 | * call kernel_maps__split_kallsyms. |
211 | */ | 210 | */ |
212 | static int kernel_maps__load_all_kallsyms(int v) | 211 | static int kernel_maps__load_all_kallsyms(void) |
213 | { | 212 | { |
214 | char *line = NULL; | 213 | char *line = NULL; |
215 | size_t n; | 214 | size_t n; |
@@ -252,7 +251,7 @@ static int kernel_maps__load_all_kallsyms(int v) | |||
252 | * Will fix up the end later, when we have all symbols sorted. | 251 | * Will fix up the end later, when we have all symbols sorted. |
253 | */ | 252 | */ |
254 | sym = symbol__new(start, 0, symbol_name, | 253 | sym = symbol__new(start, 0, symbol_name, |
255 | kernel_map->dso->sym_priv_size, v); | 254 | kernel_map->dso->sym_priv_size); |
256 | 255 | ||
257 | if (sym == NULL) | 256 | if (sym == NULL) |
258 | goto out_delete_line; | 257 | goto out_delete_line; |
@@ -300,8 +299,8 @@ static int kernel_maps__split_kallsyms(symbol_filter_t filter, int use_modules) | |||
300 | if (strcmp(map->dso->name, module)) { | 299 | if (strcmp(map->dso->name, module)) { |
301 | map = kernel_maps__find_by_dso_name(module); | 300 | map = kernel_maps__find_by_dso_name(module); |
302 | if (!map) { | 301 | if (!map) { |
303 | fputs("/proc/{kallsyms,modules} " | 302 | pr_err("/proc/{kallsyms,modules} " |
304 | "inconsistency!\n", stderr); | 303 | "inconsistency!\n"); |
305 | return -1; | 304 | return -1; |
306 | } | 305 | } |
307 | } | 306 | } |
@@ -351,10 +350,9 @@ delete_symbol: | |||
351 | } | 350 | } |
352 | 351 | ||
353 | 352 | ||
354 | static int kernel_maps__load_kallsyms(symbol_filter_t filter, | 353 | static int kernel_maps__load_kallsyms(symbol_filter_t filter, int use_modules) |
355 | int use_modules, int v) | ||
356 | { | 354 | { |
357 | if (kernel_maps__load_all_kallsyms(v)) | 355 | if (kernel_maps__load_all_kallsyms()) |
358 | return -1; | 356 | return -1; |
359 | 357 | ||
360 | dso__fixup_sym_end(kernel_map->dso); | 358 | dso__fixup_sym_end(kernel_map->dso); |
@@ -362,9 +360,9 @@ static int kernel_maps__load_kallsyms(symbol_filter_t filter, | |||
362 | return kernel_maps__split_kallsyms(filter, use_modules); | 360 | return kernel_maps__split_kallsyms(filter, use_modules); |
363 | } | 361 | } |
364 | 362 | ||
365 | static size_t kernel_maps__fprintf(FILE *fp, int v) | 363 | static size_t kernel_maps__fprintf(FILE *fp) |
366 | { | 364 | { |
367 | size_t printed = fprintf(stderr, "Kernel maps:\n"); | 365 | size_t printed = fprintf(fp, "Kernel maps:\n"); |
368 | struct rb_node *nd; | 366 | struct rb_node *nd; |
369 | 367 | ||
370 | for (nd = rb_first(&kernel_maps); nd; nd = rb_next(nd)) { | 368 | for (nd = rb_first(&kernel_maps); nd; nd = rb_next(nd)) { |
@@ -372,17 +370,17 @@ static size_t kernel_maps__fprintf(FILE *fp, int v) | |||
372 | 370 | ||
373 | printed += fprintf(fp, "Map:"); | 371 | printed += fprintf(fp, "Map:"); |
374 | printed += map__fprintf(pos, fp); | 372 | printed += map__fprintf(pos, fp); |
375 | if (v > 1) { | 373 | if (verbose > 1) { |
376 | printed += dso__fprintf(pos->dso, fp); | 374 | printed += dso__fprintf(pos->dso, fp); |
377 | printed += fprintf(fp, "--\n"); | 375 | printed += fprintf(fp, "--\n"); |
378 | } | 376 | } |
379 | } | 377 | } |
380 | 378 | ||
381 | return printed + fprintf(stderr, "END kernel maps\n"); | 379 | return printed + fprintf(fp, "END kernel maps\n"); |
382 | } | 380 | } |
383 | 381 | ||
384 | static int dso__load_perf_map(struct dso *self, struct map *map, | 382 | static int dso__load_perf_map(struct dso *self, struct map *map, |
385 | symbol_filter_t filter, int v) | 383 | symbol_filter_t filter) |
386 | { | 384 | { |
387 | char *line = NULL; | 385 | char *line = NULL; |
388 | size_t n; | 386 | size_t n; |
@@ -420,7 +418,7 @@ static int dso__load_perf_map(struct dso *self, struct map *map, | |||
420 | continue; | 418 | continue; |
421 | 419 | ||
422 | sym = symbol__new(start, size, line + len, | 420 | sym = symbol__new(start, size, line + len, |
423 | self->sym_priv_size, v); | 421 | self->sym_priv_size); |
424 | 422 | ||
425 | if (sym == NULL) | 423 | if (sym == NULL) |
426 | goto out_delete_line; | 424 | goto out_delete_line; |
@@ -534,7 +532,7 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, | |||
534 | * And always look at the original dso, not at debuginfo packages, that | 532 | * And always look at the original dso, not at debuginfo packages, that |
535 | * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS). | 533 | * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS). |
536 | */ | 534 | */ |
537 | static int dso__synthesize_plt_symbols(struct dso *self, int v) | 535 | static int dso__synthesize_plt_symbols(struct dso *self) |
538 | { | 536 | { |
539 | uint32_t nr_rel_entries, idx; | 537 | uint32_t nr_rel_entries, idx; |
540 | GElf_Sym sym; | 538 | GElf_Sym sym; |
@@ -618,7 +616,7 @@ static int dso__synthesize_plt_symbols(struct dso *self, int v) | |||
618 | "%s@plt", elf_sym__name(&sym, symstrs)); | 616 | "%s@plt", elf_sym__name(&sym, symstrs)); |
619 | 617 | ||
620 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, | 618 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, |
621 | sympltname, self->sym_priv_size, v); | 619 | sympltname, self->sym_priv_size); |
622 | if (!f) | 620 | if (!f) |
623 | goto out_elf_end; | 621 | goto out_elf_end; |
624 | 622 | ||
@@ -636,7 +634,7 @@ static int dso__synthesize_plt_symbols(struct dso *self, int v) | |||
636 | "%s@plt", elf_sym__name(&sym, symstrs)); | 634 | "%s@plt", elf_sym__name(&sym, symstrs)); |
637 | 635 | ||
638 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, | 636 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, |
639 | sympltname, self->sym_priv_size, v); | 637 | sympltname, self->sym_priv_size); |
640 | if (!f) | 638 | if (!f) |
641 | goto out_elf_end; | 639 | goto out_elf_end; |
642 | 640 | ||
@@ -654,14 +652,14 @@ out_close: | |||
654 | if (err == 0) | 652 | if (err == 0) |
655 | return nr; | 653 | return nr; |
656 | out: | 654 | out: |
657 | fprintf(stderr, "%s: problems reading %s PLT info.\n", | 655 | pr_warning("%s: problems reading %s PLT info.\n", |
658 | __func__, self->long_name); | 656 | __func__, self->long_name); |
659 | return 0; | 657 | return 0; |
660 | } | 658 | } |
661 | 659 | ||
662 | static int dso__load_sym(struct dso *self, struct map *map, const char *name, | 660 | static int dso__load_sym(struct dso *self, struct map *map, const char *name, |
663 | int fd, symbol_filter_t filter, int kernel, | 661 | int fd, symbol_filter_t filter, int kernel, |
664 | int kmodule, int v) | 662 | int kmodule) |
665 | { | 663 | { |
666 | struct map *curr_map = map; | 664 | struct map *curr_map = map; |
667 | struct dso *curr_dso = self; | 665 | struct dso *curr_dso = self; |
@@ -680,15 +678,12 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
680 | 678 | ||
681 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 679 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); |
682 | if (elf == NULL) { | 680 | if (elf == NULL) { |
683 | if (v) | 681 | pr_err("%s: cannot read %s ELF file.\n", __func__, name); |
684 | fprintf(stderr, "%s: cannot read %s ELF file.\n", | ||
685 | __func__, name); | ||
686 | goto out_close; | 682 | goto out_close; |
687 | } | 683 | } |
688 | 684 | ||
689 | if (gelf_getehdr(elf, &ehdr) == NULL) { | 685 | if (gelf_getehdr(elf, &ehdr) == NULL) { |
690 | if (v) | 686 | pr_err("%s: cannot get elf header.\n", __func__); |
691 | fprintf(stderr, "%s: cannot get elf header.\n", __func__); | ||
692 | goto out_elf_end; | 687 | goto out_elf_end; |
693 | } | 688 | } |
694 | 689 | ||
@@ -794,10 +789,9 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
794 | } | 789 | } |
795 | 790 | ||
796 | if (curr_dso->adjust_symbols) { | 791 | if (curr_dso->adjust_symbols) { |
797 | if (v > 2) | 792 | pr_debug2("adjusting symbol: st_value: %Lx sh_addr: " |
798 | printf("adjusting symbol: st_value: %Lx sh_addr: %Lx sh_offset: %Lx\n", | 793 | "%Lx sh_offset: %Lx\n", (u64)sym.st_value, |
799 | (u64)sym.st_value, (u64)shdr.sh_addr, (u64)shdr.sh_offset); | 794 | (u64)shdr.sh_addr, (u64)shdr.sh_offset); |
800 | |||
801 | sym.st_value -= shdr.sh_addr - shdr.sh_offset; | 795 | sym.st_value -= shdr.sh_addr - shdr.sh_offset; |
802 | } | 796 | } |
803 | /* | 797 | /* |
@@ -810,7 +804,7 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
810 | elf_name = demangled; | 804 | elf_name = demangled; |
811 | new_symbol: | 805 | new_symbol: |
812 | f = symbol__new(sym.st_value, sym.st_size, elf_name, | 806 | f = symbol__new(sym.st_value, sym.st_size, elf_name, |
813 | curr_dso->sym_priv_size, v); | 807 | curr_dso->sym_priv_size); |
814 | free(demangled); | 808 | free(demangled); |
815 | if (!f) | 809 | if (!f) |
816 | goto out_elf_end; | 810 | goto out_elf_end; |
@@ -837,7 +831,7 @@ out_close: | |||
837 | 831 | ||
838 | #define BUILD_ID_SIZE 128 | 832 | #define BUILD_ID_SIZE 128 |
839 | 833 | ||
840 | static char *dso__read_build_id(struct dso *self, int v) | 834 | static char *dso__read_build_id(struct dso *self) |
841 | { | 835 | { |
842 | int i; | 836 | int i; |
843 | GElf_Ehdr ehdr; | 837 | GElf_Ehdr ehdr; |
@@ -854,15 +848,13 @@ static char *dso__read_build_id(struct dso *self, int v) | |||
854 | 848 | ||
855 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 849 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); |
856 | if (elf == NULL) { | 850 | if (elf == NULL) { |
857 | if (v) | 851 | pr_err("%s: cannot read %s ELF file.\n", __func__, |
858 | fprintf(stderr, "%s: cannot read %s ELF file.\n", | 852 | self->long_name); |
859 | __func__, self->long_name); | ||
860 | goto out_close; | 853 | goto out_close; |
861 | } | 854 | } |
862 | 855 | ||
863 | if (gelf_getehdr(elf, &ehdr) == NULL) { | 856 | if (gelf_getehdr(elf, &ehdr) == NULL) { |
864 | if (v) | 857 | pr_err("%s: cannot get elf header.\n", __func__); |
865 | fprintf(stderr, "%s: cannot get elf header.\n", __func__); | ||
866 | goto out_elf_end; | 858 | goto out_elf_end; |
867 | } | 859 | } |
868 | 860 | ||
@@ -884,8 +876,7 @@ static char *dso__read_build_id(struct dso *self, int v) | |||
884 | ++raw; | 876 | ++raw; |
885 | bid += 2; | 877 | bid += 2; |
886 | } | 878 | } |
887 | if (v >= 2) | 879 | pr_debug2("%s(%s): %s\n", __func__, self->long_name, build_id); |
888 | printf("%s(%s): %s\n", __func__, self->long_name, build_id); | ||
889 | out_elf_end: | 880 | out_elf_end: |
890 | elf_end(elf); | 881 | elf_end(elf); |
891 | out_close: | 882 | out_close: |
@@ -911,8 +902,7 @@ char dso__symtab_origin(const struct dso *self) | |||
911 | return origin[self->origin]; | 902 | return origin[self->origin]; |
912 | } | 903 | } |
913 | 904 | ||
914 | int dso__load(struct dso *self, struct map *map, | 905 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter) |
915 | symbol_filter_t filter, int v) | ||
916 | { | 906 | { |
917 | int size = PATH_MAX; | 907 | int size = PATH_MAX; |
918 | char *name = malloc(size), *build_id = NULL; | 908 | char *name = malloc(size), *build_id = NULL; |
@@ -925,7 +915,7 @@ int dso__load(struct dso *self, struct map *map, | |||
925 | self->adjust_symbols = 0; | 915 | self->adjust_symbols = 0; |
926 | 916 | ||
927 | if (strncmp(self->name, "/tmp/perf-", 10) == 0) { | 917 | if (strncmp(self->name, "/tmp/perf-", 10) == 0) { |
928 | ret = dso__load_perf_map(self, map, filter, v); | 918 | ret = dso__load_perf_map(self, map, filter); |
929 | self->origin = ret > 0 ? DSO__ORIG_JAVA_JIT : | 919 | self->origin = ret > 0 ? DSO__ORIG_JAVA_JIT : |
930 | DSO__ORIG_NOT_FOUND; | 920 | DSO__ORIG_NOT_FOUND; |
931 | return ret; | 921 | return ret; |
@@ -946,7 +936,7 @@ more: | |||
946 | self->long_name); | 936 | self->long_name); |
947 | break; | 937 | break; |
948 | case DSO__ORIG_BUILDID: | 938 | case DSO__ORIG_BUILDID: |
949 | build_id = dso__read_build_id(self, v); | 939 | build_id = dso__read_build_id(self); |
950 | if (build_id != NULL) { | 940 | if (build_id != NULL) { |
951 | snprintf(name, size, | 941 | snprintf(name, size, |
952 | "/usr/lib/debug/.build-id/%.2s/%s.debug", | 942 | "/usr/lib/debug/.build-id/%.2s/%s.debug", |
@@ -967,7 +957,7 @@ more: | |||
967 | fd = open(name, O_RDONLY); | 957 | fd = open(name, O_RDONLY); |
968 | } while (fd < 0); | 958 | } while (fd < 0); |
969 | 959 | ||
970 | ret = dso__load_sym(self, map, name, fd, filter, 0, 0, v); | 960 | ret = dso__load_sym(self, map, name, fd, filter, 0, 0); |
971 | close(fd); | 961 | close(fd); |
972 | 962 | ||
973 | /* | 963 | /* |
@@ -977,7 +967,7 @@ more: | |||
977 | goto more; | 967 | goto more; |
978 | 968 | ||
979 | if (ret > 0) { | 969 | if (ret > 0) { |
980 | int nr_plt = dso__synthesize_plt_symbols(self, v); | 970 | int nr_plt = dso__synthesize_plt_symbols(self); |
981 | if (nr_plt > 0) | 971 | if (nr_plt > 0) |
982 | ret += nr_plt; | 972 | ret += nr_plt; |
983 | } | 973 | } |
@@ -1025,34 +1015,29 @@ struct map *kernel_maps__find_by_dso_name(const char *name) | |||
1025 | } | 1015 | } |
1026 | 1016 | ||
1027 | static int dso__load_module_sym(struct dso *self, struct map *map, | 1017 | static int dso__load_module_sym(struct dso *self, struct map *map, |
1028 | symbol_filter_t filter, int v) | 1018 | symbol_filter_t filter) |
1029 | { | 1019 | { |
1030 | int err = 0, fd = open(self->long_name, O_RDONLY); | 1020 | int err = 0, fd = open(self->long_name, O_RDONLY); |
1031 | 1021 | ||
1032 | if (fd < 0) { | 1022 | if (fd < 0) { |
1033 | if (v) | 1023 | pr_err("%s: cannot open %s\n", __func__, self->long_name); |
1034 | fprintf(stderr, "%s: cannot open %s\n", | ||
1035 | __func__, self->long_name); | ||
1036 | return err; | 1024 | return err; |
1037 | } | 1025 | } |
1038 | 1026 | ||
1039 | err = dso__load_sym(self, map, self->long_name, fd, filter, 0, 1, v); | 1027 | err = dso__load_sym(self, map, self->long_name, fd, filter, 0, 1); |
1040 | close(fd); | 1028 | close(fd); |
1041 | 1029 | ||
1042 | return err; | 1030 | return err; |
1043 | } | 1031 | } |
1044 | 1032 | ||
1045 | static int dsos__load_modules_sym_dir(char *dirname, | 1033 | static int dsos__load_modules_sym_dir(char *dirname, symbol_filter_t filter) |
1046 | symbol_filter_t filter, int v) | ||
1047 | { | 1034 | { |
1048 | struct dirent *dent; | 1035 | struct dirent *dent; |
1049 | int nr_symbols = 0, err; | 1036 | int nr_symbols = 0, err; |
1050 | DIR *dir = opendir(dirname); | 1037 | DIR *dir = opendir(dirname); |
1051 | 1038 | ||
1052 | if (!dir) { | 1039 | if (!dir) { |
1053 | if (v) | 1040 | pr_err("%s: cannot open %s dir\n", __func__, dirname); |
1054 | fprintf(stderr, "%s: cannot open %s dir\n", __func__, | ||
1055 | dirname); | ||
1056 | return -1; | 1041 | return -1; |
1057 | } | 1042 | } |
1058 | 1043 | ||
@@ -1066,7 +1051,7 @@ static int dsos__load_modules_sym_dir(char *dirname, | |||
1066 | 1051 | ||
1067 | snprintf(path, sizeof(path), "%s/%s", | 1052 | snprintf(path, sizeof(path), "%s/%s", |
1068 | dirname, dent->d_name); | 1053 | dirname, dent->d_name); |
1069 | err = dsos__load_modules_sym_dir(path, filter, v); | 1054 | err = dsos__load_modules_sym_dir(path, filter); |
1070 | if (err < 0) | 1055 | if (err < 0) |
1071 | goto failure; | 1056 | goto failure; |
1072 | } else { | 1057 | } else { |
@@ -1092,7 +1077,7 @@ static int dsos__load_modules_sym_dir(char *dirname, | |||
1092 | if (map->dso->long_name == NULL) | 1077 | if (map->dso->long_name == NULL) |
1093 | goto failure; | 1078 | goto failure; |
1094 | 1079 | ||
1095 | err = dso__load_module_sym(map->dso, map, filter, v); | 1080 | err = dso__load_module_sym(map->dso, map, filter); |
1096 | if (err < 0) | 1081 | if (err < 0) |
1097 | goto failure; | 1082 | goto failure; |
1098 | last = rb_last(&map->dso->syms); | 1083 | last = rb_last(&map->dso->syms); |
@@ -1119,7 +1104,7 @@ failure: | |||
1119 | return -1; | 1104 | return -1; |
1120 | } | 1105 | } |
1121 | 1106 | ||
1122 | static int dsos__load_modules_sym(symbol_filter_t filter, int v) | 1107 | static int dsos__load_modules_sym(symbol_filter_t filter) |
1123 | { | 1108 | { |
1124 | struct utsname uts; | 1109 | struct utsname uts; |
1125 | char modules_path[PATH_MAX]; | 1110 | char modules_path[PATH_MAX]; |
@@ -1130,7 +1115,7 @@ static int dsos__load_modules_sym(symbol_filter_t filter, int v) | |||
1130 | snprintf(modules_path, sizeof(modules_path), "/lib/modules/%s/kernel", | 1115 | snprintf(modules_path, sizeof(modules_path), "/lib/modules/%s/kernel", |
1131 | uts.release); | 1116 | uts.release); |
1132 | 1117 | ||
1133 | return dsos__load_modules_sym_dir(modules_path, filter, v); | 1118 | return dsos__load_modules_sym_dir(modules_path, filter); |
1134 | } | 1119 | } |
1135 | 1120 | ||
1136 | /* | 1121 | /* |
@@ -1225,15 +1210,14 @@ out_failure: | |||
1225 | } | 1210 | } |
1226 | 1211 | ||
1227 | static int dso__load_vmlinux(struct dso *self, struct map *map, | 1212 | static int dso__load_vmlinux(struct dso *self, struct map *map, |
1228 | const char *vmlinux, | 1213 | const char *vmlinux, symbol_filter_t filter) |
1229 | symbol_filter_t filter, int v) | ||
1230 | { | 1214 | { |
1231 | int err, fd = open(vmlinux, O_RDONLY); | 1215 | int err, fd = open(vmlinux, O_RDONLY); |
1232 | 1216 | ||
1233 | if (fd < 0) | 1217 | if (fd < 0) |
1234 | return -1; | 1218 | return -1; |
1235 | 1219 | ||
1236 | err = dso__load_sym(self, map, self->long_name, fd, filter, 1, 0, v); | 1220 | err = dso__load_sym(self, map, self->long_name, fd, filter, 1, 0); |
1237 | 1221 | ||
1238 | close(fd); | 1222 | close(fd); |
1239 | 1223 | ||
@@ -1241,7 +1225,7 @@ static int dso__load_vmlinux(struct dso *self, struct map *map, | |||
1241 | } | 1225 | } |
1242 | 1226 | ||
1243 | int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, | 1227 | int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, |
1244 | symbol_filter_t filter, int v, int use_modules) | 1228 | symbol_filter_t filter, int use_modules) |
1245 | { | 1229 | { |
1246 | int err = -1; | 1230 | int err = -1; |
1247 | struct dso *dso = dso__new(vmlinux, sym_priv_size); | 1231 | struct dso *dso = dso__new(vmlinux, sym_priv_size); |
@@ -1257,26 +1241,26 @@ int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, | |||
1257 | kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip; | 1241 | kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip; |
1258 | 1242 | ||
1259 | if (use_modules && dsos__load_modules(sym_priv_size) < 0) { | 1243 | if (use_modules && dsos__load_modules(sym_priv_size) < 0) { |
1260 | fprintf(stderr, "Failed to load list of modules in use! " | 1244 | pr_warning("Failed to load list of modules in use! " |
1261 | "Continuing...\n"); | 1245 | "Continuing...\n"); |
1262 | use_modules = 0; | 1246 | use_modules = 0; |
1263 | } | 1247 | } |
1264 | 1248 | ||
1265 | if (vmlinux) { | 1249 | if (vmlinux) { |
1266 | err = dso__load_vmlinux(dso, kernel_map, vmlinux, filter, v); | 1250 | err = dso__load_vmlinux(dso, kernel_map, vmlinux, filter); |
1267 | if (err > 0 && use_modules) { | 1251 | if (err > 0 && use_modules) { |
1268 | int syms = dsos__load_modules_sym(filter, v); | 1252 | int syms = dsos__load_modules_sym(filter); |
1269 | 1253 | ||
1270 | if (syms < 0) | 1254 | if (syms < 0) |
1271 | fprintf(stderr, "Failed to read module symbols!" | 1255 | pr_warning("Failed to read module symbols!" |
1272 | " Continuing...\n"); | 1256 | " Continuing...\n"); |
1273 | else | 1257 | else |
1274 | err += syms; | 1258 | err += syms; |
1275 | } | 1259 | } |
1276 | } | 1260 | } |
1277 | 1261 | ||
1278 | if (err <= 0) | 1262 | if (err <= 0) |
1279 | err = kernel_maps__load_kallsyms(filter, use_modules, v); | 1263 | err = kernel_maps__load_kallsyms(filter, use_modules); |
1280 | 1264 | ||
1281 | if (err > 0) { | 1265 | if (err > 0) { |
1282 | struct rb_node *node = rb_first(&dso->syms); | 1266 | struct rb_node *node = rb_first(&dso->syms); |
@@ -1296,8 +1280,8 @@ int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, | |||
1296 | kernel_maps__fixup_end(); | 1280 | kernel_maps__fixup_end(); |
1297 | dsos__add(dso); | 1281 | dsos__add(dso); |
1298 | 1282 | ||
1299 | if (v > 0) | 1283 | if (verbose) |
1300 | kernel_maps__fprintf(stderr, v); | 1284 | kernel_maps__fprintf(stderr); |
1301 | } | 1285 | } |
1302 | 1286 | ||
1303 | return err; | 1287 | return err; |
@@ -1355,8 +1339,8 @@ void dsos__fprintf(FILE *fp) | |||
1355 | 1339 | ||
1356 | int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter) | 1340 | int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter) |
1357 | { | 1341 | { |
1358 | if (dsos__load_kernel(vmlinux_name, sym_priv_size, | 1342 | if (dsos__load_kernel(vmlinux_name, sym_priv_size, filter, |
1359 | filter, verbose, modules) <= 0) | 1343 | modules) <= 0) |
1360 | return -1; | 1344 | return -1; |
1361 | 1345 | ||
1362 | vdso = dso__new("[vdso]", 0); | 1346 | vdso = dso__new("[vdso]", 0); |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index c2a777de9b7e..77b7b3e42417 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -63,11 +63,10 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym) | |||
63 | struct symbol *dso__find_symbol(struct dso *self, u64 ip); | 63 | struct symbol *dso__find_symbol(struct dso *self, u64 ip); |
64 | 64 | ||
65 | int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, | 65 | int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, |
66 | symbol_filter_t filter, int verbose, int modules); | 66 | symbol_filter_t filter, int modules); |
67 | struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size, | 67 | struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size, |
68 | bool *is_new); | 68 | bool *is_new); |
69 | int dso__load(struct dso *self, struct map *map, | 69 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); |
70 | symbol_filter_t filter, int v); | ||
71 | void dsos__fprintf(FILE *fp); | 70 | void dsos__fprintf(FILE *fp); |
72 | 71 | ||
73 | size_t dso__fprintf(struct dso *self, FILE *fp); | 72 | size_t dso__fprintf(struct dso *self, FILE *fp); |
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 8cb47f1d8a76..0f6d78c9863a 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -127,9 +127,9 @@ static void thread__remove_overlappings(struct thread *self, struct map *map) | |||
127 | continue; | 127 | continue; |
128 | 128 | ||
129 | if (verbose >= 2) { | 129 | if (verbose >= 2) { |
130 | printf("overlapping maps:\n"); | 130 | fputs("overlapping maps:\n", stderr); |
131 | map__fprintf(map, stdout); | 131 | map__fprintf(map, stderr); |
132 | map__fprintf(pos, stdout); | 132 | map__fprintf(pos, stderr); |
133 | } | 133 | } |
134 | 134 | ||
135 | rb_erase(&pos->rb_node, &self->maps); | 135 | rb_erase(&pos->rb_node, &self->maps); |