19 #define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED 1
24 #include <boost/algorithm/string.hpp>
27 const char* stop_at_this_frame,
28 bool skip_void_and_stl_frames) {
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");
std::string getCurrentStackTrace(uint32_t num_frames_to_skip, const char *stop_at_this_frame, bool skip_void_and_stl_frames)