diff --git a/absl/debugging/internal/examine_stack.cc b/absl/debugging/internal/examine_stack.cc index cc24ebd0..9a47f19f 100644 --- a/absl/debugging/internal/examine_stack.cc +++ b/absl/debugging/internal/examine_stack.cc @@ -143,6 +143,12 @@ void DumpPCAndFrameSizeAndSymbol(OutputWriter* writer, void* writer_arg, writer(buf, writer_arg); } +void DebugStackTraceHookLegacyAdapter(void* const stack[], int depth, + OutputWriter* writer, void* writer_arg) { + debug_stack_trace_hook(stack, depth, /*crash_pc=*/nullptr, writer, + writer_arg); +} + } // namespace void RegisterDebugStackTraceHook(SymbolizeUrlEmitter hook) { @@ -150,7 +156,11 @@ void RegisterDebugStackTraceHook(SymbolizeUrlEmitter hook) { } SymbolizeUrlEmitterLegacy GetDebugStackTraceHookLegacy() { - return debug_stack_trace_hook; + if (debug_stack_trace_hook == nullptr) { + // No prior call to RegisterDebugStackTraceHook. + return nullptr; + } + return &DebugStackTraceHookLegacyAdapter; } SymbolizeUrlEmitter GetDebugStackTraceHook() { return debug_stack_trace_hook; } @@ -313,7 +323,7 @@ void DumpStackTrace(int min_dropped_frames, int max_num_frames, auto hook = GetDebugStackTraceHook(); if (hook != nullptr) { - (*hook)(stack, depth, writer, writer_arg); + hook(stack, depth, /*crash_pc=*/nullptr, writer, writer_arg); } if (allocated_bytes != 0) Deallocate(stack, allocated_bytes); diff --git a/absl/debugging/internal/examine_stack.h b/absl/debugging/internal/examine_stack.h index 2094d627..eca430f8 100644 --- a/absl/debugging/internal/examine_stack.h +++ b/absl/debugging/internal/examine_stack.h @@ -31,7 +31,8 @@ typedef void OutputWriter(const char*, void*); // `hook` that is called each time DumpStackTrace() is called. // `hook` may be called from a signal handler. typedef void (*SymbolizeUrlEmitter)(void* const stack[], int depth, - OutputWriter* writer, void* writer_arg); + const void* crash_pc, OutputWriter* writer, + void* writer_arg); typedef void (*SymbolizeUrlEmitterLegacy)(void* const stack[], int depth, OutputWriter* writer, void* writer_arg); @@ -41,8 +42,6 @@ typedef void (*SymbolizeUrlEmitterLegacy)(void* const stack[], int depth, void RegisterDebugStackTraceHook(SymbolizeUrlEmitter hook); SymbolizeUrlEmitter GetDebugStackTraceHook(); -// Currently exact copy of above. Needed for the 3-CL dance due to -// TCMallocDebugStackTraceHook dependency on this API. SymbolizeUrlEmitterLegacy GetDebugStackTraceHookLegacy(); // Returns the program counter from signal context, or nullptr if