BDE 4.39.x Production Release
Loading...
Searching...
No Matches
balst_stacktraceframe

Detailed Description

Provide an attribute class describing an execution stack frame.

Outline

Purpose

Provide an attribute class describing an execution stack frame.

Classes

See also
balst_stacktrace

Description

This component provides a single, simply-constrained (value-semantic) attribute class, balst::StackTraceFrame, that describes a stack frame from the execution stack of a function call. Additional methods are provided to indicate whether a given attribute is considered "unknown".

Attributes

Name Type Default Constraint
----------------- ----------- ---------- ----------
address const void * 0 none
libraryFileName bsl::string "" none
lineNumber int -1 'lineNumber >= -1'
mangledSymbolName bsl::string "" none
offsetFromSymbol bsl::size_t (size_t)-1 none
sourceFileName bsl::string "" none
symbolName bsl::string "" none
Definition bslstl_string.h:1252

Unknown Values

For each attribute, a particular value is reserved to designate that the attribute value is "unknown". Default constructed objects are created with the designated "unknown" value for each attribute.

Supplementary Methods

In addition to the usual setters and getters, the balst::StackTraceFrame attribute class provides also provides a suite of non-static, (boolean-valued) predicate methods, of the form is<attributeName>Known. Each of these return true if the object attribute named by the method does not contain the designated "unknown" value for that attribute, and false otherwise.

Usage

This section illustrates intended use of this component.

Example 1: Basic Usage

In this example, we create two balst::StackTraceFrame objects, modify their properties, and compare them.

First, we create the objects a and b:

assert(a == b);
Definition balst_stacktraceframe.h:217

Then, we verify all values are initialized by the constructor to "unknown" values:

assert(false == a.isAddressKnown());
assert(false == a.isLibraryFileNameKnown());
assert(false == a.isLineNumberKnown());
assert(false == a.isMangledSymbolNameKnown());
assert(false == a.isOffsetFromSymbolKnown());
assert(false == a.isSourceFileNameKnown());
assert(false == a.isSymbolNameKnown());
bool isLibraryFileNameKnown() const
Definition balst_stacktraceframe.h:677
bool isAddressKnown() const
Definition balst_stacktraceframe.h:671
bool isSourceFileNameKnown() const
Definition balst_stacktraceframe.h:701
bool isMangledSymbolNameKnown() const
Definition balst_stacktraceframe.h:689
bool isSymbolNameKnown() const
Definition balst_stacktraceframe.h:707
bool isLineNumberKnown() const
Definition balst_stacktraceframe.h:683
bool isOffsetFromSymbolKnown() const
Definition balst_stacktraceframe.h:695

Next, we assign a value to the lineNumber attribute of a and verify:

assert(true == a.isLineNumberKnown());
assert(5 == a.lineNumber());
assert(a != b);
void setLineNumber(int value)
Definition balst_stacktraceframe.h:589
int lineNumber() const
Definition balst_stacktraceframe.h:640

Next, make the same change to b and thereby restore it's equality to a:

assert(true == b.isLineNumberKnown());
assert(5 == b.lineNumber());
assert(a == b);

Next, we update the address attribute of a and use the address accessor method to obtain the new value for the update of b:

a.setAddress((char *) 0x12345678);
assert(a != b);
assert(true == a.isAddressKnown());
assert(true == b.isAddressKnown());
assert((char *) 0x12345678 == a.address());
assert((char *) 0x12345678 == b.address());
assert(a.address() == b.address());
assert(a == b);
void setAddress(const void *value)
Definition balst_stacktraceframe.h:575
const void * address() const
Definition balst_stacktraceframe.h:628

Finally, we exercise this sequence of operations for two other attributes, symbolName and sourceFileName:

a.setSymbolName("woof");
assert(a != b);
assert(true == a.isSymbolNameKnown());
assert(true == b.isSymbolNameKnown());
assert(0 == bsl::strcmp("woof", a.symbolName().c_str()));
assert(0 == bsl::strcmp("woof", b.symbolName().c_str()));
assert(a == b);
a.setSourceFileName("woof.cpp");
assert(a != b);
assert(0 == bsl::strcmp("woof.cpp", a.sourceFileName().c_str()));
assert(0 == bsl::strcmp("woof.cpp", b.sourceFileName().c_str()));
assert(a == b);
const bsl::string & symbolName() const
Definition balst_stacktraceframe.h:664
void setSymbolName(const bsl::string_view &value)
Definition balst_stacktraceframe.h:619
const bsl::string & sourceFileName() const
Definition balst_stacktraceframe.h:658
void setSourceFileName(const bsl::string_view &value)
Definition balst_stacktraceframe.h:611
const CHAR_TYPE * c_str() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:7405