![]() |
libexcept 1.1.21
Stack trace along C++ exceptions
|
Classes | |
| struct | symbol_info |
| Structure used to collect symbol information. More... | |
Functions | |
| int | backtrace_callback (void *data, uintptr_t pc, char const *filename, int line, char const *function) |
| Call back with backtrace data. | |
| void | error_callback (void *data, char const *msg, int err) |
| Capture errors while running backtrace_pcinfo(). | |
| backtrace_state * | get_backtrace_state () |
| Retrieve a pointer to the backtrace state. | |
Variables | |
| bool | g_extended_stack = false |
| The extended stack flag. | |
| int libexcept::anonymous_namespace{stack_trace.cpp}::backtrace_callback | ( | void * | data, |
| uintptr_t | pc, | ||
| char const * | filename, | ||
| int | line, | ||
| char const * | function | ||
| ) |
This function gets called by the backtrace_pcinfo() function each time it finds a match.
The function is used to collect the filename, line number and function name of each hit.
| [in] | data | A pointer to our structure. |
| [in] | pc | The concerned pointer counter (memory address). |
| [in] | filename | The name of the file with the source code. |
| [in] | line | The line number where the call happened. |
| [in] | function | The name of the function being called. |
Definition at line 171 of file stack_trace.cpp.
References backtrace_callback(), libexcept::demangle_cpp_name(), and libexcept::anonymous_namespace{stack_trace.cpp}::symbol_info::f_pc.
Referenced by backtrace_callback().
| void libexcept::anonymous_namespace{stack_trace.cpp}::error_callback | ( | void * | data, |
| char const * | msg, | ||
| int | err | ||
| ) |
When trying to collect information about a function, we call the backtrace_pcinfo() function with this function as a callback function for errors. It generates an error message in std::cerr with the library's message and err number.
| [in] | data | Our data pointer. |
| [in] | msg | The library's message. |
| [in] | err | The error number. |
Definition at line 95 of file stack_trace.cpp.
References error_callback().
Referenced by error_callback(), and get_backtrace_state().
| backtrace_state * libexcept::anonymous_namespace{stack_trace.cpp}::get_backtrace_state | ( | ) |
To use the backtrace_pcinfo() function, we need to have a backtrace state. Function safely allocate that state the first time it gets called. We automatically create a thread safe version of the state.
Definition at line 119 of file stack_trace.cpp.
References error_callback(), and get_backtrace_state().
Referenced by get_backtrace_state().
| bool libexcept::anonymous_namespace{stack_trace.cpp}::g_extended_stack = false |
When creating a stack trace, we skip various frames by default: the libexcept frames, because they are rather useless (assuming this library functions as expected) and the functions called before the main() function.
You may change the behavior by calling the set_extended_stack() function.
Definition at line 81 of file stack_trace.cpp.
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.