Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147530
b: refs/heads/master
c: f17e04a
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 26, 2009
1 parent 9121cb9 commit 1e8a94f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 53 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: db20c0031288ff524d82b1f240f35f85d4a052eb
refs/heads/master: f17e04afaff84b5cfd317da29ac4d764908ff833
2 changes: 1 addition & 1 deletion trunk/Documentation/perf_counter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')

# CFLAGS and LDFLAGS are for the users to override from the command line.

CFLAGS = -g -O2 -Wall
CFLAGS = -ggdb3 -Wall
LDFLAGS = -lpthread -lrt -lelf
ALL_CFLAGS = $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
Expand Down
72 changes: 21 additions & 51 deletions trunk/Documentation/perf_counter/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,6 @@ typedef union event_union {
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;
Expand Down Expand Up @@ -116,7 +88,6 @@ static size_t symbol__fprintf(struct symbol *self, FILE *fp)

struct dso {
struct list_head node;
struct list_head sections;
struct rb_root syms;
char name[0];
};
Expand All @@ -127,21 +98,12 @@ static struct dso *dso__new(const char *name)

if (self != NULL) {
strcpy(self->name, name);
INIT_LIST_HEAD(&self->sections);
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;
Expand All @@ -156,7 +118,6 @@ static void dso__delete_symbols(struct dso *self)

static void dso__delete(struct dso *self)
{
dso__delete_sections(self);
dso__delete_symbols(self);
free(self);
}
Expand Down Expand Up @@ -282,9 +243,6 @@ static int dso__load(struct dso *self)
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;
Expand All @@ -302,11 +260,21 @@ static int dso__load(struct dso *self)
GElf_Sym sym;
uint32_t index;
elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
struct symbol *f;

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);
Expand Down Expand Up @@ -498,7 +466,7 @@ static size_t symhist__fprintf(struct symhist *self, FILE *fp)
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);
}
Expand Down Expand Up @@ -714,6 +682,7 @@ static int __cmd_report(void)
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",
Expand All @@ -728,19 +697,20 @@ static int __cmd_report(void)
} 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) {
dso = map->dso;
ip -= map->start + map->pgoff;
}
} 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;
}
Expand Down

0 comments on commit 1e8a94f

Please sign in to comment.