Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169643
b: refs/heads/master
c: cfc10d3
h: refs/heads/master
i:
  169641: 5707c57
  169639: 61bd866
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Nov 19, 2009
1 parent 8b2bff6 commit faef681
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 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: 11ada26c78febe4662a8e848f3bff74e3200c920
refs/heads/master: cfc10d3bcc50d70f72c0f43d03eee965c726ccc0
26 changes: 21 additions & 5 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,24 @@ static size_t symbol__fprintf(struct symbol *self, FILE *fp)
self->start, self->end, self->name);
}

static void dso__set_long_name(struct dso *self, char *name)
{
self->long_name = name;
self->long_name_len = strlen(name);
}

static void dso__set_basename(struct dso *self)
{
self->short_name = basename(self->long_name);
}

struct dso *dso__new(const char *name)
{
struct dso *self = malloc(sizeof(*self) + strlen(name) + 1);

if (self != NULL) {
strcpy(self->name, name);
self->long_name = self->name;
dso__set_long_name(self, self->name);
self->short_name = self->name;
self->syms = RB_ROOT;
self->find_symbol = dso__find_symbol;
Expand Down Expand Up @@ -888,7 +899,7 @@ bool fetch_build_id_table(struct list_head *head)
continue;
have_buildid = true;
memset(&b.header, 0, sizeof(b.header));
len = strlen(pos->long_name) + 1;
len = pos->long_name_len + 1;
len = ALIGN(len, 64);
b.header.size = sizeof(b) + len;

Expand Down Expand Up @@ -1165,6 +1176,7 @@ static int dsos__load_modules_sym_dir(char *dirname, symbol_filter_t filter)
dso_name[PATH_MAX];
struct map *map;
struct rb_node *last;
char *long_name;

if (dot == NULL || strcmp(dot, ".ko"))
continue;
Expand All @@ -1179,9 +1191,11 @@ static int dsos__load_modules_sym_dir(char *dirname, symbol_filter_t filter)
snprintf(path, sizeof(path), "%s/%s",
dirname, dent->d_name);

map->dso->long_name = strdup(path);
if (map->dso->long_name == NULL)
long_name = strdup(path);
if (long_name == NULL)
goto failure;
dso__set_long_name(map->dso, long_name);
dso__set_basename(map->dso);

err = dso__load_module_sym(map->dso, map, filter);
if (err < 0)
Expand Down Expand Up @@ -1420,8 +1434,10 @@ struct dso *dsos__findnew(const char *name)

if (!dso) {
dso = dso__new(name);
if (dso != NULL)
if (dso != NULL) {
dsos__add(dso);
dso__set_basename(dso);
}
}

return dso;
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct dso {
u8 has_build_id:1;
unsigned char origin;
u8 build_id[BUILD_ID_SIZE];
u16 long_name_len;
const char *short_name;
char *long_name;
char name[0];
Expand Down

0 comments on commit faef681

Please sign in to comment.