20 #include <boost/exception/diagnostic_information.hpp> 22 #ifdef FLOW123D_HAVE_EXEC_INFO 27 #ifdef FLOW123D_HAVE_DEMAGLER 33 : frames_(NULL),n_frames_(0)
35 #ifdef FLOW123D_HAVE_EXEC_INFO 50 frames_ = (
char **) malloc(size*
sizeof(
char) +( n_frames_+1)*
sizeof(
frames_) );
51 char *ptr_dest = (
char *)(
frames_ + n_frames_);
54 char * ptr_src = other.
frames_[i];
55 while(*ptr_src!=0) *(ptr_dest++) = *(ptr_src++);
76 out <<
"** Stacktrace **" << std::endl;
79 for(i_frame=0; i_frame <
n_frames_; i_frame++) {
81 bool is_to_cut =
true;
82 for (
auto to_cut : frames_to_cut) {
83 if ( frame.find(to_cut) == string::npos ) is_to_cut =
false;
89 unsigned int out_i_frame=0;
90 for(;i_frame<
n_frames_; i_frame++, out_i_frame++) {
93 unsigned int start_pos = frame.find(
"(")+1,
94 end_pos = frame.find(
"+");
95 string magled_fname = frame.substr( start_pos, end_pos-start_pos );
98 char *demagled_f_name = {0};
100 #ifdef FLOW123D_HAVE_DEMAGLER 101 demagled_f_name = abi::__cxa_demangle(magled_fname.c_str(), 0, 0, &status);
104 out << setw(3) << out_i_frame <<
" " << demagled_f_name << std::endl;
105 free(demagled_f_name);
107 out << setw(3) << out_i_frame <<
" " << magled_fname << std::endl;
110 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.