diff options
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/Makefile | 40 | ||||
| -rw-r--r-- | tools/perf/arch/sparc/Makefile | 4 | ||||
| -rw-r--r-- | tools/perf/arch/sparc/util/dwarf-regs.c | 43 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 29 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 17 |
5 files changed, 100 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 | ||
| 601 | ifdef NO_DEMANGLE | 601 | ifdef NO_DEMANGLE |
| 602 | BASIC_CFLAGS += -DNO_DEMANGLE | 602 | BASIC_CFLAGS += -DNO_DEMANGLE |
| 603 | else ifdef HAVE_CPLUS_DEMANGLE | ||
| 604 | EXTLIBS += -liberty | ||
| 605 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | ||
| 606 | else | 603 | else |
| 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/arch/sparc/Makefile b/tools/perf/arch/sparc/Makefile new file mode 100644 index 000000000000..15130b50dfe3 --- /dev/null +++ b/tools/perf/arch/sparc/Makefile | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | ifndef NO_DWARF | ||
| 2 | PERF_HAVE_DWARF_REGS := 1 | ||
| 3 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o | ||
| 4 | endif | ||
diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c new file mode 100644 index 000000000000..0ab88483720c --- /dev/null +++ b/tools/perf/arch/sparc/util/dwarf-regs.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * Mapping of DWARF debug register numbers into register names. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 David S. Miller <davem@davemloft.net> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License | ||
| 8 | * as published by the Free Software Foundation; either version | ||
| 9 | * 2 of the License, or (at your option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <libio.h> | ||
| 13 | #include <dwarf-regs.h> | ||
| 14 | |||
| 15 | #define SPARC_MAX_REGS 96 | ||
| 16 | |||
| 17 | const char *sparc_regs_table[SPARC_MAX_REGS] = { | ||
| 18 | "%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", | ||
| 19 | "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", | ||
| 20 | "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", | ||
| 21 | "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", | ||
| 22 | "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", | ||
| 23 | "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", | ||
| 24 | "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", | ||
| 25 | "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", | ||
| 26 | "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39", | ||
| 27 | "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47", | ||
| 28 | "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55", | ||
| 29 | "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63", | ||
| 30 | }; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * get_arch_regstr() - lookup register name from it's DWARF register number | ||
| 34 | * @n: the DWARF register number | ||
| 35 | * | ||
| 36 | * get_arch_regstr() returns the name of the register in struct | ||
| 37 | * regdwarfnum_table from it's DWARF register number. If the register is not | ||
| 38 | * found in the table, this returns NULL; | ||
| 39 | */ | ||
| 40 | const char *get_arch_regstr(unsigned int n) | ||
| 41 | { | ||
| 42 | return (n <= SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL; | ||
| 43 | } | ||
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, | |||
| 762 | print_entries: | 767 | print_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; | 1501 | out: |
| 1498 | failure: | ||
| 1499 | closedir(dir); | 1502 | closedir(dir); |
| 1500 | return -1; | 1503 | return ret; |
| 1501 | } | 1504 | } |
| 1502 | 1505 | ||
| 1503 | static char *get_kernel_version(const char *root_dir) | 1506 | static char *get_kernel_version(const char *root_dir) |
