summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-10-20 14:25:40 -0200
committerIngo Molnar <mingo@elte.hu>2009-10-20 21:12:58 +0200
commite42049926ebdcae24fdfdc8f0e3ff8f05f24a60b (patch)
treebe0a07b62070aef5edcd64d84e12e04950220590 /tools/perf/util
parented52ce2e3c33dc7626a40fa2da766d1a6460e543 (diff)
downloadblackbird-op-linux-e42049926ebdcae24fdfdc8f0e3ff8f05f24a60b.tar.gz
blackbird-op-linux-e42049926ebdcae24fdfdc8f0e3ff8f05f24a60b.zip
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')
-rw-r--r--tools/perf/util/data_map.c2
-rw-r--r--tools/perf/util/event.h8
-rw-r--r--tools/perf/util/map.c21
-rw-r--r--tools/perf/util/symbol.c56
-rw-r--r--tools/perf/util/symbol.h17
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,
if (curr_handler->sample_type_check(sample_type) < 0)
exit(-1);
- if (load_kernel() < 0) {
+ if (load_kernel(0, NULL) < 0) {
perror("failed to load kernel symbols");
return EXIT_FAILURE;
}
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)
return ip;
}
-struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen);
+struct symbol;
+
+typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
+
+struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
+ unsigned int sym_priv_size, symbol_filter_t filter,
+ int v);
struct map *map__clone(struct map *self);
int map__overlap(struct map *l, struct map *r);
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 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include "debug.h"
static inline int is_anon_memory(const char *filename)
{
@@ -19,7 +20,9 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen)
return n;
}
- struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen)
+struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
+ unsigned int sym_priv_size, symbol_filter_t filter,
+ int v)
{
struct map *self = malloc(sizeof(*self));
@@ -27,6 +30,7 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen)
const char *filename = event->filename;
char newfilename[PATH_MAX];
int anon;
+ bool new_dso;
if (cwd) {
int n = strcommon(filename, cwd, cwdlen);
@@ -49,10 +53,23 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen)
self->end = event->start + event->len;
self->pgoff = event->pgoff;
- self->dso = dsos__findnew(filename);
+ self->dso = dsos__findnew(filename, sym_priv_size, &new_dso);
if (self->dso == NULL)
goto out_delete;
+ if (new_dso) {
+ int nr = dso__load(self->dso, self, filter, v);
+
+ if (nr < 0)
+ eprintf("Failed to open %s, continuing "
+ "without symbols\n",
+ self->dso->long_name);
+ else if (nr == 0)
+ eprintf("No symbols found in %s, maybe "
+ "install a debug package?\n",
+ self->dso->long_name);
+ }
+
if (self->dso == vdso || anon)
self->map_ip = self->unmap_ip = identity__map_ip;
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 @@
#include <elf.h>
#include <sys/utsname.h>
-const char *sym_hist_filter;
-
enum dso_origin {
DSO__ORIG_KERNEL = 0,
DSO__ORIG_JAVA_JIT,
@@ -86,22 +84,16 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name,
if (!self)
return NULL;
- if (v > 2)
- printf("new symbol: %016Lx [%08lx]: %s, hist: %p\n",
- start, (unsigned long)len, name, self->hist);
-
- self->hist = NULL;
- self->hist_sum = 0;
-
- if (sym_hist_filter && !strcmp(name, sym_hist_filter))
- self->hist = calloc(sizeof(u64), len);
-
if (priv_size) {
memset(self, 0, priv_size);
self = ((void *)self) + priv_size;
}
self->start = start;
self->end = len ? start + len - 1 : start;
+
+ if (v > 2)
+ printf("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end);
+
memcpy(self->name, name, namelen);
return self;
@@ -919,7 +911,8 @@ char dso__symtab_origin(const struct dso *self)
return origin[self->origin];
}
-int dso__load(struct dso *self, struct map *map, symbol_filter_t filter, int v)
+int dso__load(struct dso *self, struct map *map,
+ symbol_filter_t filter, int v)
{
int size = PATH_MAX;
char *name = malloc(size), *build_id = NULL;
@@ -1335,33 +1328,21 @@ static struct dso *dsos__find(const char *name)
return NULL;
}
-struct dso *dsos__findnew(const char *name)
+struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size,
+ bool *is_new)
{
struct dso *dso = dsos__find(name);
- int nr;
-
- if (dso)
- return dso;
-
- dso = dso__new(name, 0);
- if (!dso)
- goto out_delete_dso;
- nr = dso__load(dso, NULL, NULL, verbose);
- if (nr < 0) {
- eprintf("Failed to open: %s\n", name);
- goto out_delete_dso;
- }
- if (!nr)
- eprintf("No symbols found in: %s, maybe install a debug package?\n", name);
-
- dsos__add(dso);
+ if (!dso) {
+ dso = dso__new(name, sym_priv_size);
+ if (dso) {
+ dsos__add(dso);
+ *is_new = true;
+ }
+ } else
+ *is_new = false;
return dso;
-
-out_delete_dso:
- dso__delete(dso);
- return NULL;
}
void dsos__fprintf(FILE *fp)
@@ -1372,9 +1353,10 @@ void dsos__fprintf(FILE *fp)
dso__fprintf(pos, fp);
}
-int load_kernel(void)
+int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter)
{
- if (dsos__load_kernel(vmlinux_name, 0, NULL, verbose, modules) <= 0)
+ if (dsos__load_kernel(vmlinux_name, sym_priv_size,
+ filter, verbose, modules) <= 0)
return -1;
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 @@
#define __PERF_SYMBOL 1
#include <linux/types.h>
+#include <stdbool.h>
#include "types.h"
#include <linux/list.h>
#include <linux/rbtree.h>
@@ -35,9 +36,6 @@ struct symbol {
struct rb_node rb_node;
u64 start;
u64 end;
- u64 hist_sum;
- u64 *hist;
- void *priv;
char name[0];
};
@@ -54,10 +52,6 @@ struct dso {
char name[0];
};
-extern const char *sym_hist_filter;
-
-typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
-
struct dso *dso__new(const char *name, unsigned int sym_priv_size);
void dso__delete(struct dso *self);
@@ -70,15 +64,16 @@ struct symbol *dso__find_symbol(struct dso *self, u64 ip);
int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size,
symbol_filter_t filter, int verbose, int modules);
-int dso__load(struct dso *self, struct map *map, symbol_filter_t filter,
- int verbose);
-struct dso *dsos__findnew(const char *name);
+struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size,
+ bool *is_new);
+int dso__load(struct dso *self, struct map *map,
+ symbol_filter_t filter, int v);
void dsos__fprintf(FILE *fp);
size_t dso__fprintf(struct dso *self, FILE *fp);
char dso__symtab_origin(const struct dso *self);
-int load_kernel(void);
+int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter);
void symbol__init(void);
OpenPOWER on IntegriCloud