#include <cstdint>
#include <string>
Go to the source code of this file.
|
std::string | getCurrentStackTrace (uint32_t num_frames_to_skip=1, const char *stop_at_this_frame=nullptr, bool skip_void_and_stl_frames=true) |
|
std::string getCurrentStackTrace |
( |
uint32_t |
num_frames_to_skip = 1 , |
|
|
const char * |
stop_at_this_frame = nullptr , |
|
|
bool |
skip_void_and_stl_frames = true |
|
) |
| |
Definition at line 26 of file StackTrace.cpp.
References strip(), and to_string().
Referenced by logger::check_failed().
29 std::string stack_trace;
31 uint32_t frame_skip_count = num_frames_to_skip;
34 auto st = boost::stacktrace::stacktrace();
37 for (
auto& frame : st) {
39 if (frame_skip_count > 0) {
45 std::string frame_string = frame.name();
48 size_t open_paren_or_angle = frame_string.find_first_of(
"(<");
49 if (open_paren_or_angle != std::string::npos) {
50 frame_string.erase(open_paren_or_angle, std::string::npos);
54 if (skip_void_and_stl_frames) {
55 if (boost::istarts_with(frame_string,
"void")) {
58 if (boost::istarts_with(frame_string,
"std::")) {
64 if (stop_at_this_frame) {
65 if (boost::starts_with(frame_string, stop_at_this_frame)) {
71 if (boost::starts_with(frame_string,
"main")) {
76 if (frame.source_file().size()) {
78 " (" + frame.source_file() +
":" +
std::to_string(frame.source_line()) +
")";
82 frame_string =
strip(frame_string);
83 if (frame_string.empty()) {
86 stack_trace += frame_string + std::string(
"\n");