From 607d59a103e5213815b468024b198a94b7d4554c Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 15 Jun 2013 14:49:25 -0400 Subject: [PATCH] ExceptionConfigWindow: detect current exception status... ...on startup by seeing if the breakpoints for the exception functions are already installed or not. --- .../gui/team_window/ExceptionConfigWindow.cpp | 59 ++++++++++++++----- .../gui/team_window/ExceptionConfigWindow.h | 5 ++ 2 files changed, 50 insertions(+), 14 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 6e13b62d48..d0a01a1e04 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp @@ -118,6 +118,24 @@ ExceptionConfigWindow::_Init() fExceptionCaught->SetEnabled(false); fCloseButton->SetTarget(this); + + + // check if the exception breakpoints are already installed + AutoLocker< ::Team> teamLocker(fTeam); + for (ImageList::ConstIterator it = fTeam->Images().GetIterator(); + it.HasNext();) { + Image* image = it.Next(); + + ImageDebugInfo* info = image->GetImageDebugInfo(); + target_addr_t address; + if (_FindExceptionFunction(info, address) != B_OK) + continue; + + if (fTeam->BreakpointAtAddress(address) != NULL) { + fExceptionThrown->SetValue(B_CONTROL_ON); + break; + } + } } @@ -125,25 +143,38 @@ void ExceptionConfigWindow::_UpdateThrownBreakpoints(bool enable) { AutoLocker< ::Team> teamLocker(fTeam); - 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)"); + target_addr_t address; + if (_FindExceptionFunction(info, address) != B_OK) + continue; - if (instance != NULL) { - target_addr_t address = instance->Address(); - if (enable) - fListener->SetBreakpointRequested(address, true); - else - fListener->ClearBreakpointRequested(address); - } - } + if (enable) + fListener->SetBreakpointRequested(address, true, true); + else + fListener->ClearBreakpointRequested(address); } } + + +status_t +ExceptionConfigWindow::_FindExceptionFunction(ImageDebugInfo* info, + target_addr_t& _foundAddress) const +{ + if (info != NULL) { + FunctionInstance* instance = info->FunctionByName( + "__cxa_allocate_exception"); + if (instance == NULL) + instance = info->FunctionByName("__throw(void)"); + + if (instance != NULL) { + _foundAddress = instance->Address(); + return B_OK; + } + } + + return B_NAME_NOT_FOUND; +} 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 0a17d1d04e..e18dfc4cc5 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h +++ b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h @@ -8,9 +8,12 @@ #include +#include "types/Types.h" + class BButton; class BCheckBox; +class ImageDebugInfo; class Team; class UserInterfaceListener; @@ -36,6 +39,8 @@ public: private: void _Init(); void _UpdateThrownBreakpoints(bool enable); + status_t _FindExceptionFunction(ImageDebugInfo* info, + target_addr_t& _foundAddress) const; private: