/**
* Destructor.
*/
- virtual ~ExceptionBase() noexcept override;
+ virtual ~ExceptionBase() noexcept override = default;
/**
* Copy operator. This operator is deleted since exception objects
const char *exc;
/**
- * A backtrace to the position where the problem happened, if the system
- * supports this.
- */
- mutable char **stacktrace;
-
- /**
- * The number of stacktrace frames that are stored in the previous variable.
+ * The number of stacktrace frames that are stored in the following variable.
* Zero if the system does not support stack traces.
*/
int n_stacktrace_frames;
, function("")
, cond("")
, exc("")
- , stacktrace(nullptr)
, n_stacktrace_frames(0)
, what_str("")
{
, function(exc.function)
, cond(exc.cond)
, exc(exc.exc)
- , stacktrace(nullptr)
, n_stacktrace_frames(exc.n_stacktrace_frames)
, what_str("") // don't copy the error message, it gets generated dynamically
// by what()
-ExceptionBase::~ExceptionBase() noexcept
-{
- free(stacktrace); // free(nullptr) is allowed
- stacktrace = nullptr;
-}
-
-
-
void
ExceptionBase::set_fields(const char *f,
const int l,
{
// If no error c_string was generated so far, do it now:
if (what_str.empty())
- {
-#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
- // We have deferred the symbol lookup to this point to avoid costly
- // runtime penalties due to linkage of external libraries by
- // backtrace_symbols.
-
- // first delete old stacktrace if necessary
- free(stacktrace); // free(nullptr) is allowed
- stacktrace = backtrace_symbols(raw_stacktrace, n_stacktrace_frames);
-#endif
-
- generate_message();
- }
+ generate_message();
return what_str.c_str();
}
if (deal_II_exceptions::internals::show_stacktrace == false)
return;
+ char **stacktrace = nullptr;
+#ifdef DEAL_II_HAVE_GLIBC_STACKTRACE
+ // We have deferred the symbol lookup to this point to avoid costly
+ // runtime penalties due to linkage of external libraries by
+ // backtrace_symbols.
+ stacktrace = backtrace_symbols(raw_stacktrace, n_stacktrace_frames);
+#endif
+
+
// if there is a stackframe stored, print it
out << std::endl;
out << "Stacktrace:" << std::endl << "-----------" << std::endl;
if (functionname == "main")
break;
}
+
+ free(stacktrace); // free(nullptr) is allowed
+ stacktrace = nullptr;
}