diff --git a/ci/test-all-configs.py b/ci/test-all-configs.py index 00e0806..2e02209 100644 --- a/ci/test-all-configs.py +++ b/ci/test-all-configs.py @@ -78,9 +78,7 @@ def output_matches(output: str, params: Tuple[str]): expected = [line.strip().split("||") for line in expected.split("\n")] output = [line.strip().split("||") for line in output.split("\n")] - max_line_diff = MAX_LINE_DIFF - if "CPPTRACE_UNWIND_WITH_UNWIND" in params or "CPPTRACE_UNWIND_WITH_DBGHELP" in params: - max_line_diff = 0 + max_line_diff = 0 errored = False @@ -136,8 +134,6 @@ def run_test(test_binary, params: Tuple[str]): if len(test_stderr) != 0: print("stderr:") print(test_stderr.decode("utf-8"), end="") - print(test_stdout, test_stderr, test.returncode) - print(test) if output_matches(test_stdout.decode("utf-8"), params): print(f"{Fore.GREEN}{Style.BRIGHT}Test succeeded{Style.RESET_ALL}") return True diff --git a/src/unwind/unwind_with_execinfo.cpp b/src/unwind/unwind_with_execinfo.cpp index 24df5d7..2a4f116 100644 --- a/src/unwind/unwind_with_execinfo.cpp +++ b/src/unwind/unwind_with_execinfo.cpp @@ -17,9 +17,13 @@ namespace detail { skip++; std::vector addrs(std::min(hard_max_frames, skip + max_depth), nullptr); const int n_frames = backtrace(addrs.data(), static_cast(addrs.size())); // thread safe + // I hate the copy here but it's the only way that isn't UB std::vector frames(n_frames - skip, 0); for(int i = skip; i < n_frames; i++) { - frames[i - skip] = reinterpret_cast(addrs[i]); + // 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. + frames[i - skip] = reinterpret_cast(addrs[i]) - 1; } return frames; } diff --git a/src/unwind/unwind_with_winapi.cpp b/src/unwind/unwind_with_winapi.cpp index 11e1bc3..27a59da 100644 --- a/src/unwind/unwind_with_winapi.cpp +++ b/src/unwind/unwind_with_winapi.cpp @@ -27,9 +27,13 @@ namespace detail { addrs.data(), NULL ); + // I hate the copy here but it's the only way that isn't UB std::vector frames(n_frames, 0); for(std::size_t i = 0; i < n_frames; i++) { - frames[i] = reinterpret_cast(addrs[i]); + // 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. + frames[i] = reinterpret_cast(addrs[i]) - 1; } return frames; }