File perf-probe-ppc64le-prefer-symbol-table-lookup-over-dwarf.patch of Package perf.1054
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Date: Wed, 1 Jul 2015 14:42:05 +0530
Subject: [PATCH] perf probe/ppc64le: Prefer symbol table lookup over DWARF
Git-commit: d5c2e2c17ae1d630ddbceb53a264f24cc99703a4
Patch-mainline: v4.2-rc1
References: bnc#936752
Summary: perf probe/ppc64le: Prefer symbol table lookup over DWARF
Description: Prefer symbol table lookup over DWARF on ppc64le. This patch
is modified compared to upstream to avoid dependencies on many ppc64 BE
patches (such as d2332098331fffe9358b50cebc8954ecd6560448 and
eb948e50831bc64e6bb2589be7575ed7c159a429).
Upstream-Description:
Use symbol table lookups by default if DWARF is not necessary, since
powerpc ABIv2 encodes local entry points in the symbol table and the
function entry address in DWARF may not be appropriate for kprobes, as
described here:
https://sourceware.org/bugzilla/show_bug.cgi?id=17638
"The DWARF address ranges deliberately include the *whole* function,
both global and local entry points."
...
"If you want to set probes on a local entry point, you should look up
the symbol in the main symbol table (not DWARF), and check the st_other
bits; they will indicate whether the function has a local entry point,
and what its offset from the global entry point is. Note that GDB does
the same when setting a breakpoint on a function entry."
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
tools/perf/config/Makefile | 4 ++++
tools/perf/util/probe-event.c | 19 +++++++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5f6f9b3..a672703 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -213,6 +213,10 @@ ifneq ($(ARCH),x86)
NO_LIBUNWIND := 1
endif
+ifeq ($(ARCH),powerpc)
+ CFLAGS += -DARCH_PREFER_SYMTAB
+endif
+
ifndef NO_LIBUNWIND
# for linking with debug library, run like:
# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index aa04bf9..8944b5d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1917,10 +1917,16 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
int ret = 0, i;
struct probe_trace_event *tev;
- /* Convert perf_probe_event with debuginfo */
- ret = try_to_find_probe_trace_events(pev, tevs, max_tevs, target);
- if (ret != 0)
- return ret; /* Found in debuginfo or got an error */
+#ifdef ARCH_PREFER_SYMTAB
+ if (perf_probe_event_need_dwarf(pev)) {
+#endif
+ /* Convert perf_probe_event with debuginfo */
+ ret = try_to_find_probe_trace_events(pev, tevs, max_tevs, target);
+ if (ret != 0)
+ return ret; /* Found in debuginfo or got an error */
+#ifdef ARCH_PREFER_SYMTAB
+ }
+#endif
/* Allocate trace event buffer */
tev = *tevs = zalloc(sizeof(struct probe_trace_event));
@@ -2000,6 +2006,11 @@ error:
clear_probe_trace_event(tev);
free(tev);
*tevs = NULL;
+#ifdef ARCH_PREFER_SYMTAB
+ /* Fall back to debuginfo */
+ if (!perf_probe_event_need_dwarf(pev))
+ ret = try_to_find_probe_trace_events(pev, tevs, max_tevs, target);
+#endif
return ret;
}