From 41bf99064c2ad4dad46bfce9cbdc8a17d94aad87 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 14 Jun 2013 20:13:39 -0400 Subject: [PATCH] Implement throw exception breakpoints. The exception thrown checkbox now tries to set/clear breakpoints for gcc2/4's respective exception throwing functions. Some tweaking still needs to be done in order that these aren't visible in the breakpoints list like normal user set breakpoints. --- .../gui/team_window/ExceptionConfigWindow.cpp | 75 ++++++++++++++----- .../gui/team_window/ExceptionConfigWindow.h | 1 + 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp index 8da82d1f33..6e13b62d48 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp @@ -8,6 +8,11 @@ #include #include +#include + +#include "FunctionInstance.h" +#include "Image.h" +#include "ImageDebugInfo.h" #include "MessageCodes.h" #include "UserInterface.h" #include "Team.h" @@ -58,6 +63,37 @@ ExceptionConfigWindow::Create(::Team* team, } +void +ExceptionConfigWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case MSG_STOP_ON_THROWN_EXCEPTION_CHANGED: + { + _UpdateThrownBreakpoints(fExceptionThrown->Value() + == B_CONTROL_ON); + break; + } + + case MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED: + { + break; + } + default: + BWindow::MessageReceived(message); + break; + } + +} + + +void +ExceptionConfigWindow::Show() +{ + CenterOnScreen(); + BWindow::Show(); +} + + void ExceptionConfigWindow::_Init() { @@ -84,29 +120,30 @@ ExceptionConfigWindow::_Init() fCloseButton->SetTarget(this); } -void -ExceptionConfigWindow::Show() -{ - CenterOnScreen(); - BWindow::Show(); -} void -ExceptionConfigWindow::MessageReceived(BMessage* message) +ExceptionConfigWindow::_UpdateThrownBreakpoints(bool enable) { - switch (message->what) { - case MSG_STOP_ON_THROWN_EXCEPTION_CHANGED: - { - break; - } + AutoLocker< ::Team> teamLocker(fTeam); - case MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED: - { - break; + for (ImageList::ConstIterator it = fTeam->Images().GetIterator(); + it.HasNext();) { + Image* image = it.Next(); + + ImageDebugInfo* info = image->GetImageDebugInfo(); + if (info != NULL) { + FunctionInstance* instance = info->FunctionByName( + "__cxa_allocate_exception"); + if (instance == NULL) + instance = info->FunctionByName("__throw(void)"); + + if (instance != NULL) { + target_addr_t address = instance->Address(); + if (enable) + fListener->SetBreakpointRequested(address, true); + else + fListener->ClearBreakpointRequested(address); + } } - default: - BWindow::MessageReceived(message); - break; } - } diff --git a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h index bae865bb26..0a17d1d04e 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h +++ b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h @@ -35,6 +35,7 @@ public: private: void _Init(); + void _UpdateThrownBreakpoints(bool enable); private: