[#BloombergLP-balst-StackTracePrintUtil-printStackTrace]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balst.adoc[balst]::xref:BloombergLP/balst/StackTracePrintUtil.adoc[StackTracePrintUtil]::printStackTrace
:relfileprefix: ../../../
:mrdocs:

Obtain a trace of the stack and print it to the specified `stream`&period;

== Synopsis

Declared in `&lt;balst&lowbar;stacktraceprintutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
std::ostream&
printStackTrace(
    std::ostream& stream,
    int maxFrames = &hyphen;1,
    bool demanglingPreferredFlag = true,
    int additionalIgnoreFrames = 0);
----

== Description

Optionally specify `maxFrames` indicating the maximum number of frames from the top of the stack that will be printed&period; If `maxFrames` is not specified, a value of at least 1024 is used&period; Optionally specify `demanglingPreferredFlag`, indicating a preference whether to attempt to demangle function names&period; If `demanglingPreferredFlag` is not specified, an attempt to demangle is assumed&period; If an error occurs, a single&hyphen;line error message is printed to `stream`&period; Optionally specify `additionalIgnoreFrames` which is added to `bsls&colon;&colon;StackAddressUtil&colon;&colon;k&lowbar;IGNORE&lowbar;FRAMES` to ignore frames of the caller&period; Return a reference to `stream`&period; The behavior is undefined unless `&hyphen;1 &lt;&equals; maxFrames` and `0 &lt;&equals; additionalIgnoreFrames`&period; Note that attempting to demangle symbol names could involve calling `malloc`, and that symbol names are always demangled on the Windows platform&period;

== Return Value

a reference to `stream`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *stream*
| output stream for the stack trace
| *maxFrames*
| maximum number of stack frames to print
| *demanglingPreferredFlag*
| whether to prefer demangled symbols
| *additionalIgnoreFrames*
| extra top frames to omit from the trace
|===


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