diff options
| -rw-r--r-- | tools/perf/builtin-top.c | 33 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 25 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 15 |
3 files changed, 52 insertions, 21 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 57e232f13bc1..c968bd3391e0 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
| @@ -169,7 +169,7 @@ static void sig_winch_handler(int sig __used) | |||
| 169 | update_print_entries(&winsize); | 169 | update_print_entries(&winsize); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | static void parse_source(struct sym_entry *syme) | 172 | static int parse_source(struct sym_entry *syme) |
| 173 | { | 173 | { |
| 174 | struct symbol *sym; | 174 | struct symbol *sym; |
| 175 | struct sym_entry_source *source; | 175 | struct sym_entry_source *source; |
| @@ -180,12 +180,21 @@ static void parse_source(struct sym_entry *syme) | |||
| 180 | u64 len; | 180 | u64 len; |
| 181 | 181 | ||
| 182 | if (!syme) | 182 | if (!syme) |
| 183 | return; | 183 | return -1; |
| 184 | |||
| 185 | sym = sym_entry__symbol(syme); | ||
| 186 | map = syme->map; | ||
| 187 | |||
| 188 | /* | ||
| 189 | * We can't annotate with just /proc/kallsyms | ||
| 190 | */ | ||
| 191 | if (map->dso->origin == DSO__ORIG_KERNEL) | ||
| 192 | return -1; | ||
| 184 | 193 | ||
| 185 | if (syme->src == NULL) { | 194 | if (syme->src == NULL) { |
| 186 | syme->src = zalloc(sizeof(*source)); | 195 | syme->src = zalloc(sizeof(*source)); |
| 187 | if (syme->src == NULL) | 196 | if (syme->src == NULL) |
| 188 | return; | 197 | return -1; |
| 189 | pthread_mutex_init(&syme->src->lock, NULL); | 198 | pthread_mutex_init(&syme->src->lock, NULL); |
| 190 | } | 199 | } |
| 191 | 200 | ||
| @@ -195,9 +204,6 @@ static void parse_source(struct sym_entry *syme) | |||
| 195 | pthread_mutex_lock(&source->lock); | 204 | pthread_mutex_lock(&source->lock); |
| 196 | goto out_assign; | 205 | goto out_assign; |
| 197 | } | 206 | } |
| 198 | |||
| 199 | sym = sym_entry__symbol(syme); | ||
| 200 | map = syme->map; | ||
| 201 | path = map->dso->long_name; | 207 | path = map->dso->long_name; |
| 202 | 208 | ||
| 203 | len = sym->end - sym->start; | 209 | len = sym->end - sym->start; |
| @@ -209,7 +215,7 @@ static void parse_source(struct sym_entry *syme) | |||
| 209 | 215 | ||
| 210 | file = popen(command, "r"); | 216 | file = popen(command, "r"); |
| 211 | if (!file) | 217 | if (!file) |
| 212 | return; | 218 | return -1; |
| 213 | 219 | ||
| 214 | pthread_mutex_lock(&source->lock); | 220 | pthread_mutex_lock(&source->lock); |
| 215 | source->lines_tail = &source->lines; | 221 | source->lines_tail = &source->lines; |
| @@ -245,6 +251,7 @@ static void parse_source(struct sym_entry *syme) | |||
| 245 | out_assign: | 251 | out_assign: |
| 246 | sym_filter_entry = syme; | 252 | sym_filter_entry = syme; |
| 247 | pthread_mutex_unlock(&source->lock); | 253 | pthread_mutex_unlock(&source->lock); |
| 254 | return 0; | ||
| 248 | } | 255 | } |
| 249 | 256 | ||
| 250 | static void __zero_source_counters(struct sym_entry *syme) | 257 | static void __zero_source_counters(struct sym_entry *syme) |
| @@ -991,7 +998,17 @@ static void event__process_sample(const event_t *self, | |||
| 991 | if (sym_filter_entry_sched) { | 998 | if (sym_filter_entry_sched) { |
| 992 | sym_filter_entry = sym_filter_entry_sched; | 999 | sym_filter_entry = sym_filter_entry_sched; |
| 993 | sym_filter_entry_sched = NULL; | 1000 | sym_filter_entry_sched = NULL; |
| 994 | parse_source(sym_filter_entry); | 1001 | if (parse_source(sym_filter_entry) < 0) { |
| 1002 | struct symbol *sym = sym_entry__symbol(sym_filter_entry); | ||
| 1003 | |||
| 1004 | pr_err("Can't annotate %s", sym->name); | ||
| 1005 | if (sym_filter_entry->map->dso->origin == DSO__ORIG_KERNEL) { | ||
| 1006 | pr_err(": No vmlinux file was found in the path:\n"); | ||
| 1007 | vmlinux_path__fprintf(stderr); | ||
| 1008 | } else | ||
| 1009 | pr_err(".\n"); | ||
| 1010 | exit(1); | ||
| 1011 | } | ||
| 995 | } | 1012 | } |
| 996 | 1013 | ||
| 997 | syme = symbol__priv(al.sym); | 1014 | syme = symbol__priv(al.sym); |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 75cd46807c70..292f941555a8 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
| @@ -18,18 +18,6 @@ | |||
| 18 | #define NT_GNU_BUILD_ID 3 | 18 | #define NT_GNU_BUILD_ID 3 |
| 19 | #endif | 19 | #endif |
| 20 | 20 | ||
| 21 | enum dso_origin { | ||
| 22 | DSO__ORIG_KERNEL = 0, | ||
| 23 | DSO__ORIG_JAVA_JIT, | ||
| 24 | DSO__ORIG_BUILD_ID_CACHE, | ||
| 25 | DSO__ORIG_FEDORA, | ||
| 26 | DSO__ORIG_UBUNTU, | ||
| 27 | DSO__ORIG_BUILDID, | ||
| 28 | DSO__ORIG_DSO, | ||
| 29 | DSO__ORIG_KMODULE, | ||
| 30 | DSO__ORIG_NOT_FOUND, | ||
| 31 | }; | ||
| 32 | |||
| 33 | static void dsos__add(struct list_head *head, struct dso *dso); | 21 | static void dsos__add(struct list_head *head, struct dso *dso); |
| 34 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); | 22 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); |
| 35 | static int dso__load_kernel_sym(struct dso *self, struct map *map, | 23 | static int dso__load_kernel_sym(struct dso *self, struct map *map, |
| @@ -1017,7 +1005,7 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
| 1017 | } | 1005 | } |
| 1018 | curr_map->map_ip = identity__map_ip; | 1006 | curr_map->map_ip = identity__map_ip; |
| 1019 | curr_map->unmap_ip = identity__map_ip; | 1007 | curr_map->unmap_ip = identity__map_ip; |
| 1020 | curr_dso->origin = DSO__ORIG_KERNEL; | 1008 | curr_dso->origin = self->origin; |
| 1021 | map_groups__insert(kmap->kmaps, curr_map); | 1009 | map_groups__insert(kmap->kmaps, curr_map); |
| 1022 | dsos__add(&dsos__kernel, curr_dso); | 1010 | dsos__add(&dsos__kernel, curr_dso); |
| 1023 | dso__set_loaded(curr_dso, map->type); | 1011 | dso__set_loaded(curr_dso, map->type); |
| @@ -1887,6 +1875,17 @@ out_fail: | |||
| 1887 | return -1; | 1875 | return -1; |
| 1888 | } | 1876 | } |
| 1889 | 1877 | ||
| 1878 | size_t vmlinux_path__fprintf(FILE *fp) | ||
| 1879 | { | ||
| 1880 | int i; | ||
| 1881 | size_t printed = 0; | ||
| 1882 | |||
| 1883 | for (i = 0; i < vmlinux_path__nr_entries; ++i) | ||
| 1884 | printed += fprintf(fp, "[%d] %s\n", i, vmlinux_path[i]); | ||
| 1885 | |||
| 1886 | return printed; | ||
| 1887 | } | ||
| 1888 | |||
| 1890 | static int setup_list(struct strlist **list, const char *list_str, | 1889 | static int setup_list(struct strlist **list, const char *list_str, |
| 1891 | const char *list_name) | 1890 | const char *list_name) |
| 1892 | { | 1891 | { |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 280dadd32a08..d983bbaf99c5 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
| @@ -149,6 +149,19 @@ size_t dsos__fprintf_buildid(FILE *fp, bool with_hits); | |||
| 149 | 149 | ||
| 150 | size_t dso__fprintf_buildid(struct dso *self, FILE *fp); | 150 | size_t dso__fprintf_buildid(struct dso *self, FILE *fp); |
| 151 | size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp); | 151 | size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp); |
| 152 | |||
| 153 | enum dso_origin { | ||
| 154 | DSO__ORIG_KERNEL = 0, | ||
| 155 | DSO__ORIG_JAVA_JIT, | ||
| 156 | DSO__ORIG_BUILD_ID_CACHE, | ||
| 157 | DSO__ORIG_FEDORA, | ||
| 158 | DSO__ORIG_UBUNTU, | ||
| 159 | DSO__ORIG_BUILDID, | ||
| 160 | DSO__ORIG_DSO, | ||
| 161 | DSO__ORIG_KMODULE, | ||
| 162 | DSO__ORIG_NOT_FOUND, | ||
| 163 | }; | ||
| 164 | |||
| 152 | char dso__symtab_origin(const struct dso *self); | 165 | char dso__symtab_origin(const struct dso *self); |
| 153 | void dso__set_long_name(struct dso *self, char *name); | 166 | void dso__set_long_name(struct dso *self, char *name); |
| 154 | void dso__set_build_id(struct dso *self, void *build_id); | 167 | void dso__set_build_id(struct dso *self, void *build_id); |
| @@ -168,4 +181,6 @@ int kallsyms__parse(const char *filename, void *arg, | |||
| 168 | int symbol__init(void); | 181 | int symbol__init(void); |
| 169 | bool symbol_type__is_a(char symbol_type, enum map_type map_type); | 182 | bool symbol_type__is_a(char symbol_type, enum map_type map_type); |
| 170 | 183 | ||
| 184 | size_t vmlinux_path__fprintf(FILE *fp); | ||
| 185 | |||
| 171 | #endif /* __PERF_SYMBOL */ | 186 | #endif /* __PERF_SYMBOL */ |
