core/vul/vul_debug.h
Go to the documentation of this file.
00001 // This is core/vul/vul_debug.h
00002 #ifndef vul_debug_h_
00003 #define vul_debug_h_
00004 
00005 //:
00006 // \file
00007 // \author Ian Scott
00008 
00009 
00010 //: Dump a core file.
00011 // \param filename can have up to one "%d" option, which will be given a different index number
00012 // on each core dump.
00013 // \returns true on success, false when coredump could not be taken
00014 bool vul_debug_core_dump(const char * filename);
00015 
00016 
00017 //: Force a core dump whilst inside a Structured Exception Handler in a windows program.
00018 // To get a core dump from a Windows structured exceptions
00019 // \verbatim
00020 // void main()
00021 // {
00022 //   __try
00023 //   {
00024 //     // Rest of program
00025 //   }
00026 //   __except(vul_debug_core_dump2(filename, GetExceptionInformation()))
00027 //   {}
00028 // }
00029 // \endverbatim
00030 // \param filename can have up to one "%d" option, which will be given a different index number
00031 // on each core dump.
00032 // \returns true on success, false when coredump could not be taken
00033 bool vul_debug_core_dump_in_windows_se(const char * filename,
00034                                        void* pep);
00035 #include <vcl_config_compiler.h>
00036 
00037 #if VCL_HAS_EXCEPTIONS
00038 # include <vcl_exception.h>
00039 //: A translated structured exception.
00040 class vul_debug_windows_structured_exception : public vcl_exception
00041 {
00042   void * ex_ptr_;
00043  public:
00044   //: Windows structured exception code.
00045   unsigned code() const;
00046   //: Related execution address.
00047   void *address() const;
00048   virtual const char *what( ) const throw();
00049   vul_debug_windows_structured_exception(void * ex_ptr) : ex_ptr_(ex_ptr) {}
00050   virtual ~vul_debug_windows_structured_exception() throw() {}
00051 };
00052 #else
00053 class vul_debug_windows_structured_exception {};
00054 #endif //  VCL_HAS_EXCEPTIONS
00055 
00056 //: Setup the system to core dump and throw a C++ exception on detection of a Structured Exception
00057 // The system will throw vul_debug_windows_structured_exception.
00058 // You must compile your code with /EHa to get the compiler to correctly handle SEs.
00059 // \param filename can have up to one "%d" option, which will be given a different index number
00060 // on each core dump.
00061 void vul_debug_set_coredump_and_throw_on_windows_se(const char * filename);
00062 
00063 //: Setup the system to core dump and throw a C++ exception on detection of out of memory.
00064 // The system will throw vcl_bad_alloc. 
00065 // \param filename can have up to one "%d" option, which will be given a different index number
00066 // on each core dump.
00067 void vul_debug_set_coredump_and_throw_on_out_of_memory(const char * filename);
00068 
00069 
00070 #endif // vul_debug_h_