diff options
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/data_map.c | 2 | ||||
-rw-r--r-- | tools/perf/util/event.h | 8 | ||||
-rw-r--r-- | tools/perf/util/map.c | 21 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 56 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 17 |
5 files changed, 52 insertions, 52 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c index 242b0555ab91..18accb8fee4d 100644 --- a/tools/perf/util/data_map.c +++ b/tools/perf/util/data_map.c | |||
@@ -130,7 +130,7 @@ int mmap_dispatch_perf_file(struct perf_header **pheader, | |||
130 | if (curr_handler->sample_type_check(sample_type) < 0) | 130 | if (curr_handler->sample_type_check(sample_type) < 0) |
131 | exit(-1); | 131 | exit(-1); |
132 | 132 | ||
133 | if (load_kernel() < 0) { | 133 | if (load_kernel(0, NULL) < 0) { |
134 | perror("failed to load kernel symbols"); | 134 | perror("failed to load kernel symbols"); |
135 | return EXIT_FAILURE; | 135 | return EXIT_FAILURE; |
136 | } | 136 | } |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 6b5be56a8271..db59c8bbe49a 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -101,7 +101,13 @@ static inline u64 identity__map_ip(struct map *map __used, u64 ip) | |||
101 | return ip; | 101 | return ip; |
102 | } | 102 | } |
103 | 103 | ||
104 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen); | 104 | struct symbol; |
105 | |||
106 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | ||
107 | |||
108 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | ||
109 | unsigned int sym_priv_size, symbol_filter_t filter, | ||
110 | int v); | ||
105 | struct map *map__clone(struct map *self); | 111 | struct map *map__clone(struct map *self); |
106 | int map__overlap(struct map *l, struct map *r); | 112 | int map__overlap(struct map *l, struct map *r); |
107 | size_t map__fprintf(struct map *self, FILE *fp); | 113 | size_t map__fprintf(struct map *self, FILE *fp); |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 4e203d144f9e..55079c0200e0 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include "debug.h" | ||
6 | 7 | ||
7 | static inline int is_anon_memory(const char *filename) | 8 | static inline int is_anon_memory(const char *filename) |
8 | { | 9 | { |
@@ -19,7 +20,9 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen) | |||
19 | return n; | 20 | return n; |
20 | } | 21 | } |
21 | 22 | ||
22 | 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, | ||
25 | int v) | ||
23 | { | 26 | { |
24 | struct map *self = malloc(sizeof(*self)); | 27 | struct map *self = malloc(sizeof(*self)); |
25 | 28 | ||
@@ -27,6 +30,7 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen) | |||
27 | const char *filename = event->filename; | 30 | const char *filename = event->filename; |
28 | char newfilename[PATH_MAX]; | 31 | char newfilename[PATH_MAX]; |
29 | int anon; | 32 | int anon; |
33 | bool new_dso; | ||
30 | 34 | ||
31 | if (cwd) { | 35 | if (cwd) { |
32 | int n = strcommon(filename, cwd, cwdlen); | 36 | int n = strcommon(filename, cwd, cwdlen); |
@@ -49,10 +53,23 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen) | |||
49 | self->end = event->start + event->len; | 53 | self->end = event->start + event->len; |
50 | self->pgoff = event->pgoff; | 54 | self->pgoff = event->pgoff; |
51 | 55 | ||
52 | self->dso = dsos__findnew(filename); | 56 | self->dso = dsos__findnew(filename, sym_priv_size, &new_dso); |
53 | if (self->dso == NULL) | 57 | if (self->dso == NULL) |
54 | goto out_delete; | 58 | goto out_delete; |
55 | 59 | ||
60 | if (new_dso) { | ||
61 | int nr = dso__load(self->dso, self, filter, v); | ||
62 | |||
63 | if (nr < 0) | ||
64 | eprintf("Failed to open %s, continuing " | ||
65 | "without symbols\n", | ||
66 | self->dso->long_name); | ||
67 | else if (nr == 0) | ||
68 | eprintf("No symbols found in %s, maybe " | ||
69 | "install a debug package?\n", | ||
70 | self->dso->long_name); | ||
71 | } | ||
72 | |||
56 | if (self->dso == vdso || anon) | 73 | if (self->dso == vdso || anon) |
57 | self->map_ip = self->unmap_ip = identity__map_ip; | 74 | self->map_ip = self->unmap_ip = identity__map_ip; |
58 | else { | 75 | else { |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 3350119f6909..0a4898480d6d 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -11,8 +11,6 @@ | |||
11 | #include <elf.h> | 11 | #include <elf.h> |
12 | #include <sys/utsname.h> | 12 | #include <sys/utsname.h> |
13 | 13 | ||
14 | const char *sym_hist_filter; | ||
15 | |||
16 | enum dso_origin { | 14 | enum dso_origin { |
17 | DSO__ORIG_KERNEL = 0, | 15 | DSO__ORIG_KERNEL = 0, |
18 | DSO__ORIG_JAVA_JIT, | 16 | DSO__ORIG_JAVA_JIT, |
@@ -86,22 +84,16 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name, | |||
86 | if (!self) | 84 | if (!self) |
87 | return NULL; | 85 | return NULL; |
88 | 86 | ||
89 | if (v > 2) | ||
90 | printf("new symbol: %016Lx [%08lx]: %s, hist: %p\n", | ||
91 | start, (unsigned long)len, name, self->hist); | ||
92 | |||
93 | self->hist = NULL; | ||
94 | self->hist_sum = 0; | ||
95 | |||
96 | if (sym_hist_filter && !strcmp(name, sym_hist_filter)) | ||
97 | self->hist = calloc(sizeof(u64), len); | ||
98 | |||
99 | if (priv_size) { | 87 | if (priv_size) { |
100 | memset(self, 0, priv_size); | 88 | memset(self, 0, priv_size); |
101 | self = ((void *)self) + priv_size; | 89 | self = ((void *)self) + priv_size; |
102 | } | 90 | } |
103 | self->start = start; | 91 | self->start = start; |
104 | self->end = len ? start + len - 1 : start; | 92 | self->end = len ? start + len - 1 : start; |
93 | |||
94 | if (v > 2) | ||
95 | printf("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); | ||
96 | |||
105 | memcpy(self->name, name, namelen); | 97 | memcpy(self->name, name, namelen); |
106 | 98 | ||
107 | return self; | 99 | return self; |
@@ -919,7 +911,8 @@ char dso__symtab_origin(const struct dso *self) | |||
919 | return origin[self->origin]; | 911 | return origin[self->origin]; |
920 | } | 912 | } |
921 | 913 | ||
922 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter, int v) | 914 | int dso__load(struct dso *self, struct map *map, |
915 | symbol_filter_t filter, int v) | ||
923 | { | 916 | { |
924 | int size = PATH_MAX; | 917 | int size = PATH_MAX; |
925 | char *name = malloc(size), *build_id = NULL; | 918 | char *name = malloc(size), *build_id = NULL; |
@@ -1335,33 +1328,21 @@ static struct dso *dsos__find(const char *name) | |||
1335 | return NULL; | 1328 | return NULL; |
1336 | } | 1329 | } |
1337 | 1330 | ||
1338 | struct dso *dsos__findnew(const char *name) | 1331 | struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size, |
1332 | bool *is_new) | ||
1339 | { | 1333 | { |
1340 | struct dso *dso = dsos__find(name); | 1334 | struct dso *dso = dsos__find(name); |
1341 | int nr; | ||
1342 | |||
1343 | if (dso) | ||
1344 | return dso; | ||
1345 | |||
1346 | dso = dso__new(name, 0); | ||
1347 | if (!dso) | ||
1348 | goto out_delete_dso; | ||
1349 | 1335 | ||
1350 | nr = dso__load(dso, NULL, NULL, verbose); | 1336 | if (!dso) { |
1351 | if (nr < 0) { | 1337 | dso = dso__new(name, sym_priv_size); |
1352 | eprintf("Failed to open: %s\n", name); | 1338 | if (dso) { |
1353 | goto out_delete_dso; | 1339 | dsos__add(dso); |
1354 | } | 1340 | *is_new = true; |
1355 | if (!nr) | 1341 | } |
1356 | eprintf("No symbols found in: %s, maybe install a debug package?\n", name); | 1342 | } else |
1357 | 1343 | *is_new = false; | |
1358 | dsos__add(dso); | ||
1359 | 1344 | ||
1360 | return dso; | 1345 | return dso; |
1361 | |||
1362 | out_delete_dso: | ||
1363 | dso__delete(dso); | ||
1364 | return NULL; | ||
1365 | } | 1346 | } |
1366 | 1347 | ||
1367 | void dsos__fprintf(FILE *fp) | 1348 | void dsos__fprintf(FILE *fp) |
@@ -1372,9 +1353,10 @@ void dsos__fprintf(FILE *fp) | |||
1372 | dso__fprintf(pos, fp); | 1353 | dso__fprintf(pos, fp); |
1373 | } | 1354 | } |
1374 | 1355 | ||
1375 | int load_kernel(void) | 1356 | int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter) |
1376 | { | 1357 | { |
1377 | if (dsos__load_kernel(vmlinux_name, 0, NULL, verbose, modules) <= 0) | 1358 | if (dsos__load_kernel(vmlinux_name, sym_priv_size, |
1359 | filter, verbose, modules) <= 0) | ||
1378 | return -1; | 1360 | return -1; |
1379 | 1361 | ||
1380 | vdso = dso__new("[vdso]", 0); | 1362 | vdso = dso__new("[vdso]", 0); |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 2e4522edeb07..c2a777de9b7e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __PERF_SYMBOL 1 | 2 | #define __PERF_SYMBOL 1 |
3 | 3 | ||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <stdbool.h> | ||
5 | #include "types.h" | 6 | #include "types.h" |
6 | #include <linux/list.h> | 7 | #include <linux/list.h> |
7 | #include <linux/rbtree.h> | 8 | #include <linux/rbtree.h> |
@@ -35,9 +36,6 @@ struct symbol { | |||
35 | struct rb_node rb_node; | 36 | struct rb_node rb_node; |
36 | u64 start; | 37 | u64 start; |
37 | u64 end; | 38 | u64 end; |
38 | u64 hist_sum; | ||
39 | u64 *hist; | ||
40 | void *priv; | ||
41 | char name[0]; | 39 | char name[0]; |
42 | }; | 40 | }; |
43 | 41 | ||
@@ -54,10 +52,6 @@ struct dso { | |||
54 | char name[0]; | 52 | char name[0]; |
55 | }; | 53 | }; |
56 | 54 | ||
57 | extern const char *sym_hist_filter; | ||
58 | |||
59 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | ||
60 | |||
61 | struct dso *dso__new(const char *name, unsigned int sym_priv_size); | 55 | struct dso *dso__new(const char *name, unsigned int sym_priv_size); |
62 | void dso__delete(struct dso *self); | 56 | void dso__delete(struct dso *self); |
63 | 57 | ||
@@ -70,15 +64,16 @@ struct symbol *dso__find_symbol(struct dso *self, u64 ip); | |||
70 | 64 | ||
71 | 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, |
72 | symbol_filter_t filter, int verbose, int modules); | 66 | symbol_filter_t filter, int verbose, int modules); |
73 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter, | 67 | struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size, |
74 | int verbose); | 68 | bool *is_new); |
75 | struct dso *dsos__findnew(const char *name); | 69 | int dso__load(struct dso *self, struct map *map, |
70 | symbol_filter_t filter, int v); | ||
76 | void dsos__fprintf(FILE *fp); | 71 | void dsos__fprintf(FILE *fp); |
77 | 72 | ||
78 | size_t dso__fprintf(struct dso *self, FILE *fp); | 73 | size_t dso__fprintf(struct dso *self, FILE *fp); |
79 | char dso__symtab_origin(const struct dso *self); | 74 | char dso__symtab_origin(const struct dso *self); |
80 | 75 | ||
81 | int load_kernel(void); | 76 | int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter); |
82 | 77 | ||
83 | void symbol__init(void); | 78 | void symbol__init(void); |
84 | 79 | ||