aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-probe.c1
-rw-r--r--tools/perf/builtin-top.c13
-rw-r--r--tools/perf/util/probe-event.c2
-rw-r--r--tools/perf/util/probe-finder.c18
-rw-r--r--tools/perf/util/probe-finder.h1
-rw-r--r--tools/perf/util/symbol.c18
-rw-r--r--tools/perf/util/symbol.h3
7 files changed, 32 insertions, 24 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c30a33592340..152d6c9b1fa4 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -47,7 +47,6 @@
47#include "util/probe-event.h" 47#include "util/probe-event.h"
48 48
49#define MAX_PATH_LEN 256 49#define MAX_PATH_LEN 256
50#define MAX_PROBES 128
51 50
52/* Session management structure */ 51/* Session management structure */
53static struct { 52static struct {
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index c968bd3391e0..887ebbf5d1ff 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -464,7 +464,7 @@ static void print_sym_table(void)
464 struct sym_entry *syme, *n; 464 struct sym_entry *syme, *n;
465 struct rb_root tmp = RB_ROOT; 465 struct rb_root tmp = RB_ROOT;
466 struct rb_node *nd; 466 struct rb_node *nd;
467 int sym_width = 0, dso_width = 0, max_dso_width; 467 int sym_width = 0, dso_width = 0, dso_short_width = 0;
468 const int win_width = winsize.ws_col - 1; 468 const int win_width = winsize.ws_col - 1;
469 469
470 samples = userspace_samples = exact_samples = 0; 470 samples = userspace_samples = exact_samples = 0;
@@ -555,15 +555,20 @@ static void print_sym_table(void)
555 if (syme->map->dso->long_name_len > dso_width) 555 if (syme->map->dso->long_name_len > dso_width)
556 dso_width = syme->map->dso->long_name_len; 556 dso_width = syme->map->dso->long_name_len;
557 557
558 if (syme->map->dso->short_name_len > dso_short_width)
559 dso_short_width = syme->map->dso->short_name_len;
560
558 if (syme->name_len > sym_width) 561 if (syme->name_len > sym_width)
559 sym_width = syme->name_len; 562 sym_width = syme->name_len;
560 } 563 }
561 564
562 printed = 0; 565 printed = 0;
563 566
564 max_dso_width = winsize.ws_col - sym_width - 29; 567 if (sym_width + dso_width > winsize.ws_col - 29) {
565 if (dso_width > max_dso_width) 568 dso_width = dso_short_width;
566 dso_width = max_dso_width; 569 if (sym_width + dso_width > winsize.ws_col - 29)
570 sym_width = winsize.ws_col - dso_width - 29;
571 }
567 putchar('\n'); 572 putchar('\n');
568 if (nr_counters == 1) 573 if (nr_counters == 1)
569 printf(" samples pcnt"); 574 printf(" samples pcnt");
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 53181dbfe4a8..7c004b6ef24f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -242,7 +242,7 @@ void parse_perf_probe_event(const char *str, struct probe_point *pp,
242 242
243 /* Parse probe point */ 243 /* Parse probe point */
244 parse_perf_probe_probepoint(argv[0], pp); 244 parse_perf_probe_probepoint(argv[0], pp);
245 if (pp->file || pp->line) 245 if (pp->file || pp->line || pp->lazy_line)
246 *need_dwarf = true; 246 *need_dwarf = true;
247 247
248 /* Copy arguments and ensure return probe has no C argument */ 248 /* Copy arguments and ensure return probe has no C argument */
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 1e6c65ebbd80..c171a243d05b 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -333,8 +333,8 @@ static void show_location(Dwarf_Op *op, struct probe_finder *pf)
333 die("%u exceeds max register number.", regn); 333 die("%u exceeds max register number.", regn);
334 334
335 if (deref) 335 if (deref)
336 ret = snprintf(pf->buf, pf->len, " %s=+%ju(%s)", 336 ret = snprintf(pf->buf, pf->len, " %s=%+jd(%s)",
337 pf->var, (uintmax_t)offs, regs); 337 pf->var, (intmax_t)offs, regs);
338 else 338 else
339 ret = snprintf(pf->buf, pf->len, " %s=%s", pf->var, regs); 339 ret = snprintf(pf->buf, pf->len, " %s=%s", pf->var, regs);
340 DIE_IF(ret < 0); 340 DIE_IF(ret < 0);
@@ -352,8 +352,7 @@ static void show_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
352 if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL) 352 if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL)
353 goto error; 353 goto error;
354 /* TODO: handle more than 1 exprs */ 354 /* TODO: handle more than 1 exprs */
355 ret = dwarf_getlocation_addr(&attr, (pf->addr - pf->cu_base), 355 ret = dwarf_getlocation_addr(&attr, pf->addr, &expr, &nexpr, 1);
356 &expr, &nexpr, 1);
357 if (ret <= 0 || nexpr == 0) 356 if (ret <= 0 || nexpr == 0)
358 goto error; 357 goto error;
359 358
@@ -437,8 +436,7 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
437 436
438 /* Get the frame base attribute/ops */ 437 /* Get the frame base attribute/ops */
439 dwarf_attr(sp_die, DW_AT_frame_base, &fb_attr); 438 dwarf_attr(sp_die, DW_AT_frame_base, &fb_attr);
440 ret = dwarf_getlocation_addr(&fb_attr, (pf->addr - pf->cu_base), 439 ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
441 &pf->fb_ops, &nops, 1);
442 if (ret <= 0 || nops == 0) 440 if (ret <= 0 || nops == 0)
443 pf->fb_ops = NULL; 441 pf->fb_ops = NULL;
444 442
@@ -455,6 +453,9 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
455 /* *pf->fb_ops will be cached in libdw. Don't free it. */ 453 /* *pf->fb_ops will be cached in libdw. Don't free it. */
456 pf->fb_ops = NULL; 454 pf->fb_ops = NULL;
457 455
456 if (pp->found == MAX_PROBES)
457 die("Too many( > %d) probe point found.\n", MAX_PROBES);
458
458 pp->probes[pp->found] = strdup(tmp); 459 pp->probes[pp->found] = strdup(tmp);
459 pp->found++; 460 pp->found++;
460} 461}
@@ -641,7 +642,6 @@ static void find_probe_point_by_func(struct probe_finder *pf)
641int find_probe_point(int fd, struct probe_point *pp) 642int find_probe_point(int fd, struct probe_point *pp)
642{ 643{
643 struct probe_finder pf = {.pp = pp}; 644 struct probe_finder pf = {.pp = pp};
644 int ret;
645 Dwarf_Off off, noff; 645 Dwarf_Off off, noff;
646 size_t cuhl; 646 size_t cuhl;
647 Dwarf_Die *diep; 647 Dwarf_Die *diep;
@@ -668,10 +668,6 @@ int find_probe_point(int fd, struct probe_point *pp)
668 pf.fname = NULL; 668 pf.fname = NULL;
669 669
670 if (!pp->file || pf.fname) { 670 if (!pp->file || pf.fname) {
671 /* Save CU base address (for frame_base) */
672 ret = dwarf_lowpc(&pf.cu_die, &pf.cu_base);
673 if (ret != 0)
674 pf.cu_base = 0;
675 if (pp->function) 671 if (pp->function)
676 find_probe_point_by_func(&pf); 672 find_probe_point_by_func(&pf);
677 else if (pp->lazy_line) 673 else if (pp->lazy_line)
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index d1a651793ba6..21f7354397b4 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -71,7 +71,6 @@ struct probe_finder {
71 71
72 /* For variable searching */ 72 /* For variable searching */
73 Dwarf_Op *fb_ops; /* Frame base attribute */ 73 Dwarf_Op *fb_ops; /* Frame base attribute */
74 Dwarf_Addr cu_base; /* Current CU base address */
75 const char *var; /* Current variable name */ 74 const char *var; /* Current variable name */
76 char *buf; /* Current output buffer */ 75 char *buf; /* Current output buffer */
77 int len; /* Length of output buffer */ 76 int len; /* Length of output buffer */
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 292f941555a8..3eb9de4baef3 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -151,9 +151,17 @@ void dso__set_long_name(struct dso *self, char *name)
151 self->long_name_len = strlen(name); 151 self->long_name_len = strlen(name);
152} 152}
153 153
154static void dso__set_short_name(struct dso *self, const char *name)
155{
156 if (name == NULL)
157 return;
158 self->short_name = name;
159 self->short_name_len = strlen(name);
160}
161
154static void dso__set_basename(struct dso *self) 162static void dso__set_basename(struct dso *self)
155{ 163{
156 self->short_name = basename(self->long_name); 164 dso__set_short_name(self, basename(self->long_name));
157} 165}
158 166
159struct dso *dso__new(const char *name) 167struct dso *dso__new(const char *name)
@@ -164,7 +172,7 @@ struct dso *dso__new(const char *name)
164 int i; 172 int i;
165 strcpy(self->name, name); 173 strcpy(self->name, name);
166 dso__set_long_name(self, self->name); 174 dso__set_long_name(self, self->name);
167 self->short_name = self->name; 175 dso__set_short_name(self, self->name);
168 for (i = 0; i < MAP__NR_TYPES; ++i) 176 for (i = 0; i < MAP__NR_TYPES; ++i)
169 self->symbols[i] = self->symbol_names[i] = RB_ROOT; 177 self->symbols[i] = self->symbol_names[i] = RB_ROOT;
170 self->slen_calculated = 0; 178 self->slen_calculated = 0;
@@ -885,7 +893,6 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
885 struct kmap *kmap = self->kernel ? map__kmap(map) : NULL; 893 struct kmap *kmap = self->kernel ? map__kmap(map) : NULL;
886 struct map *curr_map = map; 894 struct map *curr_map = map;
887 struct dso *curr_dso = self; 895 struct dso *curr_dso = self;
888 size_t dso_name_len = strlen(self->short_name);
889 Elf_Data *symstrs, *secstrs; 896 Elf_Data *symstrs, *secstrs;
890 uint32_t nr_syms; 897 uint32_t nr_syms;
891 int err = -1; 898 int err = -1;
@@ -975,7 +982,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
975 char dso_name[PATH_MAX]; 982 char dso_name[PATH_MAX];
976 983
977 if (strcmp(section_name, 984 if (strcmp(section_name,
978 curr_dso->short_name + dso_name_len) == 0) 985 (curr_dso->short_name +
986 self->short_name_len)) == 0)
979 goto new_symbol; 987 goto new_symbol;
980 988
981 if (strcmp(section_name, ".text") == 0) { 989 if (strcmp(section_name, ".text") == 0) {
@@ -1770,7 +1778,7 @@ struct dso *dso__new_kernel(const char *name)
1770 struct dso *self = dso__new(name ?: "[kernel.kallsyms]"); 1778 struct dso *self = dso__new(name ?: "[kernel.kallsyms]");
1771 1779
1772 if (self != NULL) { 1780 if (self != NULL) {
1773 self->short_name = "[kernel]"; 1781 dso__set_short_name(self, "[kernel]");
1774 self->kernel = 1; 1782 self->kernel = 1;
1775 } 1783 }
1776 1784
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 5bd91d142704..0da2455d5b90 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -111,9 +111,10 @@ struct dso {
111 u8 sorted_by_name; 111 u8 sorted_by_name;
112 u8 loaded; 112 u8 loaded;
113 u8 build_id[BUILD_ID_SIZE]; 113 u8 build_id[BUILD_ID_SIZE];
114 u16 long_name_len;
115 const char *short_name; 114 const char *short_name;
116 char *long_name; 115 char *long_name;
116 u16 long_name_len;
117 u16 short_name_len;
117 char name[0]; 118 char name[0];
118}; 119};
119 120