[#BloombergLP-bsls-StackAddressUtil-getStackAddresses]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/StackAddressUtil.adoc[StackAddressUtil]::getStackAddresses
:relfileprefix: ../../../
:mrdocs:

Load return addresses from the current call stack into `buffer`&period;

== Synopsis

Declared in `&lt;bsls&lowbar;stackaddressutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
getStackAddresses(
    void** buffer,
    int maxFrames);
----

== Description

Get an sequence of return addresses from the current thread&apos;s function call stack, ordered from most recent call to least recent, and load them into the specified array `&ast;buffer`, which is at least the specified `maxFrames` in length&period; A return address is an address stored on the stack that points to the first instruction that will be executed after the called subroutine returns&period; If there are more than `maxFrames` frames on the stack, only the return addresses for the `maxFrames` most recent routine calls are stored&period; When this routine completes, `buffer` will contain an ordered sequence of return addresses, sorted such that recent calls occur in the array before calls that took place before them&period; Return the number of stack frames stored into `buffer` on success, and a negative value otherwise&period; The behavior is undefined unless `maxFrames &gt;&equals; 0` and `buffer` has room for at least `maxFrames` addresses&period; Note that this routine may fill `buffer` with garbage if the stack is corrupt, or on Windows if some stack frames represent optimized routines&period;

== Return Value

number of stack frames stored in `buffer` on success&semi; a negative value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *buffer*
| array to receive return addresses from the stack
| *maxFrames*
| maximum number of frames to store in `buffer`
|===


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