19 #define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED 1
21 #include <boost/algorithm/string.hpp>
22 #include <boost/stacktrace.hpp>
25 const char* stop_at_this_frame,
26 bool skip_void_and_stl_frames) {
27 std::string stack_trace;
29 uint32_t frame_skip_count = num_frames_to_skip;
32 auto st = boost::stacktrace::stacktrace();
35 for (
auto& frame : st) {
37 if (frame_skip_count > 0) {
43 std::string frame_string = frame.name();
46 size_t open_paren_or_angle = frame_string.find_first_of(
"(<");
47 if (open_paren_or_angle != std::string::npos) {
48 frame_string.erase(open_paren_or_angle, std::string::npos);
52 if (skip_void_and_stl_frames) {
53 if (boost::istarts_with(frame_string,
"void")) {
56 if (boost::istarts_with(frame_string,
"std::")) {
62 if (stop_at_this_frame) {
63 if (boost::starts_with(frame_string, stop_at_this_frame)) {
69 if (boost::starts_with(frame_string,
"main")) {
74 if (frame.source_file().size()) {
76 " (" + frame.source_file() +
":" +
std::to_string(frame.source_line()) +
")";
80 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)