Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 189081
b: refs/heads/master
c: b63be8d
h: refs/heads/master
i:
  189079: 3130ee7
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Mar 16, 2010
1 parent 70b72b3 commit f478e92
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 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: fc6ceea045031658d0b59af562369eae980b4370
refs/heads/master: b63be8d7beda7fe5879559be6f70f8e1c93109e4
13 changes: 9 additions & 4 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static void print_sym_table(void)
struct sym_entry *syme, *n;
struct rb_root tmp = RB_ROOT;
struct rb_node *nd;
int sym_width = 0, dso_width = 0, max_dso_width;
int sym_width = 0, dso_width = 0, dso_short_width;
const int win_width = winsize.ws_col - 1;

samples = userspace_samples = 0;
Expand Down Expand Up @@ -545,15 +545,20 @@ static void print_sym_table(void)
if (syme->map->dso->long_name_len > dso_width)
dso_width = syme->map->dso->long_name_len;

if (syme->map->dso->short_name_len > dso_short_width)
dso_short_width = syme->map->dso->short_name_len;

if (syme->name_len > sym_width)
sym_width = syme->name_len;
}

printed = 0;

max_dso_width = winsize.ws_col - sym_width - 29;
if (dso_width > max_dso_width)
dso_width = max_dso_width;
if (sym_width + dso_width > winsize.ws_col - 29) {
dso_width = dso_short_width;
if (sym_width + dso_width > winsize.ws_col - 29)
sym_width = winsize.ws_col - dso_width - 29;
}
putchar('\n');
if (nr_counters == 1)
printf(" samples pcnt");
Expand Down
18 changes: 13 additions & 5 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,17 @@ void dso__set_long_name(struct dso *self, char *name)
self->long_name_len = strlen(name);
}

static void dso__set_short_name(struct dso *self, const char *name)
{
if (name == NULL)
return;
self->short_name = name;
self->short_name_len = strlen(name);
}

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

struct dso *dso__new(const char *name)
Expand All @@ -176,7 +184,7 @@ struct dso *dso__new(const char *name)
int i;
strcpy(self->name, name);
dso__set_long_name(self, self->name);
self->short_name = self->name;
dso__set_short_name(self, self->name);
for (i = 0; i < MAP__NR_TYPES; ++i)
self->symbols[i] = self->symbol_names[i] = RB_ROOT;
self->slen_calculated = 0;
Expand Down Expand Up @@ -897,7 +905,6 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
struct kmap *kmap = self->kernel ? map__kmap(map) : NULL;
struct map *curr_map = map;
struct dso *curr_dso = self;
size_t dso_name_len = strlen(self->short_name);
Elf_Data *symstrs, *secstrs;
uint32_t nr_syms;
int err = -1;
Expand Down Expand Up @@ -987,7 +994,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
char dso_name[PATH_MAX];

if (strcmp(section_name,
curr_dso->short_name + dso_name_len) == 0)
(curr_dso->short_name +
self->short_name_len)) == 0)
goto new_symbol;

if (strcmp(section_name, ".text") == 0) {
Expand Down Expand Up @@ -1782,7 +1790,7 @@ struct dso *dso__new_kernel(const char *name)
struct dso *self = dso__new(name ?: "[kernel.kallsyms]");

if (self != NULL) {
self->short_name = "[kernel]";
dso__set_short_name(self, "[kernel]");
self->kernel = 1;
}

Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ struct dso {
u8 sorted_by_name;
u8 loaded;
u8 build_id[BUILD_ID_SIZE];
u16 long_name_len;
const char *short_name;
char *long_name;
u16 long_name_len;
u16 short_name_len;
char name[0];
};

Expand Down

0 comments on commit f478e92

Please sign in to comment.