absl::GetStackFramesWithContext

Records program counter values obtained from a signal handler. Records program counter values for up to max_depth frames, skipping the most recent skip_count stack frames, stores their corresponding values and sizes in results and sizes buffers, and returns the number of frames stored. (Note that the frame generated for the absl::GetStackFramesWithContext() routine itself is also skipped.)

Synopsis

Declared in <absl/debugging/stacktrace.h>

extern
int
GetStackFramesWithContext(
    void** result,
    int* sizes,
    int max_depth,
    int skip_count,
    void const* uc,
    int* min_dropped_frames);

Description

The uc parameter, if non-null, should be a pointer to a ucontext_t value passed to a signal handler registered via the sa_sigaction field of a sigaction struct. (See http://man7.org/linux/man-pages/man2/sigaction.2.html.) The uc value may help a stack unwinder to provide a better stack trace under certain conditions. uc may safely be null.

The min_dropped_frames output parameter, if non-null, points to the location to note any dropped stack frames, if any, due to buffer limitations or other reasons. (This value will be set to 0 if no frames were dropped.) The number of total stack frames is guaranteed to be >= skip_count + max_depth + *min_dropped_frames.

Return Value

The number of frames stored in result and sizes.

Parameters

NameDescription
resultBuffer to receive the recorded program counter values.
sizesBuffer to receive the corresponding stack frame sizes.
max_depthMaximum number of frames to record.
skip_countNumber of most recent stack frames to skip.
ucPointer to the signal handler's ucontext_t value, or null.
min_dropped_framesIf non-null, receives the number of stack frames dropped.