aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.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-report.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-report.c')
-rw-r--r--tools/perf/builtin-report.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 2357c66fb91d..827eab2edf4b 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -30,7 +30,6 @@
30#define SHOW_HV 4 30#define SHOW_HV 4
31 31
32static char const *input_name = "perf.data"; 32static char const *input_name = "perf.data";
33static char *vmlinux = NULL;
34 33
35static char default_sort_order[] = "comm,dso,symbol"; 34static char default_sort_order[] = "comm,dso,symbol";
36static char *sort_order = default_sort_order; 35static char *sort_order = default_sort_order;
@@ -46,11 +45,6 @@ static int dump_trace = 0;
46#define dprintf(x...) do { if (dump_trace) printf(x); } while (0) 45#define dprintf(x...) do { if (dump_trace) printf(x); } while (0)
47#define cdprintf(x...) do { if (dump_trace) color_fprintf(stdout, color, x); } while (0) 46#define cdprintf(x...) do { if (dump_trace) color_fprintf(stdout, color, x); } while (0)
48 47
49static int verbose;
50#define eprintf(x...) do { if (verbose) fprintf(stderr, x); } while (0)
51
52static int modules;
53
54static int full_paths; 48static int full_paths;
55static int show_nr_samples; 49static int show_nr_samples;
56 50
@@ -161,98 +155,7 @@ static int repsep_fprintf(FILE *fp, const char *fmt, ...)
161 return n; 155 return n;
162} 156}
163 157
164static LIST_HEAD(dsos);
165static struct dso *kernel_dso;
166static struct dso *vdso;
167static struct dso *hypervisor_dso;
168
169static void dsos__add(struct dso *dso)
170{
171 list_add_tail(&dso->node, &dsos);
172}
173
174static struct dso *dsos__find(const char *name)
175{
176 struct dso *pos;
177
178 list_for_each_entry(pos, &dsos, node)
179 if (strcmp(pos->name, name) == 0)
180 return pos;
181 return NULL;
182}
183
184static struct dso *dsos__findnew(const char *name)
185{
186 struct dso *dso = dsos__find(name);
187 int nr;
188
189 if (dso)
190 return dso;
191
192 dso = dso__new(name, 0);
193 if (!dso)
194 goto out_delete_dso;
195
196 nr = dso__load(dso, NULL, verbose);
197 if (nr < 0) {
198 eprintf("Failed to open: %s\n", name);
199 goto out_delete_dso;
200 }
201 if (!nr)
202 eprintf("No symbols found in: %s, maybe install a debug package?\n", name);
203
204 dsos__add(dso);
205
206 return dso;
207
208out_delete_dso:
209 dso__delete(dso);
210 return NULL;
211}
212
213static void dsos__fprintf(FILE *fp)
214{
215 struct dso *pos;
216
217 list_for_each_entry(pos, &dsos, node)
218 dso__fprintf(pos, fp);
219}
220
221static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
222{
223 return dso__find_symbol(dso, ip);
224}
225
226static int load_kernel(void)
227{
228 int err;
229
230 kernel_dso = dso__new("[kernel]", 0);
231 if (!kernel_dso)
232 return -1;
233
234 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
235 if (err <= 0) {
236 dso__delete(kernel_dso);
237 kernel_dso = NULL;
238 } else
239 dsos__add(kernel_dso);
240
241 vdso = dso__new("[vdso]", 0);
242 if (!vdso)
243 return -1;
244 158
245 vdso->find_symbol = vdso__find_symbol;
246
247 dsos__add(vdso);
248
249 hypervisor_dso = dso__new("[hypervisor]", 0);
250 if (!hypervisor_dso)
251 return -1;
252 dsos__add(hypervisor_dso);
253
254 return err;
255}
256 159
257static char __cwd[PATH_MAX]; 160static char __cwd[PATH_MAX];
258static char *cwd = __cwd; 161static char *cwd = __cwd;