Skip to content

Commit a225a1d

Browse files
Masami HiramatsuIngo Molnar
authored andcommitted
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 <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Jim Keniston <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Frank Ch. Eigler <[email protected]> Cc: Jason Baron <[email protected]> Cc: K.Prasad <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Srikar Dronamraju <[email protected]> LKML-Reference: <20091104001229.3454.63987.stgit@harusame> Signed-off-by: Ingo Molnar <[email protected]>
1 parent a7f4328 commit a225a1d

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

tools/perf/builtin-probe.c

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static void parse_probe_event(const char *str)
189189
/* Parse probe point */
190190
parse_probe_point(argv[0], pp);
191191
free(argv[0]);
192-
if (pp->file)
192+
if (pp->file || pp->line)
193193
session.need_dwarf = 1;
194194

195195
/* Copy arguments */
@@ -347,36 +347,24 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
347347
if (session.nr_probe == 0)
348348
usage_with_options(probe_usage, options);
349349

350-
#ifdef NO_LIBDWARF
351350
if (session.need_dwarf)
352-
semantic_error("Dwarf-analysis is not supported");
353-
#endif
354-
355-
/* Synthesize probes without dwarf */
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;
351+
#ifdef NO_LIBDWARF
352+
semantic_error("Debuginfo-analysis is not supported");
353+
#else /* !NO_LIBDWARF */
354+
pr_info("Some probes require debuginfo.\n");
373355

374356
if (session.vmlinux)
375357
fd = open(session.vmlinux, O_RDONLY);
376358
else
377359
fd = open_default_vmlinux();
378-
if (fd < 0)
379-
die("Could not open vmlinux/module file.");
360+
if (fd < 0) {
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+
}
380368

381369
/* Searching probe points */
382370
for (j = 0; j < session.nr_probe; j++) {
@@ -386,14 +374,34 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
386374

387375
lseek(fd, SEEK_SET, 0);
388376
ret = find_probepoint(fd, pp);
389-
if (ret <= 0)
390-
die("No probe point found.\n");
377+
if (ret < 0) {
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.");
391386
}
392387
close(fd);
393388

394-
setup_probes:
389+
end_dwarf:
395390
#endif /* !NO_LIBDWARF */
396391

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+
397405
/* Settng up probe points */
398406
snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path);
399407
fd = open(buf, O_WRONLY, O_APPEND);

tools/perf/util/probe-finder.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,10 @@ int find_probepoint(int fd, struct probe_point *pp)
687687
struct probe_finder pf = {.pp = pp};
688688

689689
ret = dwarf_init(fd, DW_DLC_READ, 0, 0, &__dw_debug, &__dw_error);
690-
if (ret != DW_DLV_OK)
691-
die("No dwarf info found in the vmlinux - please rebuild with CONFIG_DEBUG_INFO.\n");
690+
if (ret != DW_DLV_OK) {
691+
pr_warning("No dwarf info found in the vmlinux - please rebuild with CONFIG_DEBUG_INFO.\n");
692+
return -ENOENT;
693+
}
692694

693695
pp->found = 0;
694696
while (++cu_number) {

0 commit comments

Comments
 (0)