Adjust program counters for execinfo and capturestackbacktrace too (#50)
This commit is contained in:
parent
63a7c471cd
commit
fcd0dcc62b
@ -78,9 +78,7 @@ def output_matches(output: str, params: Tuple[str]):
|
|||||||
expected = [line.strip().split("||") for line in expected.split("\n")]
|
expected = [line.strip().split("||") for line in expected.split("\n")]
|
||||||
output = [line.strip().split("||") for line in output.split("\n")]
|
output = [line.strip().split("||") for line in output.split("\n")]
|
||||||
|
|
||||||
max_line_diff = MAX_LINE_DIFF
|
max_line_diff = 0
|
||||||
if "CPPTRACE_UNWIND_WITH_UNWIND" in params or "CPPTRACE_UNWIND_WITH_DBGHELP" in params:
|
|
||||||
max_line_diff = 0
|
|
||||||
|
|
||||||
errored = False
|
errored = False
|
||||||
|
|
||||||
@ -136,8 +134,6 @@ def run_test(test_binary, params: Tuple[str]):
|
|||||||
if len(test_stderr) != 0:
|
if len(test_stderr) != 0:
|
||||||
print("stderr:")
|
print("stderr:")
|
||||||
print(test_stderr.decode("utf-8"), end="")
|
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):
|
if output_matches(test_stdout.decode("utf-8"), params):
|
||||||
print(f"{Fore.GREEN}{Style.BRIGHT}Test succeeded{Style.RESET_ALL}")
|
print(f"{Fore.GREEN}{Style.BRIGHT}Test succeeded{Style.RESET_ALL}")
|
||||||
return True
|
return True
|
||||||
|
|||||||
@ -17,9 +17,13 @@ namespace detail {
|
|||||||
skip++;
|
skip++;
|
||||||
std::vector<void*> addrs(std::min(hard_max_frames, skip + max_depth), nullptr);
|
std::vector<void*> addrs(std::min(hard_max_frames, skip + max_depth), nullptr);
|
||||||
const int n_frames = backtrace(addrs.data(), static_cast<int>(addrs.size())); // thread safe
|
const int n_frames = backtrace(addrs.data(), static_cast<int>(addrs.size())); // thread safe
|
||||||
|
// I hate the copy here but it's the only way that isn't UB
|
||||||
std::vector<uintptr_t> frames(n_frames - skip, 0);
|
std::vector<uintptr_t> frames(n_frames - skip, 0);
|
||||||
for(int i = skip; i < n_frames; i++) {
|
for(int i = skip; i < n_frames; i++) {
|
||||||
frames[i - skip] = reinterpret_cast<uintptr_t>(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<uintptr_t>(addrs[i]) - 1;
|
||||||
}
|
}
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,9 +27,13 @@ namespace detail {
|
|||||||
addrs.data(),
|
addrs.data(),
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
// I hate the copy here but it's the only way that isn't UB
|
||||||
std::vector<uintptr_t> frames(n_frames, 0);
|
std::vector<uintptr_t> frames(n_frames, 0);
|
||||||
for(std::size_t i = 0; i < n_frames; i++) {
|
for(std::size_t i = 0; i < n_frames; i++) {
|
||||||
frames[i] = reinterpret_cast<uintptr_t>(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<uintptr_t>(addrs[i]) - 1;
|
||||||
}
|
}
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user