From: wolf Date: Tue, 5 Jul 2005 19:03:51 +0000 (+0000) Subject: Provide a way to switch off stacktraces. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdfb2b5faba7c0d3e5b688b2e9a68691eff2ebc7;p=dealii-svn.git Provide a way to switch off stacktraces. git-svn-id: https://svn.dealii.org/trunk@11065 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/exceptions.h b/deal.II/base/include/base/exceptions.h index 325b7219ac..b4f284a570 100644 --- a/deal.II/base/include/base/exceptions.h +++ b/deal.II/base/include/base/exceptions.h @@ -490,7 +490,24 @@ namespace deal_II_exceptions * given to this function. */ void set_additional_assert_output (const char * const p); - + + /** + * Calling this function disables + * printing a stacktrace along with + * the other output printed when an + * exception occurs. Most of the + * time, you will want to see such + * a stacktrace; suppressing it, + * however, is useful if one wants + * to compare the output of a + * program across different + * machines and systems, since the + * stacktrace shows memory + * addresses and library + * names/paths that depend on the + * exact setup of a machine. + */ + void suppress_stacktrace_in_exceptions (); /** * The functions in this namespace are in connection with the Assert diff --git a/deal.II/base/source/exceptions.cc b/deal.II/base/source/exceptions.cc index 4a9f898fe0..9ab3b9c7ef 100644 --- a/deal.II/base/source/exceptions.cc +++ b/deal.II/base/source/exceptions.cc @@ -28,6 +28,27 @@ #endif +namespace deal_II_exceptions +{ + + std::string additional_assert_output; + + void set_additional_assert_output (const char * const p) + { + additional_assert_output = p; + } + + + + bool show_stacktrace = true; + + void suppress_stacktrace_in_exceptions () + { + show_stacktrace = false; + } +} + + ExceptionBase::ExceptionBase () : @@ -99,8 +120,12 @@ void ExceptionBase::set_fields (const char* f, void ExceptionBase::print_stack_trace (std::ostream &out) const { if (n_stacktrace_frames == 0) + return; + + if (deal_II_exceptions::show_stacktrace == false) return; + // if there is a stackframe stored, print it out << std::endl; out << "Stacktrace:" << std::endl @@ -227,16 +252,6 @@ const char * ExceptionBase::what () const throw () namespace deal_II_exceptions { - - std::string additional_assert_output; - - void set_additional_assert_output (const char * const p) - { - additional_assert_output = p; - } - - - namespace internals {