diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-08-05 11:59:47 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-08-05 18:38:01 -0400 |
commit | c408fedfc4a1fa16e611ffd6f3280301b38614be (patch) | |
tree | 5beaf2fe188dc724e0a494d49b389ef83a61720a /tools | |
parent | fc9ea5a1e53ee54f681e226d735008e2a6f8f470 (diff) |
perf symbols: Store the symbol binding
So that tools that wan't to act only on a subset of (weak, global,
local) symbols can do so, such as the upcoming uprobes support in 'perf
probe'.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/symbol.c | 30 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 1 |
2 files changed, 23 insertions, 8 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 6f0dd90c36ce..b6f5970f9106 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -131,7 +131,8 @@ static void map_groups__fixup_end(struct map_groups *self) | |||
131 | __map_groups__fixup_end(self, i); | 131 | __map_groups__fixup_end(self, i); |
132 | } | 132 | } |
133 | 133 | ||
134 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) | 134 | static struct symbol *symbol__new(u64 start, u64 len, u8 binding, |
135 | const char *name) | ||
135 | { | 136 | { |
136 | size_t namelen = strlen(name) + 1; | 137 | size_t namelen = strlen(name) + 1; |
137 | struct symbol *self = calloc(1, (symbol_conf.priv_size + | 138 | struct symbol *self = calloc(1, (symbol_conf.priv_size + |
@@ -144,6 +145,7 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name) | |||
144 | 145 | ||
145 | self->start = start; | 146 | self->start = start; |
146 | self->end = len ? start + len - 1 : start; | 147 | self->end = len ? start + len - 1 : start; |
148 | self->binding = binding; | ||
147 | self->namelen = namelen - 1; | 149 | self->namelen = namelen - 1; |
148 | 150 | ||
149 | pr_debug4("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); | 151 | pr_debug4("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); |
@@ -160,8 +162,11 @@ void symbol__delete(struct symbol *self) | |||
160 | 162 | ||
161 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) | 163 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) |
162 | { | 164 | { |
163 | return fprintf(fp, " %llx-%llx %s\n", | 165 | return fprintf(fp, " %llx-%llx %c %s\n", |
164 | self->start, self->end, self->name); | 166 | self->start, self->end, |
167 | self->binding == STB_GLOBAL ? 'g' : | ||
168 | self->binding == STB_LOCAL ? 'l' : 'w', | ||
169 | self->name); | ||
165 | } | 170 | } |
166 | 171 | ||
167 | void dso__set_long_name(struct dso *self, char *name) | 172 | void dso__set_long_name(struct dso *self, char *name) |
@@ -453,6 +458,14 @@ struct process_kallsyms_args { | |||
453 | struct dso *dso; | 458 | struct dso *dso; |
454 | }; | 459 | }; |
455 | 460 | ||
461 | static u8 kallsyms2elf_type(char type) | ||
462 | { | ||
463 | if (type == 'W') | ||
464 | return STB_WEAK; | ||
465 | |||
466 | return isupper(type) ? STB_GLOBAL : STB_LOCAL; | ||
467 | } | ||
468 | |||
456 | static int map__process_kallsym_symbol(void *arg, const char *name, | 469 | static int map__process_kallsym_symbol(void *arg, const char *name, |
457 | char type, u64 start) | 470 | char type, u64 start) |
458 | { | 471 | { |
@@ -466,7 +479,7 @@ static int map__process_kallsym_symbol(void *arg, const char *name, | |||
466 | /* | 479 | /* |
467 | * Will fix up the end later, when we have all symbols sorted. | 480 | * Will fix up the end later, when we have all symbols sorted. |
468 | */ | 481 | */ |
469 | sym = symbol__new(start, 0, name); | 482 | sym = symbol__new(start, 0, kallsyms2elf_type(type), name); |
470 | 483 | ||
471 | if (sym == NULL) | 484 | if (sym == NULL) |
472 | return -ENOMEM; | 485 | return -ENOMEM; |
@@ -661,7 +674,7 @@ static int dso__load_perf_map(struct dso *self, struct map *map, | |||
661 | if (len + 2 >= line_len) | 674 | if (len + 2 >= line_len) |
662 | continue; | 675 | continue; |
663 | 676 | ||
664 | sym = symbol__new(start, size, line + len); | 677 | sym = symbol__new(start, size, STB_GLOBAL, line + len); |
665 | 678 | ||
666 | if (sym == NULL) | 679 | if (sym == NULL) |
667 | goto out_delete_line; | 680 | goto out_delete_line; |
@@ -873,7 +886,7 @@ static int dso__synthesize_plt_symbols(struct dso *self, struct map *map, | |||
873 | "%s@plt", elf_sym__name(&sym, symstrs)); | 886 | "%s@plt", elf_sym__name(&sym, symstrs)); |
874 | 887 | ||
875 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, | 888 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, |
876 | sympltname); | 889 | STB_GLOBAL, sympltname); |
877 | if (!f) | 890 | if (!f) |
878 | goto out_elf_end; | 891 | goto out_elf_end; |
879 | 892 | ||
@@ -895,7 +908,7 @@ static int dso__synthesize_plt_symbols(struct dso *self, struct map *map, | |||
895 | "%s@plt", elf_sym__name(&sym, symstrs)); | 908 | "%s@plt", elf_sym__name(&sym, symstrs)); |
896 | 909 | ||
897 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, | 910 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, |
898 | sympltname); | 911 | STB_GLOBAL, sympltname); |
899 | if (!f) | 912 | if (!f) |
900 | goto out_elf_end; | 913 | goto out_elf_end; |
901 | 914 | ||
@@ -1146,7 +1159,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
1146 | if (demangled != NULL) | 1159 | if (demangled != NULL) |
1147 | elf_name = demangled; | 1160 | elf_name = demangled; |
1148 | new_symbol: | 1161 | new_symbol: |
1149 | f = symbol__new(sym.st_value, sym.st_size, elf_name); | 1162 | f = symbol__new(sym.st_value, sym.st_size, |
1163 | GELF_ST_BIND(sym.st_info), elf_name); | ||
1150 | free(demangled); | 1164 | free(demangled); |
1151 | if (!f) | 1165 | if (!f) |
1152 | goto out_elf_end; | 1166 | goto out_elf_end; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 906be20011d9..b7a8da4af5a0 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -53,6 +53,7 @@ struct symbol { | |||
53 | u64 start; | 53 | u64 start; |
54 | u64 end; | 54 | u64 end; |
55 | u16 namelen; | 55 | u16 namelen; |
56 | u8 binding; | ||
56 | char name[0]; | 57 | char name[0]; |
57 | }; | 58 | }; |
58 | 59 | ||