Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169565
b: refs/heads/master
c: 66bd842
h: refs/heads/master
i:
  169563: 0c96107
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Oct 29, 2009
1 parent 030aca7 commit 9501c0a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 689d30187828afe1faedf050b2f7593515b90c76
refs/heads/master: 66bd8424cc05e800db384053bf7ab967e4658468
4 changes: 2 additions & 2 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
if (map != NULL) {
got_map:
ip = map->map_ip(map, ip);
sym = map->dso->find_symbol(map->dso, ip);
sym = map__find_symbol(map, ip, symbol_filter);
} else {
/*
* If this is outside of all known maps,
Expand Down Expand Up @@ -203,7 +203,7 @@ static int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, NULL, 0,
sizeof(struct sym_priv), symbol_filter);
sizeof(struct sym_priv));
struct thread *thread = threads__findnew(event->mmap.pid);

dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n",
Expand Down
4 changes: 2 additions & 2 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ resolve_symbol(struct thread *thread, struct map **mapp, u64 *ipp)
dump_printf(" ...... map: %Lx -> %Lx\n", *ipp, ip);
*ipp = ip;

return map ? map->dso->find_symbol(map->dso, ip) : NULL;
return map ? map__find_symbol(map, ip, NULL) : NULL;
}

static int call__match(struct symbol *sym)
Expand Down Expand Up @@ -751,7 +751,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
static int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, cwd, cwdlen, 0, NULL);
struct map *map = map__new(&event->mmap, cwd, cwdlen, 0);
struct thread *thread = threads__findnew(event->mmap.pid);

dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n",
Expand Down
5 changes: 2 additions & 3 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ static void event__process_sample(const event_t *self, int counter)
map = thread__find_map(thread, ip);
if (map != NULL) {
ip = map->map_ip(map, ip);
sym = map->dso->find_symbol(map->dso, ip);
sym = map__find_symbol(map, ip, symbol_filter);
if (sym == NULL)
return;
userspace_samples++;
Expand Down Expand Up @@ -879,8 +879,7 @@ static void event__process_mmap(event_t *self)

if (thread != NULL) {
struct map *map = map__new(&self->mmap, NULL, 0,
sizeof(struct sym_entry),
symbol_filter);
sizeof(struct sym_entry));
if (map != NULL)
thread__insert_map(thread, map);
}
Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/perf/util/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ 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);
unsigned int sym_priv_size);
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);
struct symbol *map__find_symbol(struct map *self, u64 ip, symbol_filter_t filter);

int event__synthesize_thread(pid_t pid, int (*process)(event_t *event));
void event__synthesize_threads(int (*process)(event_t *event));
Expand Down
38 changes: 22 additions & 16 deletions trunk/tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ static int strcommon(const char *pathname, 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)
unsigned int sym_priv_size)
{
struct map *self = malloc(sizeof(*self));

if (self != NULL) {
const char *filename = event->filename;
char newfilename[PATH_MAX];
int anon;
bool new_dso;

if (cwd) {
int n = strcommon(filename, cwd, cwdlen);
Expand All @@ -52,23 +51,10 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
self->end = event->start + event->len;
self->pgoff = event->pgoff;

self->dso = dsos__findnew(filename, sym_priv_size, &new_dso);
self->dso = dsos__findnew(filename, sym_priv_size);
if (self->dso == NULL)
goto out_delete;

if (new_dso) {
int nr = dso__load(self->dso, self, filter);

if (nr < 0)
pr_warning("Failed to open %s, continuing "
"without symbols\n",
self->dso->long_name);
else if (nr == 0)
pr_warning("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 {
Expand All @@ -82,6 +68,26 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
return NULL;
}

struct symbol *
map__find_symbol(struct map *self, u64 ip, symbol_filter_t filter)
{
if (!self->dso->loaded) {
int nr = dso__load(self->dso, self, filter);

if (nr < 0) {
pr_warning("Failed to open %s, continuing without symbols\n",
self->dso->long_name);
return NULL;
} else if (nr == 0) {
pr_warning("No symbols found in %s, maybe install a debug package?\n",
self->dso->long_name);
return NULL;
}
}

return self->dso->find_symbol(self->dso, ip);
}

struct map *map__clone(struct map *self)
{
struct map *map = malloc(sizeof(*self));
Expand Down
16 changes: 9 additions & 7 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
int ret = -1;
int fd;

self->loaded = true;

if (!name)
return -1;

Expand Down Expand Up @@ -1019,6 +1021,8 @@ static int dso__load_module_sym(struct dso *self, struct map *map,
{
int err = 0, fd = open(self->long_name, O_RDONLY);

self->loaded = true;

if (fd < 0) {
pr_err("%s: cannot open %s\n", __func__, self->long_name);
return err;
Expand Down Expand Up @@ -1214,6 +1218,8 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
{
int err, fd = open(vmlinux, O_RDONLY);

self->loaded = true;

if (fd < 0)
return -1;

Expand Down Expand Up @@ -1312,19 +1318,15 @@ static struct dso *dsos__find(const char *name)
return NULL;
}

struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size,
bool *is_new)
struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size)
{
struct dso *dso = dsos__find(name);

if (!dso) {
dso = dso__new(name, sym_priv_size);
if (dso) {
if (dso != NULL)
dsos__add(dso);
*is_new = true;
}
} else
*is_new = false;
}

return dso;
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct dso {
unsigned int sym_priv_size;
unsigned char adjust_symbols;
unsigned char slen_calculated;
bool loaded;
unsigned char origin;
const char *short_name;
char *long_name;
Expand All @@ -64,8 +65,7 @@ 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 modules);
struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size,
bool *is_new);
struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size);
int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
void dsos__fprintf(FILE *fp);

Expand Down

0 comments on commit 9501c0a

Please sign in to comment.