Page 1 of 1

[CELayoutEditor Update] Stack Traces, VEH & misc

Posted: Thu Dec 06, 2007 20:25
by fjeronimo
Hi all,

Here's another CELayoutEditor SVN update that I hope is to your liking.

The update has been tested in both VS2003 and VS2005.

Here's the detailed contents:

---------------//-----------------

- New: VEH Support - Added Vectored Exception Handling (VEH) support under Windows platforms and debug builds (this option is ignored in release builds). The VEH handler is registered at program startup and is responsible for intercepting all thrown exceptions (both CPP & SEH Win32 ones). This includes normal thrown exceptions, unhandled ones, fatal ones (like access violations) and explicitly raised ones (via RaiseException()). Thanks go to Roger Orr (see about box for contact) for all the help he provided in the process.

- New: Stack Trace - Added stack trace support if running under Windows. The stack trace mechanism includes support for multiple stack trace processing and "eaten" exceptions detection (caught but not processed/logged exceptions).Unfortunately, the code is non-portable, although plans are being made for linux support in the near future.

The following code (inserted in EditorFrame):


Code: Select all

void buh()
{
    throw CEGUI::GenericException( "A sample error..." );
}

// ------------------------------------------------------------------------
// [...]
// In EditorFrame::OnLayoutSkin

    try
    {
        buh(); // First thrown exception     
    }
    catch(CEGUI::GenericException &)
    {
        try
        {
            // Second thrown exception
            // NOTE: This will lead exceptionAddress is empty or invalid when
            // attempting to retrieve type in the VEH handler
            throw;
        }
        catch(CEGUI::GenericException &)
        {
            try
            {
                // Third thrown exception
                throw std::exception("Final exception in the chain");
            }
            SHOW_EXCEPTION("EditorFrame::OnLayoutSkin", "This is the result of a series of nested exceptions", "This is the result of a series of nested exceptions", "This is the result of a series of nested exceptions");
        }
    }

    // Cause access violation (fatal exception)
    // NOTE: This will also lead to failure when attempting to retrieve the exception type
    // in the handler, since an SEH exception class cannot be recognized
    int* p = 0;
    *p = 0;


generates the following under Windows in a debug build (with all configuration defines in Config.h set to 1):

Code: Select all

06/12/2007 19:21:37 (Error)   CEGUI::GenericException in file d:\dev\ceguitests\celayouteditor\src\editorframe.cpp(794) : A sample error...
06/12/2007 19:21:37 (Warn)   GetRTTIExceptionType - Failed to obtain exception type (exceptionAddress is empty or invalid)
06/12/2007 19:21:39 (Error)   CELayoutEditor has detected and caught an exception. The following detailed info is available:

Description: This is the result of a series of nested exceptions
Exception Location: EditorFrame::OnLayoutSkin
Exception Message: Final exception in the chain

WARNING: Multiple stacks detected. This is the result of one or more of the following three things:
   - "Eaten" exceptions (caught but not processed/logged exceptions);
   - Exception chains (the same exception is rethrown -- e.g. catch(Exception&) throw;);
   - Nested exceptions (the exception is caught and a new one is thrown).
All stack traces will be displayed (more recent first).

Exception Stack Trace (2007-12-06 19:21:37):

  Exception Code: CPP_EXCEPTION
  Exception Flags: NONCONTINUABLE
  Exception Type: class std::exception
  Captured at: 2007-12-06 19:21:37
  Frame          Code address
  0x0012DD24  0x7C812A5B RaiseException+0x52
  0x0012DD64  0x00957EA0 CxxThrowException+0x50
  0x0012F690  0x00465F68 EditorFrame::OnLayoutSkin+0xd8 at editorframe.cpp(824)
  0x0012F6A4  0x005A376B wxAppConsole::HandleEvent+0x1b at appbase.cpp(320)
  0x0012F8D8  0x00406E31 CELayoutEditor::HandleEvent+0x61 at celayouteditor.cpp(634)
  0x0012F8FC  0x005A6CB3 wxEvtHandler::ProcessEventIfMatches+0xb3 at event.cpp(1225)
  0x0012F928  0x005A60E6 wxEventHashTable::HandleEvent+0xc6 at event.cpp(899)
  0x0012F94C  0x005A6E8B wxEvtHandler::ProcessEvent+0x10b at event.cpp(1287)
  0x0012F960  0x00487D14 wxDocParentFrame::ProcessEvent+0x54 at docview.cpp(1997)
  0x0012F9D8  0x00509BE7 wxFrameBase::ProcessCommand+0x187 at framecmn.cpp(212)
  0x0012F9F4  0x005088CC wxFrame::HandleCommand+0xac at frame.cpp(978)
  0x0012FA74  0x00508C5C wxFrame::MSWWindowProc+0x10c at frame.cpp(1056)
  0x0012FA94  0x004B3D24 wxWndProc+0xc4 at window.cpp(2554)
  0x0012FAC0  0x7E418734 GetDC+0x6d
  0x0012FB28  0x7E418816 GetDC+0x14f
  0x0012FB88  0x7E4189CD GetWindowLongW+0x127
  0x0012FB98  0x7E418A10 DispatchMessageW+0xf
  0x0012FBAC  0x0052E49F wxEventLoop::ProcessMessage+0x4f at evtloop.cpp(78)
  0x0012FC20  0x0052EA9E wxEventLoop::Dispatch+0x26e at evtloop.cpp(292)
  0x0012FC8C  0x005203F8 wxEventLoopManual::Run+0x168 at evtloopcmn.cpp(115)
  0x0012FCD4  0x0047F6E7 wxAppBase::MainLoop+0xa7 at appcmn.cpp(312)
  0x0012FCE4  0x0047F8E4 wxAppBase::OnRun+0x34 at appcmn.cpp(367)
  0x0012FD58  0x0060CF48 wxEntryReal+0x128 at init.cpp(452)
  0x0012FD94  0x005A7D75 wxEntry+0x65 at main.cpp(209)
  0x0012FE28  0x0047ED92 wxEntry+0x182 at main.cpp(386)
  0x0012FF0C  0x00401413 WinMain+0x33 at celayouteditor.cpp(131)
  0x0012FFB8  0x0068DF16 __tmainCRTStartup+0x286 at crtexe.c(589)
  0x0012FFC0  0x0068DC8D WinMainCRTStartup+0xd at crtexe.c(414)
  0x0012FFF0  0x7C816FD7 RegisterWaitForInputIdle+0x49

  Exception Code: CPP_EXCEPTION
  Exception Flags: NONCONTINUABLE
  Exception Type: Unknown (exceptionAddress is empty or invalid)
  Captured at: 2007-12-06 19:21:37
  Frame          Code address
  0x0012E368  0x7C812A5B RaiseException+0x52
  0x0012E3A8  0x00957EA0 CxxThrowException+0x50
  0x0012F690  0x00465F2A EditorFrame::OnLayoutSkin+0x9a at editorframe.cpp(817)
  0x0012F6A4  0x005A376B wxAppConsole::HandleEvent+0x1b at appbase.cpp(320)
  0x0012F8D8  0x00406E31 CELayoutEditor::HandleEvent+0x61 at celayouteditor.cpp(634)
  0x0012F8FC  0x005A6CB3 wxEvtHandler::ProcessEventIfMatches+0xb3 at event.cpp(1225)
  0x0012F928  0x005A60E6 wxEventHashTable::HandleEvent+0xc6 at event.cpp(899)
  0x0012F94C  0x005A6E8B wxEvtHandler::ProcessEvent+0x10b at event.cpp(1287)
  0x0012F960  0x00487D14 wxDocParentFrame::ProcessEvent+0x54 at docview.cpp(1997)
  0x0012F9D8  0x00509BE7 wxFrameBase::ProcessCommand+0x187 at framecmn.cpp(212)
  0x0012F9F4  0x005088CC wxFrame::HandleCommand+0xac at frame.cpp(978)
  0x0012FA74  0x00508C5C wxFrame::MSWWindowProc+0x10c at frame.cpp(1056)
  0x0012FA94  0x004B3D24 wxWndProc+0xc4 at window.cpp(2554)
  0x0012FAC0  0x7E418734 GetDC+0x6d
  0x0012FB28  0x7E418816 GetDC+0x14f
  0x0012FB88  0x7E4189CD GetWindowLongW+0x127
  0x0012FB98  0x7E418A10 DispatchMessageW+0xf
  0x0012FBAC  0x0052E49F wxEventLoop::ProcessMessage+0x4f at evtloop.cpp(78)
  0x0012FC20  0x0052EA9E wxEventLoop::Dispatch+0x26e at evtloop.cpp(292)
  0x0012FC8C  0x005203F8 wxEventLoopManual::Run+0x168 at evtloopcmn.cpp(115)
  0x0012FCD4  0x0047F6E7 wxAppBase::MainLoop+0xa7 at appcmn.cpp(312)
  0x0012FCE4  0x0047F8E4 wxAppBase::OnRun+0x34 at appcmn.cpp(367)
  0x0012FD58  0x0060CF48 wxEntryReal+0x128 at init.cpp(452)
  0x0012FD94  0x005A7D75 wxEntry+0x65 at main.cpp(209)
  0x0012FE28  0x0047ED92 wxEntry+0x182 at main.cpp(386)
  0x0012FF0C  0x00401413 WinMain+0x33 at celayouteditor.cpp(131)
  0x0012FFB8  0x0068DF16 __tmainCRTStartup+0x286 at crtexe.c(589)
  0x0012FFC0  0x0068DC8D WinMainCRTStartup+0xd at crtexe.c(414)
  0x0012FFF0  0x7C816FD7 RegisterWaitForInputIdle+0x49

  Exception Code: CPP_EXCEPTION
  Exception Flags: NONCONTINUABLE
  Exception Type: class CEGUI::GenericException
  Captured at: 2007-12-06 19:21:37
  Frame          Code address
  0x0012E9BC  0x7C812A5B RaiseException+0x52
  0x0012E9FC  0x00957EA0 CxxThrowException+0x50
  0x0012EE00  0x00465E39 buh+0xb9 at editorframe.cpp(794)
  0x0012F690  0x00465F15 EditorFrame::OnLayoutSkin+0x85 at editorframe.cpp(806)
  0x0012F6A4  0x005A376B wxAppConsole::HandleEvent+0x1b at appbase.cpp(320)
  0x0012F8D8  0x00406E31 CELayoutEditor::HandleEvent+0x61 at celayouteditor.cpp(634)
  0x0012F8FC  0x005A6CB3 wxEvtHandler::ProcessEventIfMatches+0xb3 at event.cpp(1225)
  0x0012F928  0x005A60E6 wxEventHashTable::HandleEvent+0xc6 at event.cpp(899)
  0x0012F94C  0x005A6E8B wxEvtHandler::ProcessEvent+0x10b at event.cpp(1287)
  0x0012F960  0x00487D14 wxDocParentFrame::ProcessEvent+0x54 at docview.cpp(1997)
  0x0012F9D8  0x00509BE7 wxFrameBase::ProcessCommand+0x187 at framecmn.cpp(212)
  0x0012F9F4  0x005088CC wxFrame::HandleCommand+0xac at frame.cpp(978)
  0x0012FA74  0x00508C5C wxFrame::MSWWindowProc+0x10c at frame.cpp(1056)
  0x0012FA94  0x004B3D24 wxWndProc+0xc4 at window.cpp(2554)
  0x0012FAC0  0x7E418734 GetDC+0x6d
  0x0012FB28  0x7E418816 GetDC+0x14f
  0x0012FB88  0x7E4189CD GetWindowLongW+0x127
  0x0012FB98  0x7E418A10 DispatchMessageW+0xf
  0x0012FBAC  0x0052E49F wxEventLoop::ProcessMessage+0x4f at evtloop.cpp(78)
  0x0012FC20  0x0052EA9E wxEventLoop::Dispatch+0x26e at evtloop.cpp(292)
  0x0012FC8C  0x005203F8 wxEventLoopManual::Run+0x168 at evtloopcmn.cpp(115)
  0x0012FCD4  0x0047F6E7 wxAppBase::MainLoop+0xa7 at appcmn.cpp(312)
  0x0012FCE4  0x0047F8E4 wxAppBase::OnRun+0x34 at appcmn.cpp(367)
  0x0012FD58  0x0060CF48 wxEntryReal+0x128 at init.cpp(452)
  0x0012FD94  0x005A7D75 wxEntry+0x65 at main.cpp(209)
  0x0012FE28  0x0047ED92 wxEntry+0x182 at main.cpp(386)
  0x0012FF0C  0x00401413 WinMain+0x33 at celayouteditor.cpp(131)
  0x0012FFB8  0x0068DF16 __tmainCRTStartup+0x286 at crtexe.c(589)
  0x0012FFC0  0x0068DC8D WinMainCRTStartup+0xd at crtexe.c(414)
  0x0012FFF0  0x7C816FD7 RegisterWaitForInputIdle+0x49

06/12/2007 19:21:39 (Warn)   GetRTTIExceptionType - Failed to obtain exception type (SEH Exception)
06/12/2007 19:21:39 (Error)   VectoredHandler - Fatal Win32 exception detected:

Exception Stack Trace (2007-12-06 19:21:39):

  Exception Code: EXCEPTION_ACCESS_VIOLATION
  Exception Flags: CONTINUABLE
  Exception Type: Unknown (SEH Exception)
  Captured at: 2007-12-06 19:21:39
  Frame          Code address
  0x0012F690  0x0046653E EditorFrame::OnLayoutSkin+0x6ae at editorframe.cpp(832)
  0x0012F6A4  0x005A376B wxAppConsole::HandleEvent+0x1b at appbase.cpp(320)
  0x0012F8D8  0x00406E31 CELayoutEditor::HandleEvent+0x61 at celayouteditor.cpp(634)
  0x0012F8FC  0x005A6CB3 wxEvtHandler::ProcessEventIfMatches+0xb3 at event.cpp(1225)
  0x0012F928  0x005A60E6 wxEventHashTable::HandleEvent+0xc6 at event.cpp(899)
  0x0012F94C  0x005A6E8B wxEvtHandler::ProcessEvent+0x10b at event.cpp(1287)
  0x0012F960  0x00487D14 wxDocParentFrame::ProcessEvent+0x54 at docview.cpp(1997)
  0x0012F9D8  0x00509BE7 wxFrameBase::ProcessCommand+0x187 at framecmn.cpp(212)
  0x0012F9F4  0x005088CC wxFrame::HandleCommand+0xac at frame.cpp(978)
  0x0012FA74  0x00508C5C wxFrame::MSWWindowProc+0x10c at frame.cpp(1056)
  0x0012FA94  0x004B3D24 wxWndProc+0xc4 at window.cpp(2554)
  0x0012FAC0  0x7E418734 GetDC+0x6d
  0x0012FB28  0x7E418816 GetDC+0x14f
  0x0012FB88  0x7E4189CD GetWindowLongW+0x127
  0x0012FB98  0x7E418A10 DispatchMessageW+0xf
  0x0012FBAC  0x0052E49F wxEventLoop::ProcessMessage+0x4f at evtloop.cpp(78)
  0x0012FC20  0x0052EA9E wxEventLoop::Dispatch+0x26e at evtloop.cpp(292)
  0x0012FC8C  0x005203F8 wxEventLoopManual::Run+0x168 at evtloopcmn.cpp(115)
  0x0012FCD4  0x0047F6E7 wxAppBase::MainLoop+0xa7 at appcmn.cpp(312)
  0x0012FCE4  0x0047F8E4 wxAppBase::OnRun+0x34 at appcmn.cpp(367)
  0x0012FD58  0x0060CF48 wxEntryReal+0x128 at init.cpp(452)
  0x0012FD94  0x005A7D75 wxEntry+0x65 at main.cpp(209)
  0x0012FE28  0x0047ED92 wxEntry+0x182 at main.cpp(386)
  0x0012FF0C  0x00401413 WinMain+0x33 at celayouteditor.cpp(131)
  0x0012FFB8  0x0068DF16 __tmainCRTStartup+0x286 at crtexe.c(589)
  0x0012FFC0  0x0068DC8D WinMainCRTStartup+0xd at crtexe.c(414)
  0x0012FFF0  0x7C816FD7 RegisterWaitForInputIdle+0x49


- New: Exception code retrieval - Added support for exception code retrieval. See 'Stack Trace' entry above for more info.

- New: Exception flags retrieval - Added support for exception flags retrieval. See 'Stack Trace' entry above for more info.

- New: Exception type retrieval - Added support for exception type retrieval (using RTTI). See 'Stack Trace' entry above for more info.

- New: Exception line & file - Added support for line and file retrieval for CEGUI exceptions. See 'Stack Trace' entry above for more info.

- New: Exception handling configuration - The new features added above are fully configurable via the defines present in Config.h (CHECK_STACK_TRACES;
SHOW_EXCEPTION_FLAGS; SHOW_EXCEPTION_CODE; SHOW_EXCEPTION_TYPE; CHECK_EATEN_EXCEPTIONS; CHECK_MULTIPLE_STACKS and APPEND_MULTIPLE_STACKS).

- New: Logger - The logger is now setup right from the start (and not only when CEGUI is initialized). This allows for the contemplation of errors when performing the CELayoutEditor setup. The log file is now named CELayoutEditor.log instead of CEGUI.log.


- Change: RTTI - Project now supports RTTI in both VS2003 and VS2005.

- Change: Lint files - Lint files have been updated.


---------------//-----------------

Enjoy.