Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147708
b: refs/heads/master
c: 80d496b
h: refs/heads/master
v: v3
  • Loading branch information
Pekka Enberg authored and Ingo Molnar committed Jun 8, 2009
1 parent 1f3d352 commit 9491f09
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 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: dab5855b12411334355ba21349a06700e4ae7a3b
refs/heads/master: 80d496be89ed7dede5abee5c057634e80a31c82d
15 changes: 14 additions & 1 deletion trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,19 @@ static uint64_t vdso__map_ip(struct map *map, uint64_t ip)
return ip;
}

static inline int is_anon_memory(const char *filename)
{
return strcmp(filename, "//anon") == 0;
}

static struct map *map__new(struct mmap_event *event)
{
struct map *self = malloc(sizeof(*self));

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

if (cwd) {
int n = strcommon(filename);
Expand All @@ -227,6 +233,13 @@ static struct map *map__new(struct mmap_event *event)
}
}

anon = is_anon_memory(filename);

if (anon) {
snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", event->pid);
filename = newfilename;
}

self->start = event->start;
self->end = event->start + event->len;
self->pgoff = event->pgoff;
Expand All @@ -235,7 +248,7 @@ static struct map *map__new(struct mmap_event *event)
if (self->dso == NULL)
goto out_delete;

if (self->dso == vdso)
if (self->dso == vdso || anon)
self->map_ip = vdso__map_ip;
else
self->map_ip = map__map_ip;
Expand Down
65 changes: 65 additions & 0 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,68 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
return -1;
}

static int dso__load_perf_map(struct dso *self, symbol_filter_t filter, int verbose)
{
char *line = NULL;
size_t n;
FILE *file;
int nr_syms = 0;

file = fopen(self->name, "r");
if (file == NULL)
goto out_failure;

while (!feof(file)) {
__u64 start, size;
struct symbol *sym;
int line_len, len;

line_len = getline(&line, &n, file);
if (line_len < 0)
break;

if (!line)
goto out_failure;

line[--line_len] = '\0'; /* \n */

len = hex2u64(line, &start);

len++;
if (len + 2 >= line_len)
continue;

len += hex2u64(line + len, &size);

len++;
if (len + 2 >= line_len)
continue;

sym = symbol__new(start, size, line + len,
self->sym_priv_size, start, verbose);

if (sym == NULL)
goto out_delete_line;

if (filter && filter(self, sym))
symbol__delete(sym, self->sym_priv_size);
else {
dso__insert_symbol(self, sym);
nr_syms++;
}
}

free(line);
fclose(file);

return nr_syms;

out_delete_line:
free(line);
out_failure:
return -1;
}

/**
* elf_symtab__for_each_symbol - iterate thru all the symbols
*
Expand Down Expand Up @@ -507,6 +569,9 @@ int dso__load(struct dso *self, symbol_filter_t filter, int verbose)
if (!name)
return -1;

if (strncmp(self->name, "/tmp/perf-", 10) == 0)
return dso__load_perf_map(self, filter, verbose);

more:
do {
switch (variant) {
Expand Down

0 comments on commit 9491f09

Please sign in to comment.