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::GetStackFrames() routine itself is also skipped.)
Declared in <absl/debugging/stacktrace.h>
extern
int
GetStackFrames(
void** result,
int* sizes,
int max_depth,
int skip_count);
Example:
main() { foo(); } foo() { bar(); } bar() { void* result[10]; int sizes[10]; int depth = absl::GetStackFrames(result, sizes, 10, 1); }
The current stack frame would consist of three function calls: bar(), foo(), and then main(); however, since the GetStackFrames() call sets skip_count to 1, it will skip the frame for bar(), the most recently invoked function call. It will therefore return 2 and fill result with program counters within the following functions:
result[0]foo() result[1]main()
(Note: in practice, a few more entries after main() may be added to account for startup processes.)
Corresponding stack frame sizes will also be recorded:
sizes[0]16 sizes[1]16
(Stack frame sizes of 16 above are just for illustration purposes.)
Stack frame sizes of 0 or less indicate that those frame sizes couldn't be identified.
This routine may return fewer stack frame entries than are available. Also note that result and sizes must both be non-null.
The number of frames stored in result and sizes.
| Name | Description |
|---|---|
| result | Buffer to receive the recorded program counter values. |
| sizes | Buffer to receive the corresponding stack frame sizes. |
| max_depth | Maximum number of frames to record. |
| skip_count | Number of most recent stack frames to skip. |