]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Provide a way to switch off stacktraces.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Jul 2005 19:03:51 +0000 (19:03 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Jul 2005 19:03:51 +0000 (19:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@11065 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/exceptions.h
deal.II/base/source/exceptions.cc

index 325b7219ac22d119364f2af766d65d98ec258cd1..b4f284a570f3266c44aeed11a6cb352a85ee5fa2 100644 (file)
@@ -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
index 4a9f898fe09657c2605572a5b552211f808df796..9ab3b9c7ef75790d931ccd2607dc6400214152b5 100644 (file)
 #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 
   {
     

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.