absl::GetStackTrace

Records program counter values for up to max_depth frames, skipping the most recent skip_count stack frames, stores their corresponding values in results, and returns the number of frames stored. Note that this function is similar to absl::GetStackFrames() except that it returns the stack trace only, and not stack frame sizes.

Synopsis

Declared in <absl/debugging/stacktrace.h>

extern
int
GetStackTrace(
    void** result,
    int max_depth,
    int skip_count);

Description

Example:

main() { foo(); } foo() { bar(); } bar() { void* result[10]; int depth = absl::GetStackTrace(result, 10, 1); }

This produces:

result[0]foo result[1]main .... ...

result must not be null.

Return Value

The number of frames stored in result.

Parameters

NameDescription
resultBuffer to receive the recorded program counter values.
max_depthMaximum number of frames to record.
skip_countNumber of most recent stack frames to skip.