From 59b5e8025607f588507bc5876001847585f304b5 Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sun, 24 Sep 2023 18:21:41 -0400 Subject: [PATCH] Adjust pc for better line number reporting with StackWalk64 --- ci/test-all-configs.py | 2 +- src/unwind/unwind_with_dbghelp.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ci/test-all-configs.py b/ci/test-all-configs.py index 87c1475..00e0806 100644 --- a/ci/test-all-configs.py +++ b/ci/test-all-configs.py @@ -79,7 +79,7 @@ def output_matches(output: str, params: Tuple[str]): output = [line.strip().split("||") for line in output.split("\n")] max_line_diff = MAX_LINE_DIFF - if "CPPTRACE_UNWIND_WITH_UNWIND" in params: + if "CPPTRACE_UNWIND_WITH_UNWIND" in params or "CPPTRACE_UNWIND_WITH_DBGHELP" in params: max_line_diff = 0 errored = False diff --git a/src/unwind/unwind_with_dbghelp.cpp b/src/unwind/unwind_with_dbghelp.cpp index 55c8ba4..17d957c 100644 --- a/src/unwind/unwind_with_dbghelp.cpp +++ b/src/unwind/unwind_with_dbghelp.cpp @@ -112,7 +112,10 @@ namespace detail { if(skip) { skip--; } else { - trace.push_back(frame.AddrPC.Offset); + // On x86/x64/arm, as far as I can tell, the frame return address is always one after the call + // So we just decrement to get the pc back inside the `call` / `bl` + // This is done with _Unwind too but conditionally based on info from _Unwind_GetIPInfo. + trace.push_back(frame.AddrPC.Offset - 1); } } else { // base