23 #if defined(__GLIBC__) || defined(__APPLE__) 39 static bool output_demangled_name(
41 const std::string &stack_entry)
43 bool return_value=
false;
45 std::string working(stack_entry);
50 if(start!=std::string::npos &&
51 end!=std::string::npos &&
55 std::string mangled(working.substr(start+1, length));
57 int demangle_success=1;
58 std::unique_ptr<char, freert> demangled(
60 mangled.c_str(),
nullptr,
nullptr, &demangle_success));
62 if(demangle_success==0)
64 out << working.substr(0, start+1)
66 << working.substr(end);
81 #if defined(__GLIBC__) || defined(__APPLE__) 82 void *
stack[50] = {};
84 std::size_t entries=backtrace(
stack,
sizeof(
stack) /
sizeof(
void *));
85 std::unique_ptr<char*, freert> description(
86 backtrace_symbols(
stack, entries));
88 for(std::size_t i=0; i<entries; i++)
90 if(!output_demangled_name(out, description.get()[i]))
91 out << description.get()[i];
92 out <<
'\n' << std::flush;
96 out <<
"Backtraces not supported\n" << std::flush;
104 std::ostringstream ostr;
112 std::cerr <<
"--- begin invariant violation report ---\n";
113 std::cerr << reason.
what() <<
'\n';
114 std::cerr <<
"--- end invariant violation report ---\n";
119 std::ostringstream out;
120 out <<
"Invariant check failed\n" 121 <<
"File: " <<
file <<
":" <<
line <<
" function: " <<
function <<
'\n' 123 <<
"Reason: " <<
reason <<
'\n' 124 <<
"Backtrace:" <<
'\n' 133 if(!s.empty() && s.back() !=
'\n')
virtual std::string what() const noexcept
A logic error, augmented with a distinguished field to hold a backtrace.
void print_backtrace(std::ostream &out)
Prints a back trace to 'out'.
virtual std::string what() const noexcept
unsignedbv_typet size_type()
const std::string condition
std::string get_backtrace()
Returns a backtrace.
const std::string diagnostics
const std::string backtrace
void report_exception_to_stderr(const invariant_failedt &reason)
Dump exception report to stderr.
const irept & find(const irep_namet &name) const