aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-10-20 12:25:40 -0400
committerIngo Molnar <mingo@elte.hu>2009-10-20 15:12:58 -0400
commite42049926ebdcae24fdfdc8f0e3ff8f05f24a60b (patch)
treebe0a07b62070aef5edcd64d84e12e04950220590 /tools/perf/util/symbol.c
parented52ce2e3c33dc7626a40fa2da766d1a6460e543 (diff)
perf annotate: Use the sym_priv_size area for the histogram
We have this sym_priv_size mechanism for attaching private areas to struct symbol entries but annotate wasn't using it, adding private areas to struct symbol in addition to a ->priv pointer. Scrap all that and use the sym_priv_size mechanism. 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: <1256055940-19511-1-git-send-email-acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c56
1 files changed, 19 insertions, 37 deletions
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
14const char *sym_hist_filter;
15
16enum dso_origin { 14enum 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
922int dso__load(struct dso *self, struct map *map, symbol_filter_t filter, int v) 914int 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
1338struct dso *dsos__findnew(const char *name) 1331struct 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
1362out_delete_dso:
1363 dso__delete(dso);
1364 return NULL;
1365} 1346}
1366 1347
1367void dsos__fprintf(FILE *fp) 1348void 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
1375int load_kernel(void) 1356int 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);