aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-probe.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-11-03 19:12:30 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-04 07:02:47 -0500
commita225a1d911f0e434dc0407df29fd08e4388f3fa4 (patch)
treed7b298174ffe1ce6d2e849aa89f9ace55e41e419 /tools/perf/builtin-probe.c
parenta7f4328b91fb6e71dbe1fa4d46f3597c9555014d (diff)
perf/probes: Fall back to non-dwarf if possible
Fall back to non-dwarf probe point if the probe definition may not need dwarf analysis, when perf can't find vmlinux/debuginfo. This might skip some inlined code of target function. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: Jason Baron <jbaron@redhat.com> Cc: K.Prasad <prasad@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> LKML-Reference: <20091104001229.3454.63987.stgit@harusame> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-probe.c')
-rw-r--r--tools/perf/builtin-probe.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 65bcaed0ef49..d111a93f2209 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -189,7 +189,7 @@ static void parse_probe_event(const char *str)
189 /* Parse probe point */ 189 /* Parse probe point */
190 parse_probe_point(argv[0], pp); 190 parse_probe_point(argv[0], pp);
191 free(argv[0]); 191 free(argv[0]);
192 if (pp->file) 192 if (pp->file || pp->line)
193 session.need_dwarf = 1; 193 session.need_dwarf = 1;
194 194
195 /* Copy arguments */ 195 /* Copy arguments */
@@ -347,36 +347,24 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
347 if (session.nr_probe == 0) 347 if (session.nr_probe == 0)
348 usage_with_options(probe_usage, options); 348 usage_with_options(probe_usage, options);
349 349
350#ifdef NO_LIBDWARF
351 if (session.need_dwarf) 350 if (session.need_dwarf)
352 semantic_error("Dwarf-analysis is not supported"); 351#ifdef NO_LIBDWARF
353#endif 352 semantic_error("Debuginfo-analysis is not supported");
354 353#else /* !NO_LIBDWARF */
355 /* Synthesize probes without dwarf */ 354 pr_info("Some probes require debuginfo.\n");
356 for (j = 0; j < session.nr_probe; j++) {
357#ifndef NO_LIBDWARF
358 if (!session.probes[j].retprobe) {
359 session.need_dwarf = 1;
360 continue;
361 }
362#endif
363 ret = synthesize_probe_event(&session.probes[j]);
364 if (ret == -E2BIG)
365 semantic_error("probe point is too long.");
366 else if (ret < 0)
367 die("Failed to synthesize a probe point.");
368 }
369
370#ifndef NO_LIBDWARF
371 if (!session.need_dwarf)
372 goto setup_probes;
373 355
374 if (session.vmlinux) 356 if (session.vmlinux)
375 fd = open(session.vmlinux, O_RDONLY); 357 fd = open(session.vmlinux, O_RDONLY);
376 else 358 else
377 fd = open_default_vmlinux(); 359 fd = open_default_vmlinux();
378 if (fd < 0) 360 if (fd < 0) {
379 die("Could not open vmlinux/module file."); 361 if (session.need_dwarf)
362 die("Could not open vmlinux/module file.");
363
364 pr_warning("Could not open vmlinux/module file."
365 " Try to use symbols.\n");
366 goto end_dwarf;
367 }
380 368
381 /* Searching probe points */ 369 /* Searching probe points */
382 for (j = 0; j < session.nr_probe; j++) { 370 for (j = 0; j < session.nr_probe; j++) {
@@ -386,14 +374,34 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
386 374
387 lseek(fd, SEEK_SET, 0); 375 lseek(fd, SEEK_SET, 0);
388 ret = find_probepoint(fd, pp); 376 ret = find_probepoint(fd, pp);
389 if (ret <= 0) 377 if (ret < 0) {
390 die("No probe point found.\n"); 378 if (session.need_dwarf)
379 die("Could not analyze debuginfo.");
380
381 pr_warning("An error occurred in debuginfo analysis. Try to use symbols.\n");
382 break;
383 }
384 if (ret == 0) /* No error but failed to find probe point. */
385 die("No probe point found.");
391 } 386 }
392 close(fd); 387 close(fd);
393 388
394setup_probes: 389end_dwarf:
395#endif /* !NO_LIBDWARF */ 390#endif /* !NO_LIBDWARF */
396 391
392 /* Synthesize probes without dwarf */
393 for (j = 0; j < session.nr_probe; j++) {
394 pp = &session.probes[j];
395 if (pp->found) /* This probe is already found. */
396 continue;
397
398 ret = synthesize_probe_event(pp);
399 if (ret == -E2BIG)
400 semantic_error("probe point is too long.");
401 else if (ret < 0)
402 die("Failed to synthesize a probe point.");
403 }
404
397 /* Settng up probe points */ 405 /* Settng up probe points */
398 snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path); 406 snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path);
399 fd = open(buf, O_WRONLY, O_APPEND); 407 fd = open(buf, O_WRONLY, O_APPEND);