aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.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/builtin-annotate.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/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c96
1 files changed, 0 insertions, 96 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 1dba568e1941..1a792990031a 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -26,7 +26,6 @@
26#define SHOW_HV 4 26#define SHOW_HV 4
27 27
28static char const *input_name = "perf.data"; 28static char const *input_name = "perf.data";
29static char *vmlinux = "vmlinux";
30 29
31static char default_sort_order[] = "comm,symbol"; 30static char default_sort_order[] = "comm,symbol";
32static char *sort_order = default_sort_order; 31static char *sort_order = default_sort_order;
@@ -37,9 +36,6 @@ static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
37static int dump_trace = 0; 36static int dump_trace = 0;
38#define dprintf(x...) do { if (dump_trace) printf(x); } while (0) 37#define dprintf(x...) do { if (dump_trace) printf(x); } while (0)
39 38
40static int verbose;
41
42static int modules;
43 39
44static int full_paths; 40static int full_paths;
45 41
@@ -89,98 +85,6 @@ struct sym_ext {
89 char *path; 85 char *path;
90}; 86};
91 87
92static LIST_HEAD(dsos);
93static struct dso *kernel_dso;
94static struct dso *vdso;
95
96
97static void dsos__add(struct dso *dso)
98{
99 list_add_tail(&dso->node, &dsos);
100}
101
102static struct dso *dsos__find(const char *name)
103{
104 struct dso *pos;
105
106 list_for_each_entry(pos, &dsos, node)
107 if (strcmp(pos->name, name) == 0)
108 return pos;
109 return NULL;
110}
111
112static struct dso *dsos__findnew(const char *name)
113{
114 struct dso *dso = dsos__find(name);
115 int nr;
116
117 if (dso)
118 return dso;
119
120 dso = dso__new(name, 0);
121 if (!dso)
122 goto out_delete_dso;
123
124 nr = dso__load(dso, NULL, verbose);
125 if (nr < 0) {
126 if (verbose)
127 fprintf(stderr, "Failed to open: %s\n", name);
128 goto out_delete_dso;
129 }
130 if (!nr && verbose) {
131 fprintf(stderr,
132 "No symbols found in: %s, maybe install a debug package?\n",
133 name);
134 }
135
136 dsos__add(dso);
137
138 return dso;
139
140out_delete_dso:
141 dso__delete(dso);
142 return NULL;
143}
144
145static void dsos__fprintf(FILE *fp)
146{
147 struct dso *pos;
148
149 list_for_each_entry(pos, &dsos, node)
150 dso__fprintf(pos, fp);
151}
152
153static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
154{
155 return dso__find_symbol(dso, ip);
156}
157
158static int load_kernel(void)
159{
160 int err;
161
162 kernel_dso = dso__new("[kernel]", 0);
163 if (!kernel_dso)
164 return -1;
165
166 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
167 if (err <= 0) {
168 dso__delete(kernel_dso);
169 kernel_dso = NULL;
170 } else
171 dsos__add(kernel_dso);
172
173 vdso = dso__new("[vdso]", 0);
174 if (!vdso)
175 return -1;
176
177 vdso->find_symbol = vdso__find_symbol;
178
179 dsos__add(vdso);
180
181 return err;
182}
183
184struct map { 88struct map {
185 struct list_head node; 89 struct list_head node;
186 u64 start; 90 u64 start;