-
Notifications
You must be signed in to change notification settings - Fork 2
Docs
inline void dump_stacktrace(size_t capture = -1U, std::ostream& os = std::cout, stack_printer printer = detail::default_print)`
Automatically captures stacktrace, using stacktrace::stacktrace
, and prints it out to os
, using printer
. The default behavior is to capture max possible stack frames, and then print to std::cout
using the detail::default_print
function
Params: capture - max frames to capture (default: -1U
)
os - the std::ostream
to print to (default: std::cout
)
printer - the printer to use to print the stacktrace (default: detail::default_print
)
inline void dump_stacktrace(const symbol_stacktrace& st, std::ostream& os = std::cout, stack_printer printer = detail::default_print)`
Prints st
out to os
, using printer
. The default behavior is to capture max possible stack frames, and then print to std::cout
using the detail::default_print
function
Params: st - the stacktrace to print
os - the std::ostream
to print to (default: std::cout
)
printer - the printer to use to print the stacktrace (default: detail::default_print
)
(inline) pointer_stacktrace stacktrace(size_t capture = -1U)
Captures a max of capture
stack frames, and returns a pointer_stacktrace
with all collected pointers. This may include frames that are not from your code, such as _start
.
Params: capture - max frames to capture (default: -1
)
Return: captured stacktrace
Notes: This will include itself in the stacktrace. On windows, you can only capture up to MAXUSHORT
frames (passing in a value larger will cause it to capture only MAXUSHORT
frames)
(inline) symbol_stacktrace get_traced(const pointer_stacktrace& trace)
Converts a pointer_stacktrace
to a symbol_stacktrace
, using debug symbols in the current executable
Params: trace - the pointer stacktrace from stacktrace::stacktrace
Return: symbolic stacktrace
Notes: Compile with debug info included to get any usable info
using stack_printer = std::function<void(const entry&, std::ostream& os)>;
Function passed to the stacktrace::dump_stacktrace
functions that allow you to have custom printing
class stack_aware_exception : std::runtime_error
Exception that has stacktraces.
Notes: usage
inline const char* get_file() const;
inline const char* get_func() const;
inline const char* get_long_func() const;
inline int get_line() const;
inline const symbol_stacktrace& get_stacktrace() const;
inline std::string get_long_msg() const;
Getter functions
friend std::ostream& operator<<(std::ostream& os, const stack_aware_exception& dt)
Operator used to print stacktraces to a std::ostream
. Use stacktrace::shortexcept
, stacktrace::longexcept
, stacktrace::stacktrace
IO manipulators to set the modes of printing.