From 8a668c4025f1c989278b170053e60a2f0d20d16e Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 16 Jan 2018 08:14:15 +1100 Subject: [PATCH] [Debugger] Change CBreakpoints::isDebugging() to a debug setting --- .../Project64-core/Settings/DebugSettings.cpp | 7 +++++- .../Project64-core/Settings/DebugSettings.h | 3 ++- Source/Project64-core/Settings/Settings.h | 1 + .../Project64-core/Settings/SettingsClass.cpp | 1 + .../UserInterface/Debugger/Breakpoints.cpp | 22 ------------------- .../UserInterface/Debugger/Breakpoints.h | 4 ---- .../Debugger/Debugger-Commands.cpp | 20 ++++++++--------- .../Debugger/Debugger-Commands.h | 3 ++- .../Debugger/Debugger-RegisterTabs.cpp | 7 ++---- .../Debugger/Debugger-RegisterTabs.h | 8 +++++-- .../Debugger/Debugger-StackTrace.cpp | 2 +- .../Debugger/Debugger-StackTrace.h | 3 ++- .../UserInterface/Debugger/Debugger.cpp | 16 +++++--------- .../UserInterface/Debugger/debugger.h | 4 +++- 14 files changed, 42 insertions(+), 59 deletions(-) diff --git a/Source/Project64-core/Settings/DebugSettings.cpp b/Source/Project64-core/Settings/DebugSettings.cpp index c1f4c5946..a1b26c0b2 100644 --- a/Source/Project64-core/Settings/DebugSettings.cpp +++ b/Source/Project64-core/Settings/DebugSettings.cpp @@ -13,11 +13,13 @@ int CDebugSettings::m_RefCount = 0; +bool CDebugSettings::m_Registered = false; + bool CDebugSettings::m_bHaveDebugger = false; +bool CDebugSettings::m_Stepping = true; bool CDebugSettings::m_bRecordRecompilerAsm = false; bool CDebugSettings::m_bShowTLBMisses = false; bool CDebugSettings::m_bShowDivByZero = false; -bool CDebugSettings::m_Registered = false; bool CDebugSettings::m_RecordExecutionTimes = false; bool CDebugSettings::m_HaveExecutionBP = false; @@ -32,6 +34,7 @@ CDebugSettings::CDebugSettings() g_Settings->RegisterChangeCB(Debugger_ShowTLBMisses, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_ShowDivByZero, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_RecordExecutionTimes, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); + g_Settings->RegisterChangeCB(Debugger_SteppingOps, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_HaveExecutionBP, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); RefreshSettings(); @@ -48,6 +51,7 @@ CDebugSettings::~CDebugSettings() g_Settings->UnregisterChangeCB(Debugger_ShowTLBMisses, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_ShowDivByZero, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_RecordExecutionTimes, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); + g_Settings->UnregisterChangeCB(Debugger_SteppingOps, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_HaveExecutionBP, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); } } @@ -59,5 +63,6 @@ void CDebugSettings::RefreshSettings() m_bShowTLBMisses = m_bHaveDebugger && g_Settings->LoadBool(Debugger_ShowTLBMisses); m_bShowDivByZero = m_bHaveDebugger && g_Settings->LoadBool(Debugger_ShowDivByZero); m_RecordExecutionTimes = g_Settings->LoadBool(Debugger_RecordExecutionTimes); + m_Stepping = g_Settings->LoadBool(Debugger_SteppingOps); m_HaveExecutionBP = g_Settings->LoadBool(Debugger_HaveExecutionBP); } \ No newline at end of file diff --git a/Source/Project64-core/Settings/DebugSettings.h b/Source/Project64-core/Settings/DebugSettings.h index c5bfe2202..35222094b 100644 --- a/Source/Project64-core/Settings/DebugSettings.h +++ b/Source/Project64-core/Settings/DebugSettings.h @@ -19,6 +19,7 @@ public: virtual ~CDebugSettings(); static inline bool bHaveDebugger(void) { return m_bHaveDebugger; } + static inline bool isStepping(void) { return m_Stepping; } static inline bool bRecordRecompilerAsm(void) { return m_bRecordRecompilerAsm; } static inline bool bShowTLBMisses(void) { return m_bShowTLBMisses; } static inline bool bShowDivByZero(void) { return m_bShowDivByZero; } @@ -33,8 +34,8 @@ private: void RefreshSettings(void); - //Settings that can be changed on the fly static bool m_bHaveDebugger; + static bool m_Stepping; static bool m_bRecordRecompilerAsm; static bool m_bShowTLBMisses; static bool m_bShowDivByZero; diff --git a/Source/Project64-core/Settings/Settings.h b/Source/Project64-core/Settings/Settings.h index 1c998c287..91fca6c4a 100644 --- a/Source/Project64-core/Settings/Settings.h +++ b/Source/Project64-core/Settings/Settings.h @@ -229,6 +229,7 @@ enum SettingID Debugger_ShowRecompMemSize, Debugger_DebugLanguage, Debugger_RecordExecutionTimes, + Debugger_SteppingOps, Debugger_HaveExecutionBP, //Trace diff --git a/Source/Project64-core/Settings/SettingsClass.cpp b/Source/Project64-core/Settings/SettingsClass.cpp index 4ef6f4e6b..88e1daa30 100644 --- a/Source/Project64-core/Settings/SettingsClass.cpp +++ b/Source/Project64-core/Settings/SettingsClass.cpp @@ -314,6 +314,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false)); AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false)); AddHandler(Debugger_RecordExecutionTimes, new CSettingTypeApplication("Debugger", "Record Execution Times", false)); + AddHandler(Debugger_SteppingOps, new CSettingTypeTempBool(false)); AddHandler(Debugger_HaveExecutionBP, new CSettingTypeTempBool(false)); AddHandler(Debugger_DebugLanguage, new CSettingTypeApplication("Debugger", "Debug Language", false)); AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false)); diff --git a/Source/Project64/UserInterface/Debugger/Breakpoints.cpp b/Source/Project64/UserInterface/Debugger/Breakpoints.cpp index b0eff2c4f..b48687cf8 100644 --- a/Source/Project64/UserInterface/Debugger/Breakpoints.cpp +++ b/Source/Project64/UserInterface/Debugger/Breakpoints.cpp @@ -19,36 +19,14 @@ CBreakpoints::CBreakpoints() { - m_Debugging = FALSE; m_Skipping = FALSE; } -void CBreakpoints::Pause() -{ - KeepDebugging(); - g_System->Pause(); -} - void CBreakpoints::Resume() { g_System->ExternalEvent(SysEvent_ResumeCPU_FromMenu); } -bool CBreakpoints::isDebugging() -{ - return m_Debugging; -} - -void CBreakpoints::KeepDebugging() -{ - m_Debugging = true; -} - -void CBreakpoints::StopDebugging() -{ - m_Debugging = false; -} - bool CBreakpoints::isSkipping() { bool ret = m_Skipping; diff --git a/Source/Project64/UserInterface/Debugger/Breakpoints.h b/Source/Project64/UserInterface/Debugger/Breakpoints.h index 3bc1c9f4d..22c805901 100644 --- a/Source/Project64/UserInterface/Debugger/Breakpoints.h +++ b/Source/Project64/UserInterface/Debugger/Breakpoints.h @@ -40,9 +40,6 @@ public: void Resume(); void Skip(); - bool isDebugging(); - void KeepDebugging(); - void StopDebugging(); bool isSkipping(); bool RBPAdd(uint32_t address, bool bTemporary = false); @@ -67,6 +64,5 @@ private: breakpoints_t m_WriteMem; breakpoints_t m_Execution; - bool m_Debugging; bool m_Skipping; }; \ No newline at end of file diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp index 86e6ec3ea..352f58570 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp @@ -120,7 +120,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA m_AddressEdit.SetValue(0x80000000, false, true); ShowAddress(0x80000000, TRUE); - if (m_Breakpoints->isDebugging()) + if (isStepping()) { m_ViewPCButton.EnableWindow(TRUE); m_StepButton.EnableWindow(TRUE); @@ -491,7 +491,7 @@ void CDebugCommandsView::ShowAddress(DWORD address, BOOL top) { m_StartAddress = address; - if (!m_Breakpoints->isDebugging()) + if (!isStepping()) { // Disable buttons m_ViewPCButton.EnableWindow(FALSE); @@ -756,7 +756,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc RGB(0xFF, 0xEE, 0xCC); } - else if (address == pc && m_Breakpoints->isDebugging()) + else if (address == pc && isStepping()) { // pc pLVCD->clrTextBk = RGB(0x88, 0x88, 0x88); @@ -793,7 +793,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) { colors = { 0xFFFFFF, 0xFF0000 }; } - else if (address == pc && m_Breakpoints->isDebugging()) + else if (address == pc && isStepping()) { colors = { 0xFFFFAA, 0x222200 }; } @@ -838,7 +838,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) pLVCD->clrTextBk = _byteswap_ulong(colors.bg) >> 8; pLVCD->clrText = _byteswap_ulong(colors.fg) >> 8; - if (!m_Breakpoints->isDebugging()) + if (!isStepping()) { return CDRF_DODEFAULT; } @@ -1084,7 +1084,7 @@ void CDebugCommandsView::RemoveSelectedBreakpoints() void CDebugCommandsView::CPUSkip() { - m_Breakpoints->KeepDebugging(); + g_Settings->SaveBool(Debugger_SteppingOps, true); m_Breakpoints->Skip(); m_Breakpoints->Resume(); } @@ -1093,7 +1093,7 @@ void CDebugCommandsView::CPUStepInto() { m_Debugger->Debug_RefreshStackWindow(); m_Debugger->Debug_RefreshStackTraceWindow(); - m_Breakpoints->KeepDebugging(); + g_Settings->SaveBool(Debugger_SteppingOps, true); m_Breakpoints->Resume(); } @@ -1101,7 +1101,7 @@ void CDebugCommandsView::CPUResume() { m_Debugger->Debug_RefreshStackWindow(); m_Debugger->Debug_RefreshStackTraceWindow(); - m_Breakpoints->StopDebugging(); + g_Settings->SaveBool(Debugger_SteppingOps, false); m_Breakpoints->Resume(); m_RegisterTabs.SetColorsEnabled(false); m_RegisterTabs.RefreshEdits(); @@ -1132,7 +1132,7 @@ LRESULT CDebugCommandsView::OnForwardButton(WORD /*wNotifyCode*/, WORD /*wID*/, LRESULT CDebugCommandsView::OnViewPCButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) { - if (g_Reg != NULL && m_Breakpoints->isDebugging()) + if (g_Reg != NULL && isStepping()) { ShowAddress(g_Reg->m_PROGRAM_COUNTER, TRUE); } @@ -1330,7 +1330,7 @@ LRESULT CDebugCommandsView::OnPCChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND m_bIgnorePCChange = false; return 0; } - if (g_Reg != NULL && m_Breakpoints->isDebugging()) + if (g_Reg != NULL && isStepping()) { g_Reg->m_PROGRAM_COUNTER = m_PCEdit.GetValue(); } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h index fa426c9e2..5519098ac 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h @@ -70,7 +70,8 @@ public: class CDebugCommandsView : public CDebugDialog, public CDialogResize, - public CToolTipDialog + public CToolTipDialog, + public CDebugSettings { friend class CEditOp; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp index 06f6dae8e..9353f4bd1 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp @@ -263,9 +263,7 @@ void CRegisterTabs::RefreshEdits() void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam) { - CBreakpoints* breakpoints = ((CDebuggerUI*)g_Debugger)->Breakpoints(); - - if (g_Reg == NULL || !breakpoints->isDebugging()) + if (g_Reg == NULL || !isStepping()) { return; } @@ -709,8 +707,7 @@ BOOL CEditReg64::Attach(HWND hWndNew) LRESULT CEditReg64::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - CBreakpoints* breakpoints = ((CDebuggerUI*)g_Debugger)->Breakpoints(); - if (!breakpoints->isDebugging()) + if (!isStepping()) { goto canceled; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h index f3c8fcaf6..57de3d02d 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h @@ -11,7 +11,9 @@ #pragma once #include "Breakpoints.h" -class CEditReg64 : public CWindowImpl +class CEditReg64 : + public CWindowImpl, + private CDebugSettings { public: static uint64_t ParseValue(char* wordPair); @@ -28,7 +30,9 @@ public: END_MSG_MAP() }; -class CRegisterTabs : public CTabCtrl +class CRegisterTabs : + public CTabCtrl, + public CDebugSettings { private: typedef union diff --git a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp index f5285a4ca..bacc9e33d 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp @@ -103,7 +103,7 @@ LRESULT CDebugStackTrace::OnListDblClicked(NMHDR* pNMHDR) void CDebugStackTrace::Refresh() { - if (!m_Debugger->Breakpoints()->isDebugging()) + if (!isStepping()) { return; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h index fd1b0f66a..c46fef58a 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h @@ -21,7 +21,8 @@ typedef struct { class CDebugStackTrace : public CDebugDialog, - public CDialogResize + public CDialogResize, + private CDebugSettings { public: enum { IDD = IDD_Debugger_StackTrace }; diff --git a/Source/Project64/UserInterface/Debugger/Debugger.cpp b/Source/Project64/UserInterface/Debugger/Debugger.cpp index e544b136d..efff737b0 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger.cpp @@ -367,15 +367,11 @@ CDMALog* CDebuggerUI::DMALog() void CDebuggerUI::BreakpointHit() { -#ifdef tofix - m_Breakpoints->KeepDebugging(); -#endif + g_Settings->SaveBool(Debugger_SteppingOps, true); Debug_ShowCommandsLocation(g_Reg->m_PROGRAM_COUNTER, false); Debug_RefreshStackWindow(); Debug_RefreshStackTraceWindow(); -#ifdef tofix - m_Breakpoints->Pause(); -#endif + g_System->Pause(); } // CDebugger implementation @@ -392,7 +388,7 @@ bool CDebuggerUI::CPUStepStarted() uint32_t PROGRAM_COUNTER = g_Reg->m_PROGRAM_COUNTER; uint32_t JumpToLocation = R4300iOp::m_JumpToLocation; - m_ScriptSystem->HookCPUExec()->InvokeByParamInRange(PROGRAM_COUNTER); + //m_ScriptSystem->HookCPUExec()->InvokeByParamInRange(PROGRAM_COUNTER); // PC breakpoints @@ -408,7 +404,7 @@ bool CDebuggerUI::CPUStepStarted() if (op >= R4300i_LDL && op <= R4300i_SD && op != R4300i_CACHE) // Read and write instructions { - uint32_t memoryAddress = g_Reg->m_GPR[Opcode.base].UW[0] + (int16_t)Opcode.offset; + /*uint32_t memoryAddress = g_Reg->m_GPR[Opcode.base].UW[0] + (int16_t)Opcode.offset; if ((op <= R4300i_LWU || (op >= R4300i_LL && op <= R4300i_LD))) // Read instructions { @@ -448,10 +444,10 @@ bool CDebuggerUI::CPUStepStarted() } } } - } + }*/ } - if (!m_Breakpoints->isDebugging()) + if (!isStepping()) { return !m_Breakpoints->isSkipping(); } diff --git a/Source/Project64/UserInterface/Debugger/debugger.h b/Source/Project64/UserInterface/Debugger/debugger.h index 7cc96c4cf..d1c0ad8cc 100644 --- a/Source/Project64/UserInterface/Debugger/debugger.h +++ b/Source/Project64/UserInterface/Debugger/debugger.h @@ -10,6 +10,7 @@ ****************************************************************************/ #pragma once #include +#include class CDumpMemory; class CDebugMemoryView; @@ -27,7 +28,8 @@ class CBreakpoints; class CScriptSystem; class CDebuggerUI : - public CDebugger + public CDebugger, + public CDebugSettings { public: CDebuggerUI();