Snap! Websites
An Open Source CMS System in C++
This typedef defines the type of the variables used to pass the stack trace between functions. It is a simple vector a C++ strings.
The first string (trace[0]
) represents the current function. Note that the collected functions will include all the functions, including the exception_base_t::collect_stack_trace() and various calling functions from the libexcept library. In most cases this means 2 or 3 lines at the start of the stack trace vector are going to be about libexcept functions and not the function where the exception was raised.
Definition at line 60 of file exception.h.
This variable represents the full library version at the time you compile your program.
This function collects the current stack as a trace to log later.
By default, the stack trace shows you a number of backtrace equal to STACK_TRACE_DEPTH (which is 20 at time of writing). You may specify another number to get more or less lines. Note that a really large number will generally show you the entire stack since a number larger than the number of function pointers on the stack will return the entire stack.
If you pass 0 as stack_trace_depth
then the function returns an empty vector of strings.
Passing std::numeric_limits<int>::max()
as the stack_trace_depth
parameter forces the function to return the entire stack trace available.
Definition at line 248 of file exception.cpp.
Referenced by libexcept::exception_base_t::exception_base_t().
This function collects the current stack as a trace including the line numbers and demangled function names as available.
The function also works like the collect_stack_trace() function.
addr2line
and c++filt
command line tools to convert the information. It is likely that if it fails it means your system does not have those two tools installed. Also, the addr2line requires the debug information in the libraries and executables. Without that information you will still get invalid answers in your stacktrace.See also the libbacktrace library: https://gcc.gnu.org/viewcvs/gcc/trunk/libbacktrace/
Source: https://github.com/catchorg/Catch2/issues/539
Definition at line 343 of file exception.cpp.
References demangle_cpp_name().
C++ offers a typeid(\<type>).name()
function, only that does not return a readable name in many cases. This function transforms that name back to the original. This is particularly useful for C++ base types. For example "unsigned short" becomes "t". To verify a type, it is quite practical.
This function demangles all names, including those we get when building a stack trace.
Definition at line 72 of file demangle.cpp.
Referenced by collect_stack_trace_with_line_numbers().
Because collecting the stack trace can be time consuming and once in a while you may need the highest possible speed including libexcept exceptions, we offer a flag to avoid all stack collection processing.
We especially use this feature when running tests because we generate the exceptions on purpose and do not want to get the stack trace which is rather useless in this case. We do not yet have any other situations where we do not want a stack trace.
By default collect_stack
is already true so you do not need to change it on startup.
Definition at line 202 of file exception.cpp.
References libexcept::anonymous_namespace{exception.cpp}::g_collect_stack.
This function returns the library version when it was compiled as a string. It can be used to compare against a version you support (i.e. the version your software was compiled against could be different.)
Definition at line 53 of file version.cpp.
This function returns the library major version number when it was compiled as an integer. It can be used to compare against a version you support.
Definition at line 65 of file version.cpp.
References LIBEXCEPT_LIBRARY_VERSION_MAJOR.
This function returns the library minor version number when it was compiled as an integer. It can be used to compare against a version you support.
Definition at line 77 of file version.cpp.
References LIBEXCEPT_LIBRARY_VERSION_MINOR.
This function returns the library patch version number when it was compiled as an integer. It can be used to compare against a version you support.
Definition at line 89 of file version.cpp.
References LIBEXCEPT_LIBRARY_VERSION_PATCH.
Definition at line 41 of file version.h.in.
Referenced by version_major().
Definition at line 42 of file version.h.in.
Referenced by version_minor().
Definition at line 43 of file version.h.in.
Referenced by version_patch().
This parameter defines the default number of lines returned by the collect_stack_trace() function.
All the functions that call the collect_stack_trace() have a stack_trace_depth
parameter you can use to change this value.
Note that a value of 0 is valid as the stack trace depth. This just means not even one line is going to be taken from the stack.
Definition at line 58 of file exception.h.
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.
Snap! Websites
An Open Source CMS System in C++