Open debugger at the location of failing assert, if possible.

Break into the debugger in the function containing the assert that failed
instead of inside wxWidgets assert handler which is several (~8) levels below
the last line of the user code. This is much more useful in practice and also
less confusing.

Currently this only works for MSVC as the other compilers don't have any
__debugbreak intrinsice equivalent.

Also update the except sample to test wxTrap() directly too.

Closes #11184.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-12-04 00:39:29 +00:00
parent f3ddefc1ad
commit 55fd62c1e3
3 changed files with 68 additions and 20 deletions

View File

@@ -120,6 +120,7 @@ public:
void OnThrowUnhandled(wxCommandEvent& event);
void OnCrash(wxCommandEvent& event);
void OnTrap(wxCommandEvent& event);
#if wxUSE_ON_FATAL_EXCEPTION
void OnHandleCrash(wxCommandEvent& event);
#endif
@@ -188,6 +189,7 @@ enum
Except_ThrowObject,
Except_ThrowUnhandled,
Except_Crash,
Except_Trap,
#if wxUSE_ON_FATAL_EXCEPTION
Except_HandleCrash,
#endif // wxUSE_ON_FATAL_EXCEPTION
@@ -217,6 +219,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(Except_ThrowObject, MyFrame::OnThrowObject)
EVT_MENU(Except_ThrowUnhandled, MyFrame::OnThrowUnhandled)
EVT_MENU(Except_Crash, MyFrame::OnCrash)
EVT_MENU(Except_Trap, MyFrame::OnTrap)
#if wxUSE_ON_FATAL_EXCEPTION
EVT_MENU(Except_HandleCrash, MyFrame::OnHandleCrash)
#endif // wxUSE_ON_FATAL_EXCEPTION
@@ -353,6 +356,8 @@ MyFrame::MyFrame()
menuFile->Append(Except_ThrowUnhandled,
wxT("Throw &unhandled exception\tCtrl-U"));
menuFile->Append(Except_Crash, wxT("&Crash\tCtrl-C"));
menuFile->Append(Except_Trap, "&Trap\tCtrl-T",
"Break into the debugger (if one is running)");
menuFile->AppendSeparator();
#if wxUSE_ON_FATAL_EXCEPTION
menuFile->AppendCheckItem(Except_HandleCrash, wxT("&Handle crashes\tCtrl-H"));
@@ -447,6 +452,11 @@ void MyFrame::OnCrash(wxCommandEvent& WXUNUSED(event))
DoCrash();
}
void MyFrame::OnTrap(wxCommandEvent& WXUNUSED(event))
{
wxTrap();
}
#if wxUSE_ON_FATAL_EXCEPTION
void MyFrame::OnHandleCrash(wxCommandEvent& event)