summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
db20c00)
[ Impact: fix DSO symbol output in perf report ]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
# CFLAGS and LDFLAGS are for the users to override from the command line.
# CFLAGS and LDFLAGS are for the users to override from the command line.
LDFLAGS = -lpthread -lrt -lelf
ALL_CFLAGS = $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
LDFLAGS = -lpthread -lrt -lelf
ALL_CFLAGS = $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
struct comm_event comm;
} event_t;
struct comm_event comm;
} event_t;
-struct section {
- struct list_head node;
- uint64_t start;
- uint64_t end;
- uint64_t offset;
- char name[0];
-};
-
-struct section *section__new(uint64_t start, uint64_t size,
- uint64_t offset, char *name)
-{
- struct section *self = malloc(sizeof(*self) + strlen(name) + 1);
-
- if (self != NULL) {
- self->start = start;
- self->end = start + size;
- self->offset = offset;
- strcpy(self->name, name);
- }
-
- return self;
-}
-
-static void section__delete(struct section *self)
-{
- free(self);
-}
-
struct symbol {
struct rb_node rb_node;
uint64_t start;
struct symbol {
struct rb_node rb_node;
uint64_t start;
struct dso {
struct list_head node;
struct dso {
struct list_head node;
- struct list_head sections;
struct rb_root syms;
char name[0];
};
struct rb_root syms;
char name[0];
};
if (self != NULL) {
strcpy(self->name, name);
if (self != NULL) {
strcpy(self->name, name);
- INIT_LIST_HEAD(&self->sections);
self->syms = RB_ROOT;
}
return self;
}
self->syms = RB_ROOT;
}
return self;
}
-static void dso__delete_sections(struct dso *self)
-{
- struct section *pos, *n;
-
- list_for_each_entry_safe(pos, n, &self->sections, node)
- section__delete(pos);
-}
-
static void dso__delete_symbols(struct dso *self)
{
struct symbol *pos;
static void dso__delete_symbols(struct dso *self)
{
struct symbol *pos;
static void dso__delete(struct dso *self)
{
static void dso__delete(struct dso *self)
{
- dso__delete_sections(self);
dso__delete_symbols(self);
free(self);
}
dso__delete_symbols(self);
free(self);
}
if (sec == NULL)
goto out_elf_end;
if (sec == NULL)
goto out_elf_end;
- if (gelf_getshdr(sec, &shdr) == NULL)
- goto out_elf_end;
-
Elf_Data *syms = elf_getdata(sec, NULL);
if (syms == NULL)
goto out_elf_end;
Elf_Data *syms = elf_getdata(sec, NULL);
if (syms == NULL)
goto out_elf_end;
GElf_Sym sym;
uint32_t index;
elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
GElf_Sym sym;
uint32_t index;
elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
if (!elf_sym__is_function(&sym))
continue;
if (!elf_sym__is_function(&sym))
continue;
- struct symbol *f = symbol__new(sym.st_value, sym.st_size,
- elf_sym__name(&sym, symstrs));
- if (f == NULL)
+
+ sec = elf_getscn(elf, sym.st_shndx);
+ if (!sec)
+ goto out_elf_end;
+
+ gelf_getshdr(sec, &shdr);
+ sym.st_value -= shdr.sh_addr - shdr.sh_offset;
+
+ f = symbol__new(sym.st_value, sym.st_size,
+ elf_sym__name(&sym, symstrs));
+ if (!f)
goto out_elf_end;
dso__insert_symbol(self, f);
goto out_elf_end;
dso__insert_symbol(self, f);
ret += fprintf(fp, "%s", self->sym ? self->sym->name: "<unknown>");
else
ret += fprintf(fp, "%s: %s",
ret += fprintf(fp, "%s", self->sym ? self->sym->name: "<unknown>");
else
ret += fprintf(fp, "%s: %s",
- self->dso ? self->dso->name : "<unknown",
+ self->dso ? self->dso->name : "<unknown>",
self->sym ? self->sym->name : "<unknown>");
return ret + fprintf(fp, ": %u\n", self->count);
}
self->sym ? self->sym->name : "<unknown>");
return ret + fprintf(fp, ": %u\n", self->count);
}
int show = 0;
struct dso *dso = NULL;
struct thread *thread = threads__findnew(event->ip.pid);
int show = 0;
struct dso *dso = NULL;
struct thread *thread = threads__findnew(event->ip.pid);
+ uint64_t ip = event->ip.ip;
if (thread == NULL) {
fprintf(stderr, "problem processing %d event, bailing out\n",
if (thread == NULL) {
fprintf(stderr, "problem processing %d event, bailing out\n",
} else if (event->header.misc & PERF_EVENT_MISC_USER) {
show = SHOW_USER;
level = '.';
} else if (event->header.misc & PERF_EVENT_MISC_USER) {
show = SHOW_USER;
level = '.';
- struct map *map = thread__find_map(thread, event->ip.ip);
- if (map != NULL)
+ struct map *map = thread__find_map(thread, ip);
+ if (map != NULL) {
+ ip -= map->start + map->pgoff;
+ }
} else {
show = SHOW_HV;
level = 'H';
}
if (show & show_mask) {
} else {
show = SHOW_HV;
level = 'H';
}
if (show & show_mask) {
- struct symbol *sym = dso__find_symbol(dso, event->ip.ip);
+ struct symbol *sym = dso__find_symbol(dso, ip);
- if (thread__symbol_incnew(thread, sym, event->ip.ip,
- dso, level)) {
+ if (thread__symbol_incnew(thread, sym, ip, dso, level)) {
fprintf(stderr, "problem incrementing symbol count, bailing out\n");
goto done;
}
fprintf(stderr, "problem incrementing symbol count, bailing out\n");
goto done;
}