]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Skip all backtrace frames that belong to the exception raising
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 30 Jun 2005 20:28:02 +0000 (20:28 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 30 Jun 2005 20:28:02 +0000 (20:28 +0000)
mechanism itself.

git-svn-id: https://svn.dealii.org/trunk@11014 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/exceptions.cc

index 36a73a9978c4492c42965b700674d39b8b0703e5..c33ef814d05aeb091bdeb6966ff0756d496e8ecf 100644 (file)
@@ -88,8 +88,27 @@ void ExceptionBase::print_stack_trace (std::ostream &out) const
    const int n_frames = backtrace(array, 25);
    char ** symbols = backtrace_symbols(array, n_frames);
 
-   for (int i = 0; i < n_frames; i++)
-      out << symbols[i] << std::endl;
+                                   // print the stacktraces. first
+                                   // omit all those frames that have
+                                   // ExceptionBase or
+                                   // deal_II_exceptions in their
+                                   // names, as these correspond to
+                                   // the exception raising mechanism
+                                   // themselves, rather than the
+                                   // place where the exception was
+                                   // triggered
+   int frame = 0;
+   while ((frame < n_frames)
+         &&
+         ((std::string(symbols[frame]).find ("ExceptionBase") != std::string::npos)
+          ||
+          (std::string(symbols[frame]).find ("deal_II_exceptions") != std::string::npos)))
+     ++frame;
+
+                                   // output the rest
+   for (; frame < n_frames; ++frame)
+      out << symbols[frame]
+         << std::endl;
 
    free(symbols);
 #endif

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.