21 #include <boost/exception/diagnostic_information.hpp> 23 #ifdef FLOW123D_HAVE_EXEC_INFO 28 #ifdef FLOW123D_HAVE_DEMAGLER 34 : frames_(NULL),n_frames_(0)
36 #ifdef FLOW123D_HAVE_EXEC_INFO 51 frames_ = (
char **) malloc(size*
sizeof(
char) +( n_frames_+1)*
sizeof(
frames_) );
52 char *ptr_dest = (
char *)(
frames_ + n_frames_);
55 char * ptr_src = other.
frames_[i];
56 while(*ptr_src!=0) *(ptr_dest++) = *(ptr_src++);
77 out <<
"** Stacktrace **" << std::endl;
80 for(i_frame=0; i_frame <
n_frames_; i_frame++) {
82 bool is_to_cut =
true;
83 for (
auto to_cut : frames_to_cut) {
84 if ( frame.find(to_cut) == string::npos ) is_to_cut =
false;
90 unsigned int out_i_frame=0;
91 for(;i_frame<
n_frames_; i_frame++, out_i_frame++) {
94 unsigned int start_pos = frame.find(
"(")+1,
95 end_pos = frame.find(
"+");
96 string magled_fname = frame.substr( start_pos, end_pos-start_pos );
99 char *demagled_f_name = {0};
101 #ifdef FLOW123D_HAVE_DEMAGLER 102 demagled_f_name = abi::__cxa_demangle(magled_fname.c_str(), 0, 0, &status);
105 out << setw(3) << out_i_frame <<
" " << demagled_f_name << std::endl;
106 free(demagled_f_name);
108 out << setw(3) << out_i_frame <<
" " << magled_fname << std::endl;
111 if (magled_fname ==
"main")
break;
Class representing stacktrace of exceptions.
void print(std::ostream &out, std::vector< std::string > frames_to_cut=std::vector< std::string >()) const
Prints formated stacktrace into given stream out.
int n_frames_
Size of stacktrace table - number of frames.
char ** frames_
Array of backtrace frames returned by glibc backtrace_symbols.
StackTrace()
Default constructor, fill stacktrace.