19 #define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED 1
23 #include <boost/algorithm/string.hpp>
26 const char* stop_at_this_frame,
27 bool skip_void_and_stl_frames) {
28 std::string stack_trace;
30 uint32_t frame_skip_count = num_frames_to_skip;
33 auto st = boost::stacktrace::stacktrace();
36 for (
auto& frame : st) {
38 if (frame_skip_count > 0) {
44 std::string frame_string = frame.name();
47 size_t open_paren_or_angle = frame_string.find_first_of(
"(<");
48 if (open_paren_or_angle != std::string::npos) {
49 frame_string.erase(open_paren_or_angle, std::string::npos);
53 if (skip_void_and_stl_frames) {
54 if (boost::istarts_with(frame_string,
"void")) {
57 if (boost::istarts_with(frame_string,
"std::")) {
63 if (stop_at_this_frame) {
64 if (boost::starts_with(frame_string, stop_at_this_frame)) {
70 if (boost::starts_with(frame_string,
"main")) {
75 if (frame.source_file().size()) {
77 " (" + frame.source_file() +
":" +
std::to_string(frame.source_line()) +
")";
81 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)