From f9b99adeddbe71208e65cead5f349add7aa9c9b5 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 7 Mar 2022 22:25:14 -0800 Subject: Export of internal Abseil changes -- 0b01bad05b4cdea647ad274d64af0d6732787a1d by Gennadiy Rozental : Internal change PiperOrigin-RevId: 433124996 Change-Id: I0a081fb5cbb628901e4913a9c587468ca3b3aaa4 GitOrigin-RevId: 0b01bad05b4cdea647ad274d64af0d6732787a1d --- absl/debugging/internal/examine_stack.cc | 10 ++++++++++ absl/debugging/internal/examine_stack.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'absl/debugging/internal') diff --git a/absl/debugging/internal/examine_stack.cc b/absl/debugging/internal/examine_stack.cc index 2fbfea8e..81d216f9 100644 --- a/absl/debugging/internal/examine_stack.cc +++ b/absl/debugging/internal/examine_stack.cc @@ -37,6 +37,16 @@ namespace absl { ABSL_NAMESPACE_BEGIN namespace debugging_internal { +namespace { +ABSL_CONST_INIT SymbolizeUrlEmitter debug_stack_trace_hook = nullptr; +} // namespace + +void RegisterDebugStackTraceHook(SymbolizeUrlEmitter hook) { + debug_stack_trace_hook = hook; +} + +SymbolizeUrlEmitter GetDebugStackTraceHook() { return debug_stack_trace_hook; } + // Returns the program counter from signal context, nullptr if // unknown. vuc is a ucontext_t*. We use void* to avoid the use of // ucontext_t on non-POSIX systems. diff --git a/absl/debugging/internal/examine_stack.h b/absl/debugging/internal/examine_stack.h index 39336913..61f0056f 100644 --- a/absl/debugging/internal/examine_stack.h +++ b/absl/debugging/internal/examine_stack.h @@ -23,6 +23,21 @@ namespace absl { ABSL_NAMESPACE_BEGIN namespace debugging_internal { +// Type of function used for printing in stack trace dumping, etc. +// We avoid closures to keep things simple. +typedef void OutputWriter(const char*, void*); + +// RegisterDebugStackTraceHook() allows to register a single routine +// `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); + +// Registration of SymbolizeUrlEmitter for use inside of a signal handler. +// This is inherently unsafe and must be signal safe code. +void RegisterDebugStackTraceHook(SymbolizeUrlEmitter hook); +SymbolizeUrlEmitter GetDebugStackTraceHook(); + // Returns the program counter from signal context, or nullptr if // unknown. `vuc` is a ucontext_t*. We use void* to avoid the use of // ucontext_t on non-POSIX systems. -- cgit v1.2.3