aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-08-12 04:03:49 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-08-12 06:02:38 -0400
commitcd84c2ac6d6425dd4d1b80a2231e534b9b03df18 (patch)
tree943332327f02f7a056dc87c64e72e340c484ede6 /tools/perf/util/symbol.c
parent9f8666971185b86615a074bcac67c90fdf8af8bc (diff)
perf tools: Factorize high level dso helpers
Factorize multiple definitions of high level dso helpers into the symbol source file. The side effect is a general export of the verbose and eprintf debugging helpers into a new file dedicated to debugging purposes. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Brice Goglin <Brice.Goglin@inria.fr>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index f1dcede14307..e9b13b414955 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -937,6 +937,103 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
937 return err; 937 return err;
938} 938}
939 939
940LIST_HEAD(dsos);
941struct dso *kernel_dso;
942struct dso *vdso;
943struct dso *hypervisor_dso;
944
945char *vmlinux = "vmlinux";
946int modules;
947
948static void dsos__add(struct dso *dso)
949{
950 list_add_tail(&dso->node, &dsos);
951}
952
953static struct dso *dsos__find(const char *name)
954{
955 struct dso *pos;
956
957 list_for_each_entry(pos, &dsos, node)
958 if (strcmp(pos->name, name) == 0)
959 return pos;
960 return NULL;
961}
962
963struct dso *dsos__findnew(const char *name)
964{
965 struct dso *dso = dsos__find(name);
966 int nr;
967
968 if (dso)
969 return dso;
970
971 dso = dso__new(name, 0);
972 if (!dso)
973 goto out_delete_dso;
974
975 nr = dso__load(dso, NULL, verbose);
976 if (nr < 0) {
977 eprintf("Failed to open: %s\n", name);
978 goto out_delete_dso;
979 }
980 if (!nr)
981 eprintf("No symbols found in: %s, maybe install a debug package?\n", name);
982
983 dsos__add(dso);
984
985 return dso;
986
987out_delete_dso:
988 dso__delete(dso);
989 return NULL;
990}
991
992void dsos__fprintf(FILE *fp)
993{
994 struct dso *pos;
995
996 list_for_each_entry(pos, &dsos, node)
997 dso__fprintf(pos, fp);
998}
999
1000static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
1001{
1002 return dso__find_symbol(dso, ip);
1003}
1004
1005int load_kernel(void)
1006{
1007 int err;
1008
1009 kernel_dso = dso__new("[kernel]", 0);
1010 if (!kernel_dso)
1011 return -1;
1012
1013 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
1014 if (err <= 0) {
1015 dso__delete(kernel_dso);
1016 kernel_dso = NULL;
1017 } else
1018 dsos__add(kernel_dso);
1019
1020 vdso = dso__new("[vdso]", 0);
1021 if (!vdso)
1022 return -1;
1023
1024 vdso->find_symbol = vdso__find_symbol;
1025
1026 dsos__add(vdso);
1027
1028 hypervisor_dso = dso__new("[hypervisor]", 0);
1029 if (!hypervisor_dso)
1030 return -1;
1031 dsos__add(hypervisor_dso);
1032
1033 return err;
1034}
1035
1036
940void symbol__init(void) 1037void symbol__init(void)
941{ 1038{
942 elf_version(EV_CURRENT); 1039 elf_version(EV_CURRENT);