aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-top.c13
-rw-r--r--tools/perf/util/symbol.c18
-rw-r--r--tools/perf/util/symbol.h3
3 files changed, 24 insertions, 10 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0b719e3dde05..8364c8aba194 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -455,7 +455,7 @@ static void print_sym_table(void)
455 struct sym_entry *syme, *n; 455 struct sym_entry *syme, *n;
456 struct rb_root tmp = RB_ROOT; 456 struct rb_root tmp = RB_ROOT;
457 struct rb_node *nd; 457 struct rb_node *nd;
458 int sym_width = 0, dso_width = 0, max_dso_width; 458 int sym_width = 0, dso_width = 0, dso_short_width;
459 const int win_width = winsize.ws_col - 1; 459 const int win_width = winsize.ws_col - 1;
460 460
461 samples = userspace_samples = 0; 461 samples = userspace_samples = 0;
@@ -545,15 +545,20 @@ static void print_sym_table(void)
545 if (syme->map->dso->long_name_len > dso_width) 545 if (syme->map->dso->long_name_len > dso_width)
546 dso_width = syme->map->dso->long_name_len; 546 dso_width = syme->map->dso->long_name_len;
547 547
548 if (syme->map->dso->short_name_len > dso_short_width)
549 dso_short_width = syme->map->dso->short_name_len;
550
548 if (syme->name_len > sym_width) 551 if (syme->name_len > sym_width)
549 sym_width = syme->name_len; 552 sym_width = syme->name_len;
550 } 553 }
551 554
552 printed = 0; 555 printed = 0;
553 556
554 max_dso_width = winsize.ws_col - sym_width - 29; 557 if (sym_width + dso_width > winsize.ws_col - 29) {
555 if (dso_width > max_dso_width) 558 dso_width = dso_short_width;
556 dso_width = max_dso_width; 559 if (sym_width + dso_width > winsize.ws_col - 29)
560 sym_width = winsize.ws_col - dso_width - 29;
561 }
557 putchar('\n'); 562 putchar('\n');
558 if (nr_counters == 1) 563 if (nr_counters == 1)
559 printf(" samples pcnt"); 564 printf(" samples pcnt");
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 323c0aea0a91..c458c4a371d1 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -163,9 +163,17 @@ void dso__set_long_name(struct dso *self, char *name)
163 self->long_name_len = strlen(name); 163 self->long_name_len = strlen(name);
164} 164}
165 165
166static void dso__set_short_name(struct dso *self, const char *name)
167{
168 if (name == NULL)
169 return;
170 self->short_name = name;
171 self->short_name_len = strlen(name);
172}
173
166static void dso__set_basename(struct dso *self) 174static void dso__set_basename(struct dso *self)
167{ 175{
168 self->short_name = basename(self->long_name); 176 dso__set_short_name(self, basename(self->long_name));
169} 177}
170 178
171struct dso *dso__new(const char *name) 179struct dso *dso__new(const char *name)
@@ -176,7 +184,7 @@ struct dso *dso__new(const char *name)
176 int i; 184 int i;
177 strcpy(self->name, name); 185 strcpy(self->name, name);
178 dso__set_long_name(self, self->name); 186 dso__set_long_name(self, self->name);
179 self->short_name = self->name; 187 dso__set_short_name(self, self->name);
180 for (i = 0; i < MAP__NR_TYPES; ++i) 188 for (i = 0; i < MAP__NR_TYPES; ++i)
181 self->symbols[i] = self->symbol_names[i] = RB_ROOT; 189 self->symbols[i] = self->symbol_names[i] = RB_ROOT;
182 self->slen_calculated = 0; 190 self->slen_calculated = 0;
@@ -897,7 +905,6 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
897 struct kmap *kmap = self->kernel ? map__kmap(map) : NULL; 905 struct kmap *kmap = self->kernel ? map__kmap(map) : NULL;
898 struct map *curr_map = map; 906 struct map *curr_map = map;
899 struct dso *curr_dso = self; 907 struct dso *curr_dso = self;
900 size_t dso_name_len = strlen(self->short_name);
901 Elf_Data *symstrs, *secstrs; 908 Elf_Data *symstrs, *secstrs;
902 uint32_t nr_syms; 909 uint32_t nr_syms;
903 int err = -1; 910 int err = -1;
@@ -987,7 +994,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
987 char dso_name[PATH_MAX]; 994 char dso_name[PATH_MAX];
988 995
989 if (strcmp(section_name, 996 if (strcmp(section_name,
990 curr_dso->short_name + dso_name_len) == 0) 997 (curr_dso->short_name +
998 self->short_name_len)) == 0)
991 goto new_symbol; 999 goto new_symbol;
992 1000
993 if (strcmp(section_name, ".text") == 0) { 1001 if (strcmp(section_name, ".text") == 0) {
@@ -1782,7 +1790,7 @@ struct dso *dso__new_kernel(const char *name)
1782 struct dso *self = dso__new(name ?: "[kernel.kallsyms]"); 1790 struct dso *self = dso__new(name ?: "[kernel.kallsyms]");
1783 1791
1784 if (self != NULL) { 1792 if (self != NULL) {
1785 self->short_name = "[kernel]"; 1793 dso__set_short_name(self, "[kernel]");
1786 self->kernel = 1; 1794 self->kernel = 1;
1787 } 1795 }
1788 1796
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 280dadd32a08..f30a37428919 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -110,9 +110,10 @@ struct dso {
110 u8 sorted_by_name; 110 u8 sorted_by_name;
111 u8 loaded; 111 u8 loaded;
112 u8 build_id[BUILD_ID_SIZE]; 112 u8 build_id[BUILD_ID_SIZE];
113 u16 long_name_len;
114 const char *short_name; 113 const char *short_name;
115 char *long_name; 114 char *long_name;
115 u16 long_name_len;
116 u16 short_name_len;
116 char name[0]; 117 char name[0];
117}; 118};
118 119