Commit 4b4da7f7 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Ingo Molnar

perf probe: Cleanup debuginfo related code

Cleanup debuginfo related code to eliminate fragile code which
pointed by Ingo (Thanks!).
1) Invert logic of NO_DWARF_SUPPORT to DWARF_SUPPORT.
2) For removing assymetric/local variable ifdefs, introduce
  more helper functions.
3) Change options order to reduce the number of ifdefs.
Reported-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1269274229-20442-2-git-send-email-acme@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f3a1f0ea
...@@ -506,9 +506,8 @@ endif ...@@ -506,9 +506,8 @@ endif
ifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) ifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
msg := $(warning No libdw.h found or old libdw.h found, disables dwarf support. Please install elfutils-devel/elfutils-dev); msg := $(warning No libdw.h found or old libdw.h found, disables dwarf support. Please install elfutils-devel/elfutils-dev);
BASIC_CFLAGS += -DNO_DWARF_SUPPORT
else else
BASIC_CFLAGS += -I/usr/include/elfutils BASIC_CFLAGS += -I/usr/include/elfutils -DDWARF_SUPPORT
EXTLIBS += -lelf -ldw EXTLIBS += -lelf -ldw
LIB_OBJS += util/probe-finder.o LIB_OBJS += util/probe-finder.o
endif endif
......
...@@ -109,7 +109,7 @@ static int opt_del_probe_event(const struct option *opt __used, ...@@ -109,7 +109,7 @@ static int opt_del_probe_event(const struct option *opt __used,
return 0; return 0;
} }
#ifndef NO_DWARF_SUPPORT #ifdef DWARF_SUPPORT
static int opt_show_lines(const struct option *opt __used, static int opt_show_lines(const struct option *opt __used,
const char *str, int unset __used) const char *str, int unset __used)
{ {
...@@ -126,7 +126,7 @@ static const char * const probe_usage[] = { ...@@ -126,7 +126,7 @@ static const char * const probe_usage[] = {
"perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]", "perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]",
"perf probe [<options>] --del '[GROUP:]EVENT' ...", "perf probe [<options>] --del '[GROUP:]EVENT' ...",
"perf probe --list", "perf probe --list",
#ifndef NO_DWARF_SUPPORT #ifdef DWARF_SUPPORT
"perf probe --line 'LINEDESC'", "perf probe --line 'LINEDESC'",
#endif #endif
NULL NULL
...@@ -135,20 +135,16 @@ static const char * const probe_usage[] = { ...@@ -135,20 +135,16 @@ static const char * const probe_usage[] = {
static const struct option options[] = { static const struct option options[] = {
OPT_BOOLEAN('v', "verbose", &verbose, OPT_BOOLEAN('v', "verbose", &verbose,
"be more verbose (show parsed arguments, etc)"), "be more verbose (show parsed arguments, etc)"),
#ifndef NO_DWARF_SUPPORT
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
#endif
OPT_BOOLEAN('l', "list", &params.list_events, OPT_BOOLEAN('l', "list", &params.list_events,
"list up current probe events"), "list up current probe events"),
OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.", OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.",
opt_del_probe_event), opt_del_probe_event),
OPT_CALLBACK('a', "add", NULL, OPT_CALLBACK('a', "add", NULL,
#ifdef NO_DWARF_SUPPORT #ifdef DWARF_SUPPORT
"[EVENT=]FUNC[+OFF|%return] [ARG ...]",
#else
"[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT" "[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT"
" [ARG ...]", " [ARG ...]",
#else
"[EVENT=]FUNC[+OFF|%return] [ARG ...]",
#endif #endif
"probe point definition, where\n" "probe point definition, where\n"
"\t\tGROUP:\tGroup name (optional)\n" "\t\tGROUP:\tGroup name (optional)\n"
...@@ -156,23 +152,25 @@ static const struct option options[] = { ...@@ -156,23 +152,25 @@ static const struct option options[] = {
"\t\tFUNC:\tFunction name\n" "\t\tFUNC:\tFunction name\n"
"\t\tOFF:\tOffset from function entry (in byte)\n" "\t\tOFF:\tOffset from function entry (in byte)\n"
"\t\t%return:\tPut the probe at function return\n" "\t\t%return:\tPut the probe at function return\n"
#ifdef NO_DWARF_SUPPORT #ifdef DWARF_SUPPORT
"\t\tARG:\tProbe argument (only \n"
#else
"\t\tSRC:\tSource code path\n" "\t\tSRC:\tSource code path\n"
"\t\tRL:\tRelative line number from function entry.\n" "\t\tRL:\tRelative line number from function entry.\n"
"\t\tAL:\tAbsolute line number in file.\n" "\t\tAL:\tAbsolute line number in file.\n"
"\t\tPT:\tLazy expression of line code.\n" "\t\tPT:\tLazy expression of line code.\n"
"\t\tARG:\tProbe argument (local variable name or\n" "\t\tARG:\tProbe argument (local variable name or\n"
#endif
"\t\t\tkprobe-tracer argument format.)\n", "\t\t\tkprobe-tracer argument format.)\n",
#else
"\t\tARG:\tProbe argument (kprobe-tracer argument format.)\n",
#endif
opt_add_probe_event), opt_add_probe_event),
OPT_BOOLEAN('f', "force", &params.force_add, "forcibly add events" OPT_BOOLEAN('f', "force", &params.force_add, "forcibly add events"
" with existing name"), " with existing name"),
#ifndef NO_DWARF_SUPPORT #ifdef DWARF_SUPPORT
OPT_CALLBACK('L', "line", NULL, OPT_CALLBACK('L', "line", NULL,
"FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]", "FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]",
"Show source code lines.", opt_show_lines), "Show source code lines.", opt_show_lines),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
#endif #endif
OPT__DRY_RUN(&probe_event_dry_run), OPT__DRY_RUN(&probe_event_dry_run),
OPT_END() OPT_END()
...@@ -211,7 +209,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) ...@@ -211,7 +209,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
return 0; return 0;
} }
#ifndef NO_DWARF_SUPPORT #ifdef DWARF_SUPPORT
if (params.show_lines) { if (params.show_lines) {
if (params.nevents != 0 || params.dellist) { if (params.nevents != 0 || params.dellist) {
pr_warning(" Error: Don't use --line with" pr_warning(" Error: Don't use --line with"
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ static inline int is_c_varname(const char *name) ...@@ -15,7 +15,7 @@ static inline int is_c_varname(const char *name)
return isalpha(name[0]) || name[0] == '_'; return isalpha(name[0]) || name[0] == '_';
} }
#ifndef NO_DWARF_SUPPORT #ifdef DWARF_SUPPORT
/* Find kprobe_trace_events specified by perf_probe_event from debuginfo */ /* Find kprobe_trace_events specified by perf_probe_event from debuginfo */
extern int find_kprobe_trace_events(int fd, struct perf_probe_event *pev, extern int find_kprobe_trace_events(int fd, struct perf_probe_event *pev,
struct kprobe_trace_event **tevs); struct kprobe_trace_event **tevs);
...@@ -57,6 +57,6 @@ struct line_finder { ...@@ -57,6 +57,6 @@ struct line_finder {
int found; int found;
}; };
#endif /* NO_DWARF_SUPPORT */ #endif /* DWARF_SUPPORT */
#endif /*_PROBE_FINDER_H */ #endif /*_PROBE_FINDER_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment