[RFC PATCH 2/2] tools/perf: Change how probe offsets are handled
From: Naveen N. Rao
Date: Wed Mar 30 2016 - 12:45:41 EST
While trying to address the kallsyms perf test failure on ppc64le,
Ananth noticed that we were not necessarily probing at the expected
address when an offset to the function was specified.
So far, we used to treat probe point offsets as being offset from the
LEP. However, userspace applications (objdump/readelf) always show
disassembly and offsets from the function GEP. This is confusing to the
user. Fix this by changing how we modify probe address with perf.
If only the function name is provided, we assume the user needs the LEP.
Otherwise, if an offset is specified, we assume that the user knows the
exact address to probe based on function disassembly, and so we just
place the probe from the GEP offset.
Tested lightly. Needs more testing.
Cc: Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>
Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Reported-by: Ananth N Mavinakayanahalli <ananth@xxxxxxxxxx>
Signed-off-by: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
---
tools/perf/arch/powerpc/util/sym-handling.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
index 3e98a61..36f6eb0 100644
--- a/tools/perf/arch/powerpc/util/sym-handling.c
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -65,16 +65,23 @@ void arch__fix_tev_from_maps(struct perf_probe_event *pev,
struct probe_trace_event *tev, struct map *map,
struct symbol *sym)
{
+ int lep_offset = PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other);
+
/*
* ppc64 ABIv2 local entry point is currently always 2 instructions
- * (8 bytes) after the global entry point.
+ * (8 bytes) after the global entry point. When probing at a function
+ * entry point, we normally always want the LEP since that catches calls
+ * to the function through both the GEP and the LEP. However, if the user
+ * specifies an offset, we fall back to using the GEP since all userspace
+ * applications (objdump/readelf) show function disassembly with offsets
+ * from the GEP.
*/
- if (!pev->uprobes && map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) {
- tev->point.address += PPC64LE_LEP_OFFSET;
+ if (pev->point.offset)
+ return;
+
+ if (!pev->uprobes && map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS)
tev->point.offset += PPC64LE_LEP_OFFSET;
- } else if (PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other)) {
- tev->point.address += PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other);
- tev->point.offset += PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other);
- }
+ else if (lep_offset)
+ tev->point.offset += lep_offset;
}
#endif
--
2.7.4