aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile40
-rw-r--r--tools/perf/util/hist.c29
-rw-r--r--tools/perf/util/symbol.c17
3 files changed, 53 insertions, 33 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 3d8f31ed771d..d75c28a825f5 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -600,30 +600,32 @@ endif
600 600
601ifdef NO_DEMANGLE 601ifdef NO_DEMANGLE
602 BASIC_CFLAGS += -DNO_DEMANGLE 602 BASIC_CFLAGS += -DNO_DEMANGLE
603else ifdef HAVE_CPLUS_DEMANGLE
604 EXTLIBS += -liberty
605 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
606else 603else
607 has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") 604 ifdef HAVE_CPLUS_DEMANGLE
608 605 EXTLIBS += -liberty
609 ifeq ($(has_bfd),y) 606 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
610 EXTLIBS += -lbfd
611 else 607 else
612 has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") 608 has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y")
613 ifeq ($(has_bfd_iberty),y) 609
614 EXTLIBS += -lbfd -liberty 610 ifeq ($(has_bfd),y)
611 EXTLIBS += -lbfd
615 else 612 else
616 has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") 613 has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y")
617 ifeq ($(has_bfd_iberty_z),y) 614 ifeq ($(has_bfd_iberty),y)
618 EXTLIBS += -lbfd -liberty -lz 615 EXTLIBS += -lbfd -liberty
619 else 616 else
620 has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") 617 has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y")
621 ifeq ($(has_cplus_demangle),y) 618 ifeq ($(has_bfd_iberty_z),y)
622 EXTLIBS += -liberty 619 EXTLIBS += -lbfd -liberty -lz
623 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
624 else 620 else
625 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) 621 has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y")
626 BASIC_CFLAGS += -DNO_DEMANGLE 622 ifeq ($(has_cplus_demangle),y)
623 EXTLIBS += -liberty
624 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
625 else
626 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
627 BASIC_CFLAGS += -DNO_DEMANGLE
628 endif
627 endif 629 endif
628 endif 630 endif
629 endif 631 endif
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 07f89b66b318..784ee0bdda77 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -631,9 +631,14 @@ int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists,
631 u64 session_total) 631 u64 session_total)
632{ 632{
633 char bf[512]; 633 char bf[512];
634 hist_entry__snprintf(self, bf, sizeof(bf), pair_hists, 634 int ret;
635 show_displacement, displacement, 635
636 true, session_total); 636 ret = hist_entry__snprintf(self, bf, sizeof(bf), pair_hists,
637 show_displacement, displacement,
638 true, session_total);
639 if (!ret)
640 return 0;
641
637 return fprintf(fp, "%s\n", bf); 642 return fprintf(fp, "%s\n", bf);
638} 643}
639 644
@@ -762,6 +767,7 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
762print_entries: 767print_entries:
763 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 768 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) {
764 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 769 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
770 int cnt;
765 771
766 if (show_displacement) { 772 if (show_displacement) {
767 if (h->pair != NULL) 773 if (h->pair != NULL)
@@ -771,8 +777,13 @@ print_entries:
771 displacement = 0; 777 displacement = 0;
772 ++position; 778 ++position;
773 } 779 }
774 ret += hist_entry__fprintf(h, pair, show_displacement, 780 cnt = hist_entry__fprintf(h, pair, show_displacement,
775 displacement, fp, self->stats.total_period); 781 displacement, fp, self->stats.total_period);
782 /* Ignore those that didn't match the parent filter */
783 if (!cnt)
784 continue;
785
786 ret += cnt;
776 787
777 if (symbol_conf.use_callchain) 788 if (symbol_conf.use_callchain)
778 ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period); 789 ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period);
@@ -965,13 +976,17 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
965 * Parse hexa addresses followed by ':' 976 * Parse hexa addresses followed by ':'
966 */ 977 */
967 line_ip = strtoull(tmp, &tmp2, 16); 978 line_ip = strtoull(tmp, &tmp2, 16);
968 if (*tmp2 != ':' || tmp == tmp2) 979 if (*tmp2 != ':' || tmp == tmp2 || tmp2[1] == '\0')
969 line_ip = -1; 980 line_ip = -1;
970 } 981 }
971 982
972 if (line_ip != -1) { 983 if (line_ip != -1) {
973 u64 start = map__rip_2objdump(self->ms.map, sym->start); 984 u64 start = map__rip_2objdump(self->ms.map, sym->start),
985 end = map__rip_2objdump(self->ms.map, sym->end);
986
974 offset = line_ip - start; 987 offset = line_ip - start;
988 if (offset < 0 || (u64)line_ip > end)
989 offset = -1;
975 } 990 }
976 991
977 objdump_line = objdump_line__new(offset, line); 992 objdump_line = objdump_line__new(offset, line);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index b63e5713849f..5b276833e2bf 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1443,6 +1443,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
1443{ 1443{
1444 struct dirent *dent; 1444 struct dirent *dent;
1445 DIR *dir = opendir(dir_name); 1445 DIR *dir = opendir(dir_name);
1446 int ret = 0;
1446 1447
1447 if (!dir) { 1448 if (!dir) {
1448 pr_debug("%s: cannot open %s dir\n", __func__, dir_name); 1449 pr_debug("%s: cannot open %s dir\n", __func__, dir_name);
@@ -1465,8 +1466,9 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
1465 1466
1466 snprintf(path, sizeof(path), "%s/%s", 1467 snprintf(path, sizeof(path), "%s/%s",
1467 dir_name, dent->d_name); 1468 dir_name, dent->d_name);
1468 if (map_groups__set_modules_path_dir(self, path) < 0) 1469 ret = map_groups__set_modules_path_dir(self, path);
1469 goto failure; 1470 if (ret < 0)
1471 goto out;
1470 } else { 1472 } else {
1471 char *dot = strrchr(dent->d_name, '.'), 1473 char *dot = strrchr(dent->d_name, '.'),
1472 dso_name[PATH_MAX]; 1474 dso_name[PATH_MAX];
@@ -1487,17 +1489,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
1487 dir_name, dent->d_name); 1489 dir_name, dent->d_name);
1488 1490
1489 long_name = strdup(path); 1491 long_name = strdup(path);
1490 if (long_name == NULL) 1492 if (long_name == NULL) {
1491 goto failure; 1493 ret = -1;
1494 goto out;
1495 }
1492 dso__set_long_name(map->dso, long_name); 1496 dso__set_long_name(map->dso, long_name);
1493 dso__kernel_module_get_build_id(map->dso, ""); 1497 dso__kernel_module_get_build_id(map->dso, "");
1494 } 1498 }
1495 } 1499 }
1496 1500
1497 return 0; 1501out:
1498failure:
1499 closedir(dir); 1502 closedir(dir);
1500 return -1; 1503 return ret;
1501} 1504}
1502 1505
1503static char *get_kernel_version(const char *root_dir) 1506static char *get_kernel_version(const char *root_dir)