diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-08-19 18:21:52 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-08-19 18:21:52 -0400 |
commit | 6a396f67d2442e30150ffb5e1142dbb2f2181d3f (patch) | |
tree | 2ea4f3ab1d3766204a55ec26600b848ed3a7e8aa /tools/perf/util/symbol.c | |
parent | f884dcaead5f17bf586ac5fe6a3ad07b5203616a (diff) | |
parent | cccddf4f5580131c9b963900e1d3400655e633cc (diff) |
Merge branch 'nfsv4_xdr_cleanups-for-2.6.32' into nfs-for-2.6.32
Conflicts:
fs/nfs/nfs4xdr.c
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r-- | tools/perf/util/symbol.c | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 16ddca202948..5c0f42e6b33b 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -7,22 +7,17 @@ | |||
7 | #include <gelf.h> | 7 | #include <gelf.h> |
8 | #include <elf.h> | 8 | #include <elf.h> |
9 | 9 | ||
10 | #ifndef NO_DEMANGLE | ||
11 | #include <bfd.h> | ||
12 | #else | ||
13 | static inline | ||
14 | char *bfd_demangle(void __used *v, const char __used *c, int __used i) | ||
15 | { | ||
16 | return NULL; | ||
17 | } | ||
18 | #endif | ||
19 | |||
20 | const char *sym_hist_filter; | 10 | const char *sym_hist_filter; |
21 | 11 | ||
22 | #ifndef DMGL_PARAMS | 12 | enum dso_origin { |
23 | #define DMGL_PARAMS (1 << 0) /* Include function args */ | 13 | DSO__ORIG_KERNEL = 0, |
24 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ | 14 | DSO__ORIG_JAVA_JIT, |
25 | #endif | 15 | DSO__ORIG_FEDORA, |
16 | DSO__ORIG_UBUNTU, | ||
17 | DSO__ORIG_BUILDID, | ||
18 | DSO__ORIG_DSO, | ||
19 | DSO__ORIG_NOT_FOUND, | ||
20 | }; | ||
26 | 21 | ||
27 | static struct symbol *symbol__new(u64 start, u64 len, | 22 | static struct symbol *symbol__new(u64 start, u64 len, |
28 | const char *name, unsigned int priv_size, | 23 | const char *name, unsigned int priv_size, |
@@ -81,6 +76,7 @@ struct dso *dso__new(const char *name, unsigned int sym_priv_size) | |||
81 | self->sym_priv_size = sym_priv_size; | 76 | self->sym_priv_size = sym_priv_size; |
82 | self->find_symbol = dso__find_symbol; | 77 | self->find_symbol = dso__find_symbol; |
83 | self->slen_calculated = 0; | 78 | self->slen_calculated = 0; |
79 | self->origin = DSO__ORIG_NOT_FOUND; | ||
84 | } | 80 | } |
85 | 81 | ||
86 | return self; | 82 | return self; |
@@ -710,7 +706,7 @@ static char *dso__read_build_id(struct dso *self, int verbose) | |||
710 | ++raw; | 706 | ++raw; |
711 | bid += 2; | 707 | bid += 2; |
712 | } | 708 | } |
713 | if (verbose) | 709 | if (verbose >= 2) |
714 | printf("%s(%s): %s\n", __func__, self->name, build_id); | 710 | printf("%s(%s): %s\n", __func__, self->name, build_id); |
715 | out_elf_end: | 711 | out_elf_end: |
716 | elf_end(elf); | 712 | elf_end(elf); |
@@ -720,11 +716,26 @@ out: | |||
720 | return build_id; | 716 | return build_id; |
721 | } | 717 | } |
722 | 718 | ||
719 | char dso__symtab_origin(const struct dso *self) | ||
720 | { | ||
721 | static const char origin[] = { | ||
722 | [DSO__ORIG_KERNEL] = 'k', | ||
723 | [DSO__ORIG_JAVA_JIT] = 'j', | ||
724 | [DSO__ORIG_FEDORA] = 'f', | ||
725 | [DSO__ORIG_UBUNTU] = 'u', | ||
726 | [DSO__ORIG_BUILDID] = 'b', | ||
727 | [DSO__ORIG_DSO] = 'd', | ||
728 | }; | ||
729 | |||
730 | if (self == NULL || self->origin == DSO__ORIG_NOT_FOUND) | ||
731 | return '!'; | ||
732 | return origin[self->origin]; | ||
733 | } | ||
734 | |||
723 | int dso__load(struct dso *self, symbol_filter_t filter, int verbose) | 735 | int dso__load(struct dso *self, symbol_filter_t filter, int verbose) |
724 | { | 736 | { |
725 | int size = PATH_MAX; | 737 | int size = PATH_MAX; |
726 | char *name = malloc(size), *build_id = NULL; | 738 | char *name = malloc(size), *build_id = NULL; |
727 | int variant = 0; | ||
728 | int ret = -1; | 739 | int ret = -1; |
729 | int fd; | 740 | int fd; |
730 | 741 | ||
@@ -733,19 +744,26 @@ int dso__load(struct dso *self, symbol_filter_t filter, int verbose) | |||
733 | 744 | ||
734 | self->adjust_symbols = 0; | 745 | self->adjust_symbols = 0; |
735 | 746 | ||
736 | if (strncmp(self->name, "/tmp/perf-", 10) == 0) | 747 | if (strncmp(self->name, "/tmp/perf-", 10) == 0) { |
737 | return dso__load_perf_map(self, filter, verbose); | 748 | ret = dso__load_perf_map(self, filter, verbose); |
749 | self->origin = ret > 0 ? DSO__ORIG_JAVA_JIT : | ||
750 | DSO__ORIG_NOT_FOUND; | ||
751 | return ret; | ||
752 | } | ||
753 | |||
754 | self->origin = DSO__ORIG_FEDORA - 1; | ||
738 | 755 | ||
739 | more: | 756 | more: |
740 | do { | 757 | do { |
741 | switch (variant) { | 758 | self->origin++; |
742 | case 0: /* Fedora */ | 759 | switch (self->origin) { |
760 | case DSO__ORIG_FEDORA: | ||
743 | snprintf(name, size, "/usr/lib/debug%s.debug", self->name); | 761 | snprintf(name, size, "/usr/lib/debug%s.debug", self->name); |
744 | break; | 762 | break; |
745 | case 1: /* Ubuntu */ | 763 | case DSO__ORIG_UBUNTU: |
746 | snprintf(name, size, "/usr/lib/debug%s", self->name); | 764 | snprintf(name, size, "/usr/lib/debug%s", self->name); |
747 | break; | 765 | break; |
748 | case 2: | 766 | case DSO__ORIG_BUILDID: |
749 | build_id = dso__read_build_id(self, verbose); | 767 | build_id = dso__read_build_id(self, verbose); |
750 | if (build_id != NULL) { | 768 | if (build_id != NULL) { |
751 | snprintf(name, size, | 769 | snprintf(name, size, |
@@ -754,16 +772,15 @@ more: | |||
754 | free(build_id); | 772 | free(build_id); |
755 | break; | 773 | break; |
756 | } | 774 | } |
757 | variant++; | 775 | self->origin++; |
758 | /* Fall thru */ | 776 | /* Fall thru */ |
759 | case 3: /* Sane people */ | 777 | case DSO__ORIG_DSO: |
760 | snprintf(name, size, "%s", self->name); | 778 | snprintf(name, size, "%s", self->name); |
761 | break; | 779 | break; |
762 | 780 | ||
763 | default: | 781 | default: |
764 | goto out; | 782 | goto out; |
765 | } | 783 | } |
766 | variant++; | ||
767 | 784 | ||
768 | fd = open(name, O_RDONLY); | 785 | fd = open(name, O_RDONLY); |
769 | } while (fd < 0); | 786 | } while (fd < 0); |
@@ -784,6 +801,8 @@ more: | |||
784 | } | 801 | } |
785 | out: | 802 | out: |
786 | free(name); | 803 | free(name); |
804 | if (ret < 0 && strstr(self->name, " (deleted)") != NULL) | ||
805 | return 0; | ||
787 | return ret; | 806 | return ret; |
788 | } | 807 | } |
789 | 808 | ||
@@ -899,6 +918,9 @@ int dso__load_kernel(struct dso *self, const char *vmlinux, | |||
899 | if (err <= 0) | 918 | if (err <= 0) |
900 | err = dso__load_kallsyms(self, filter, verbose); | 919 | err = dso__load_kallsyms(self, filter, verbose); |
901 | 920 | ||
921 | if (err > 0) | ||
922 | self->origin = DSO__ORIG_KERNEL; | ||
923 | |||
902 | return err; | 924 | return err; |
903 | } | 925 | } |
904 | 926 | ||