mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf dwarf-aux: Check .eh_frame section for CFA
@ 2026-10-02 22:42 Namhyung Kim
  0 siblings, 0 replies; only message in thread
From: Namhyung Kim @ 2026-10-02 22:42 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Jiri Olsa, Adrian Hunter, James Clark,
	Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users,
	Masami Hiramatsu

The die_get_cfa() only calls dwarf_getcfi() which handles .debug_frame
section.  But most binaries have .eh_frame instead so it would fail.
Let's call dwarf_getcfi_elf() first to try .eh_frame section and then
fallback to .debug_frame.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/dwarf-aux.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 54f8b5ec74a2fe70..af3913e661fce79e 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -1886,9 +1886,14 @@ int die_get_cfa(Dwarf *dwarf, u64 pc, int *preg, int *poffset)
 	Dwarf_Op *ops = NULL;
 	size_t nops;
 
-	cfi = dwarf_getcfi(dwarf);
-	if (cfi == NULL)
-		return -1;
+	/* try to get .eh_frame section */
+	cfi = dwarf_getcfi_elf(dwarf_getelf(dwarf));
+	if (cfi == NULL) {
+		/* and then try .debug_frame section */
+		cfi = dwarf_getcfi(dwarf);
+		if (cfi == NULL)
+			return -1;
+	}
 
 	if (!dwarf_cfi_addrframe(cfi, pc, &frame) &&
 	    !dwarf_frame_cfa(frame, &ops, &nops) &&
-- 
2.56.0.rc1.315.gc6ed9934b7-goog


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-02 22:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 22:42 [PATCH] perf dwarf-aux: Check .eh_frame section for CFA Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®