Skip to content

Commit

Permalink
perf probe: Fix !dwarf build
Browse files Browse the repository at this point in the history
Fix the !drawf build.

This uses the existing NO_DWARF_SUPPORT mechanism we use for that,
but it's really fragile and needs a cleanup. (in a separate patch)

1) Such uses:

 #ifndef NO_DWARF_SUPPORT

are double inverted logic a'la 'not not'. Instead the flag should
be called DWARF_SUPPORT.

2) Furthermore, assymetric #ifdef polluted code flow like:

        if (need_dwarf)
 #ifdef NO_DWARF_SUPPORT
                die("Debuginfo-analysis is not supported");
 #else   /* !NO_DWARF_SUPPORT */
                pr_debug("Some probes require debuginfo.\n");

        fd = open_vmlinux();

is very fragile and not acceptable. Instead of that helper functions
should be created and the dwarf/no-dwarf logic should be separated more
cleanly.

3) Local variable #ifdefs like this:

 #ifndef NO_DWARF_SUPPORT
        int fd;
 #endif

Are fragile as well and should be eliminated. Helper functions achieve
that too.

Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20100316220612.32050.33806.stgit@localhost6.localdomain6>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ingo Molnar committed Mar 17, 2010
1 parent 7df2f32 commit 3b0d516
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,10 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev,
if (!sym)
die("Kernel symbol \'%s\' not found - probe not added.",
tev->point.symbol);
#ifndef NO_DWARF_SUPPORT
found:
close(fd);
#endif
return ntevs;
}

Expand Down Expand Up @@ -1172,17 +1174,21 @@ void show_line_range(struct line_range *lr)
unsigned int l = 1;
struct line_node *ln;
FILE *fp;
#ifndef NO_DWARF_SUPPORT
int fd, ret;
#endif

/* Search a line range */
init_vmlinux();
#ifndef NO_DWARF_SUPPORT
fd = open_vmlinux();
if (fd < 0)
die("Could not open debuginfo file.");
ret = find_line_range(fd, lr);
if (ret <= 0)
die("Source line is not found.\n");
close(fd);
#endif

setup_pager();

Expand Down

0 comments on commit 3b0d516

Please sign in to comment.