Update *SymbolizeURL APIs to add crash_pc parameter.

PiperOrigin-RevId: 855335009
Change-Id: I1632c5a89e91b857dc18ff9434abf22c3f622d8f
This commit is contained in:
Abseil Team
2026-01-12 12:20:16 -08:00
committed by Copybara-Service
parent 83b229ada5
commit 6e0a3164d2
2 changed files with 14 additions and 5 deletions

View File

@@ -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);

View File

@@ -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