terminate.C File Reference

#include "Util/terminate.H"
#include <exception>
#include <execinfo.h>
#include <pthread.h>
Include dependency graph for terminate.C:

Go to the source code of this file.

Functions

void invt_install_fancy_terminate ()
 Installs a fancy termination handler which prints a backtrace before aborting.

Detailed Description

fancy termination routine

Definition in file terminate.C.


Function Documentation

void invt_install_fancy_terminate (  ) 

Installs a fancy termination handler which prints a backtrace before aborting.

This function needs to be called just once per program run, to install our termination handler; thereafter, if std::terminate() is called (e.g. due to an uncaught exception) it will call our fancy termination handler.

The backtrace (from /usr/include/execinfo.h) will be in a fairly raw format, e.g. with lines like the following:

/path/to/saliency/build/obj/nub/refdetail.so(_ZN3nub6detail22throw_soft_ref_invalidERKSt9type_infoRKN4rutz8file_posE+0xc3)[0xb79301f3] /path/to/saliency/build/obj/Neuro/ShapeEstimator.so(_ZN14ShapeEstimator7computeERK7Point2D+0x60b)[0xb7a556bb] /path/to/saliency/build/obj/Neuro/Brain.so(_ZN5Brain6evolveER7SimTimeR7Point2DRiRf+0x9ed)[0xb7afb0ad] /path/to/saliency/build/obj/Neuro/getSaliency.so(_ZN11GetSaliency7computeERK5ImageI6PixRGBIhEERK7SimTime+0x1ef)[0xb79e8cef]

That is, each line gives the name of the object file, followed by the symbol name of the function that was executing in that file, plus a code offset relative to the start of the function, plus a global address:

file.so(symbolname+offset)[address]

You can get somewhat prettier looking output if you pipe the backtrace through the c++filt program, which will demangle the function names and give you something like this:

/path/to/saliency/build/obj/nub/refdetail.so(nub::detail::throw_soft_ref_invalid(std::type_info const&, rutz::file_pos const&)+0xc3)[0xb79301f3] /path/to/saliency/build/obj/Neuro/ShapeEstimator.so(ShapeEstimator::compute(Point2D<int> const&)+0x60b)[0xb7a556bb] /path/to/saliency/build/obj/Neuro/Brain.so(Brain::evolve(SimTime&, Point2D<int>&, int&, float&)+0x9ed)[0xb7afb0ad] /path/to/saliency/build/obj/Neuro/getSaliency.so(GetSaliency::compute(Image<PixRGB<unsigned char> > const&, SimTime const&)+0x1ef)[0xb79e8cef]

Definition at line 101 of file terminate.C.

Referenced by ModelManager::ModelManager().

Generated on Sun May 8 08:42:52 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3