Skip to content

Commit

Permalink
perf probe: Fix build when DWARF support libraries not present
Browse files Browse the repository at this point in the history
On a freshly installed system, after libelf-dev is installed we get:

    CC       /tmp/build/perf/util/probe-event.o
  util/probe-event.c: In function ‘try_to_find_probe_trace_events’:
  util/probe-event.c:753:46: error: unused parameter ‘target’ [-Werror=unused-parameter]
       int max_tevs __maybe_unused, const char *target)
                                                ^
    CC       /tmp/build/perf/util/cgroup.o
  util/probe-event.c: At top level:
  util/probe-event.c:193:12: error: ‘get_text_start_address’ defined but not used [-Werror=unused-function]
   static int get_text_start_address(const char *exec, unsigned long *address)
            ^
  cc1: all warnings being treated as errors
  make[1]: *** [/tmp/build/perf/util/probe-event.o] Error 1
  make[1]: *** Waiting for unfinished jobs....
  make: *** [install] Error 2

Fix it by enclosing functions only used when those libraries are installed
under the suitable preprocessor define and using __maybe_unused to a function
that is only built when DWARF support is disabled.

Problem introduced in this changeset:

  commit fb7345b
  Author: Masami Hiramatsu <[email protected]>
  Date:   Thu Dec 26 05:41:53 2013 +0000

      perf probe: Support basic dwarf-based operations on uprobe events

Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Jan 13, 2014
1 parent a5846e2 commit 1d027ee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const char *kernel_get_module_path(const char *module)
return (dso) ? dso->long_name : NULL;
}

#ifdef HAVE_DWARF_SUPPORT
/* Copied from unwind.c */
static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
GElf_Shdr *shp, const char *name)
Expand Down Expand Up @@ -217,6 +218,7 @@ static int get_text_start_address(const char *exec, unsigned long *address)
elf_end(elf);
return ret;
}
#endif

static int init_user_exec(void)
{
Expand Down Expand Up @@ -750,7 +752,8 @@ static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp,

static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
struct probe_trace_event **tevs __maybe_unused,
int max_tevs __maybe_unused, const char *target)
int max_tevs __maybe_unused,
const char *target __maybe_unused)
{
if (perf_probe_event_need_dwarf(pev)) {
pr_warning("Debuginfo-analysis is not supported.\n");
Expand Down

0 comments on commit 1d027ee

Please sign in to comment.