BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balst::StackTraceUtil Struct Reference

#include <balst_stacktraceutil.h>

Static Public Member Functions

static bsl::ostream & hexStackTrace (bsl::ostream &stream)
 
static int loadStackTraceFromAddressArray (StackTrace *result, const void *const addresses[], int numAddresses, bool demanglingPreferredFlag=true)
 
static int loadStackTraceFromStack (StackTrace *result, int maxFrames=-1, bool demanglingPreferredFlag=true)
 
static bsl::ostream & printFormatted (bsl::ostream &stream, const StackTrace &stackTrace)
 
static bsl::ostream & printFormatted (bsl::ostream &stream, const StackTraceFrame &stackTraceFrame)
 
static bsl::ostream & printHexStackTrace (bsl::ostream &stream, char delimiter=' ', int maxFrames=-1, int additionalIgnoreFrames=0, bslma::Allocator *allocator=0)
 

Detailed Description

This struct serves as a namespace for a collection of functions that are useful for initializing and printing a stack-trace object.

Member Function Documentation

◆ hexStackTrace()

static bsl::ostream & balst::StackTraceUtil::hexStackTrace ( bsl::ostream &  stream)
static

Write to the specified stream the stack addresses from a stack trace of the current thread, in hex from top to bottom, and return stream.

◆ loadStackTraceFromAddressArray()

static int balst::StackTraceUtil::loadStackTraceFromAddressArray ( StackTrace result,
const void *const  addresses[],
int  numAddresses,
bool  demanglingPreferredFlag = true 
)
static

Populate the specified result with stack-trace information from the stack, described by the specified array of addresses of length numAddresses. Optionally specify demanglingPreferredFlag to indicate whether or not to attempt to perform demangling, however, demangling is always performed on the Windows platform and never performed on Solaris using the CC compiler regardless of the value of demanglingPreferredFlag. If demanglingPreferredFlag is not specified, demangling is performed on those platforms that support it. Return 0 on success, and a non-zero value otherwise. Any frames previously contained in the stack-trace object are discarded. The behavior is undefined unless addresses contains at least numAddresses addresses. Note that the return addresses from the stack can be obtained by calling bsls::StackAddressUtil::getStackAddresses, and that demangling sometimes involves calling malloc.

◆ loadStackTraceFromStack()

static int balst::StackTraceUtil::loadStackTraceFromStack ( StackTrace result,
int  maxFrames = -1,
bool  demanglingPreferredFlag = true 
)
static

Populate the specified result object with information about the current thread's program stack. Optionally specify maxFrames to indicate the maximum number of frames to take from the top of the stack. If maxFrames is not specified, the default limit is at least 1024. Optionally specify demanglingPreferredFlag to indicate whether to attempt to perform demangling, if possible. If demanglingPreferredFlag is not specfied, demangling is assumed to be preferred, however, demangling is always performed on the Windows platform and never performed on Solaris using the CC compiler regardless of the value of demanglingPreferredFlag. Any frames previously contained in the stackTrace object are discarded. Return 0 on success, and a non-zero value otherwise. The behavior is undefined unless maxFrames (if specified) is greater than 0. Note that demangling may involve calling malloc.

◆ printFormatted() [1/2]

static bsl::ostream & balst::StackTraceUtil::printFormatted ( bsl::ostream &  stream,
const StackTrace stackTrace 
)
static

Stream the specified stackTrace to the specified stream in some multi-line, human-readable format. Note that this operation attempts to avoid using the default allocator.

◆ printFormatted() [2/2]

static bsl::ostream & balst::StackTraceUtil::printFormatted ( bsl::ostream &  stream,
const StackTraceFrame stackTraceFrame 
)
static

Write the value of the specified stackTraceFrame to the specified output stream in some single-line, human-readable format and return a reference to stream. The name of the symbol is represented by the symbolName property of stackTraceFrame, if known; otherwise, it is represented by the mangledSymbolName property, if known; otherwise, it is represented by "--unknown--". Other frame attributes are written only if their values are known. Note that the format is not fully specified, and can change without notice. Also note that this method attempts to avoid using the default allocator.

◆ printHexStackTrace()

static bsl::ostream & balst::StackTraceUtil::printHexStackTrace ( bsl::ostream &  stream,
char  delimiter = ' ',
int  maxFrames = -1,
int  additionalIgnoreFrames = 0,
bslma::Allocator allocator = 0 
)
static

Write to the specified stream the stack addresses from a stack trace of the current thread, in hex from top to bottom, and return stream. Optionally specify delimiter, that is to be written between stack addresses. If delimiter is not specified, the addresses are separated by a single space. Optionally specify maxFrames, the upper limit of the number of frames to obtain, where a negative or unspecified value will be interpreted as a large finite default value. Optionally specify additionalIgnoreFrames to be added to the number of frames from the stack top to be ignored and not printed. Optionally specify allocator to be used for temporary storage; if none is specified, a locally created heap bypass allocator will be used. The behavior is undefined unless delimiter != 0 and additionalIgnoreFrames >= 0.


The documentation for this struct was generated from the following file: