BDE 4.14.0 Production release
|
Modules | |
balst_objectfileformat | |
Provide platform-dependent object file format trait definitions. | |
balst_resolver_dwarfreader | |
Provide mechanism for reading DWARF information from object files. | |
balst_resolver_filehelper | |
Provide platform-independent file input for stack trace resolvers. | |
balst_resolverimpl_dladdr | |
Provide functions for resolving a stack trace using dladdr . | |
balst_resolverimpl_elf | |
Provide a utility to resolve ELF symbols in a stack trace. | |
balst_resolverimpl_windows | |
Provide resolution of symbols in stack trace for Windows objects. | |
balst_resolverimpl_xcoff | |
Provide a mechanism to resolve xcoff symbols in a stack trace. | |
balst_stacktrace | |
Provide a description of a function-call stack. | |
balst_stacktraceconfigurationutil | |
Provide utility for global configuration of stack trace. | |
balst_stacktraceframe | |
Provide an attribute class describing an execution stack frame. | |
balst_stacktraceprinter | |
Provide an object for streaming the current stack trace. | |
balst_stacktraceprintutil | |
Provide a single function to perform and print a stack trace. | |
balst_stacktracetestallocator | |
Provide a test allocator that reports the call stack for leaks. | |
balst_stacktraceutil | |
Provide low-level utilities for obtaining & printing a stack-trace. | |
Provide a portable facility for obtaining & printing a stack trace.
Basic Application Library Stack Trace utilities (balst)
The 'balst' package provides a facility for obtaining and printing a stack trace at run time.
The 'balst' package currently has 14 components having 7 levels of physical dependency. The list below shows the hierarchical ordering of the components. The order of components within each level is not architecturally significant, just alphabetical.
balst_objectfileformat : Provide platform-dependent object file format trait definitions.
'balst_resolver_dwarfreader': !PRIVATE! Provide mechanism for reading DWARF information from object files.
'balst_resolver_filehelper': !PRIVATE! Provide platform-independent file input for stack trace resolvers.
'balst_resolverimpl_dladdr': !PRIVATE! Provide functions for resolving a stack trace using dladdr
.
'balst_resolverimpl_elf': !PRIVATE! Provide a utility to resolve ELF symbols in a stack trace.
'balst_resolverimpl_windows': !PRIVATE! Provide resolution of symbols in stack trace for Windows objects.
'balst_resolverimpl_xcoff': !PRIVATE! Provide a mechanism to resolve xcoff symbols in a stack trace.
balst_stacktrace : Provide a description of a function-call stack.
balst_stacktraceconfigurationutil : Provide utility for global configuration of stack trace.
balst_stacktraceframe : Provide an attribute class describing an execution stack frame.
balst_stacktraceprinter : Provide an object for streaming the current stack trace.
balst_stacktraceprintutil : Provide a single function to perform and print a stack trace.
balst_stacktracetestallocator : Provide a test allocator that reports the call stack for leaks.
balst_stacktraceutil : Provide low-level utilities for obtaining & printing a stack-trace.
Getting a strack trace through any of the components in this package involves resolving symbols and possibly line numbers and source file names, all of which are computationally very expensive, involving a lot of disk access to debug regions of the executable. If the stack trace is called once when a program crashes, this is not a problem, but if stack traces are to be called frequently during execution to monitor program behavior in some way, it is absolutely prohibitive.
The lowest level of stack trace is not in this package, it is bsls_stackaddressutil , and it contains the code to walk down the stack and collect a buffer of 'void *'s which are return addresses from the stack, which can be obtained very quickly and without doing any disk access, to be expensively resolved to human-readable format later using balst_stacktraceutil or the Bloomberg stand-alone program 'showfunc.tsk'.
As an example of this, the component balst_stacktracetestallocator needs to do a stack trace on every memory allocation. To do a fully-resolved stack trace each time would be a performance catastrophe. So instead, it does a fast call to bsls_stackaddressutil on every memory allocation, and saves a buffer of 'void *'s each time, and then, when it is determined at the end that any of those allocations were leaked, calls balst_stacktraceutil to resolve the buffer of 'void *'s corresponding to the leaked allocation into human-readable output to make a report for the client to read.
This section illustrates intended use of this package.
First, we define a recursive function 'recurseAndPrintStack' that recurses 4 times, then calls '<< StackTracePrinter()' to obtain a stack trace and print it to 'BALL_LOG_FATAL':
which, on Linux, produces the output:
Note that long lines of output here have been hand-wrapped to fit into comments in this 79-column source file. Also note that if the full path of the executable or library is too long, only the basename will be displayed, while if it is short, then the full path will be displayed.