Skip to content

Commit

Permalink
BACKWARD: Using RtlCaptureStackBackTrace instead of StackWalk64
Browse files Browse the repository at this point in the history
Use RtlCaptureStackBackTrace instead of StackWolker64 in case of missing context

see bombela/backward-cpp#334
  • Loading branch information
mgerhardy committed May 2, 2024
1 parent 21bc6cf commit 929b45b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contrib/libs/backward/backward.h
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,15 @@ class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder {
void *error_addr = nullptr) {
set_context(static_cast<CONTEXT*>(context));
set_error_addr(error_addr);

if (!context) {
_stacktrace.resize(depth);
const WORD capturedFrames = RtlCaptureStackBackTrace(
0, static_cast<DWORD>(depth), _stacktrace.data(), NULL);
_stacktrace.resize(capturedFrames);
return capturedFrames;
}

CONTEXT localCtx; // used when no context is provided

if (depth == 0) {
Expand Down

0 comments on commit 929b45b

Please sign in to comment.