[#absl-GetStackFrames]
= xref:absl.adoc[absl]::GetStackFrames
:relfileprefix: ../
:mrdocs:

Records program counter values for up to `max&lowbar;depth` frames, skipping the most recent `skip&lowbar;count` stack frames, stores their corresponding values and sizes in `results` and `sizes` buffers, and returns the number of frames stored&period; (Note that the frame generated for the `absl&colon;&colon;GetStackFrames()` routine itself is also skipped&period;)

== Synopsis

Declared in `&lt;absl&sol;debugging&sol;stacktrace&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
extern
int
GetStackFrames(
    void** result,
    int* sizes,
    int max&lowbar;depth,
    int skip&lowbar;count);
----

== Description

Example&colon;

main() &lcub; foo()&semi; &rcub; foo() &lcub; bar()&semi; &rcub; bar() &lcub; void&ast; result&lsqb;10&rsqb;&semi; int sizes&lsqb;10&rsqb;&semi; int depth &equals; absl&colon;&colon;GetStackFrames(result, sizes, 10, 1)&semi; &rcub;

The current stack frame would consist of three function calls&colon; `bar()`, `foo()`, and then `main()`&semi; however, since the `GetStackFrames()` call sets `skip&lowbar;count` to `1`, it will skip the frame for `bar()`, the most recently invoked function call&period; It will therefore return 2 and fill `result` with program counters within the following functions&colon;

result&lsqb;0&rsqb;foo() result&lsqb;1&rsqb;main()

(Note&colon; in practice, a few more entries after `main()` may be added to account for startup processes&period;)

Corresponding stack frame sizes will also be recorded&colon;

sizes&lsqb;0&rsqb;16 sizes&lsqb;1&rsqb;16

(Stack frame sizes of `16` above are just for illustration purposes&period;)

Stack frame sizes of 0 or less indicate that those frame sizes couldn&apos;t be identified&period;

This routine may return fewer stack frame entries than are available&period; Also note that `result` and `sizes` must both be non&hyphen;null&period;

== Return Value

The number of frames stored in `result` and `sizes`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *result*
| Buffer to receive the recorded program counter values&period;
| *sizes*
| Buffer to receive the corresponding stack frame sizes&period;
| *max&lowbar;depth*
| Maximum number of frames to record&period;
| *skip&lowbar;count*
| Number of most recent stack frames to skip&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
