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

This struct provides a namespace for the function to obtain return addresses from the stack&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class StackAddressUtil;
----

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/StackAddressUtil/_04enum.adoc[`Unnamed enum`] 
| Constants controlling stack address capture on Linux and Darwin&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/StackAddressUtil/formatCheapStack.adoc[`formatCheapStack`] 
| Load the specified `output` buffer having the specified `length` with the Bloomberg standard &quot;cheapstack&quot; contents as a null&hyphen;terminated string&period; On successfully obtaining the current call stack, this will be instructions on how to run the Bloomberg tool `showfunc&period;tsk` (with the optionally specified `taskname`, otherwise with an attempt to obtain the system&hyphen;specific process name) to get details of the current call stack where `formatCheapStack` was called&period; On failure, text indicating that the call stack was not obtainable will be written to `output`&period; If `length` is not long enough for the entire output it will be truncated&period; The behavior is undefined unless `0 &lt;&equals; length` and `output` has the capacity for at least `length` bytes&period;
| xref:BloombergLP/bsls/StackAddressUtil/getStackAddresses.adoc[`getStackAddresses`] 
| 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;
|===



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