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
lineNumber int -1 'lineNumber >= -1'
offsetFromSymbol bsl::size_t (size_t)-1 none
Definition bslstl_string.h:1252
- address: the return address in the parent (calling) function on return from the child (called) function.
- libraryFileName: the executable or shared-library file name containing the parent function.
- lineNumber: the source line number in the parent function corresponding, corresponding to a call to the child function.
- mangledSymbolName: mangled symbol name of the parent function (in C code, the "mangled" name matches the symbol name.)
- offsetFromSymbol: offset from the start of the parent function to the call to the child function.
- sourceFileName: Name of the source file of the parent function.
- symbolName: unmangled symbol name of the parent function (in C, code symbol name matches the mangled symbol name.)
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:
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(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:
Next, we update the address attribute of a and use the address accessor method to obtain the new value for the update of b:
assert(a != b);
assert((
char *) 0x12345678 == a.
address());
assert((
char *) 0x12345678 == 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:
assert(a != b);
assert(a == b);
assert(a != b);
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