[Debugger] Change CBreakpoints::isDebugging() to a debug setting

This commit is contained in:
zilmar 2018-01-16 08:14:15 +11:00
parent ea1e0efbef
commit 8a668c4025
14 changed files with 42 additions and 59 deletions

View File

@ -13,11 +13,13 @@
int CDebugSettings::m_RefCount = 0; int CDebugSettings::m_RefCount = 0;
bool CDebugSettings::m_Registered = false;
bool CDebugSettings::m_bHaveDebugger = false; bool CDebugSettings::m_bHaveDebugger = false;
bool CDebugSettings::m_Stepping = true;
bool CDebugSettings::m_bRecordRecompilerAsm = false; bool CDebugSettings::m_bRecordRecompilerAsm = false;
bool CDebugSettings::m_bShowTLBMisses = false; bool CDebugSettings::m_bShowTLBMisses = false;
bool CDebugSettings::m_bShowDivByZero = false; bool CDebugSettings::m_bShowDivByZero = false;
bool CDebugSettings::m_Registered = false;
bool CDebugSettings::m_RecordExecutionTimes = false; bool CDebugSettings::m_RecordExecutionTimes = false;
bool CDebugSettings::m_HaveExecutionBP = 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_ShowTLBMisses, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_ShowDivByZero, 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_RecordExecutionTimes, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_SteppingOps, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_HaveExecutionBP, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_HaveExecutionBP, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
RefreshSettings(); RefreshSettings();
@ -48,6 +51,7 @@ CDebugSettings::~CDebugSettings()
g_Settings->UnregisterChangeCB(Debugger_ShowTLBMisses, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_ShowTLBMisses, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_ShowDivByZero, 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_RecordExecutionTimes, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_SteppingOps, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_HaveExecutionBP, 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_bShowTLBMisses = m_bHaveDebugger && g_Settings->LoadBool(Debugger_ShowTLBMisses);
m_bShowDivByZero = m_bHaveDebugger && g_Settings->LoadBool(Debugger_ShowDivByZero); m_bShowDivByZero = m_bHaveDebugger && g_Settings->LoadBool(Debugger_ShowDivByZero);
m_RecordExecutionTimes = g_Settings->LoadBool(Debugger_RecordExecutionTimes); m_RecordExecutionTimes = g_Settings->LoadBool(Debugger_RecordExecutionTimes);
m_Stepping = g_Settings->LoadBool(Debugger_SteppingOps);
m_HaveExecutionBP = g_Settings->LoadBool(Debugger_HaveExecutionBP); m_HaveExecutionBP = g_Settings->LoadBool(Debugger_HaveExecutionBP);
} }

View File

@ -19,6 +19,7 @@ public:
virtual ~CDebugSettings(); virtual ~CDebugSettings();
static inline bool bHaveDebugger(void) { return m_bHaveDebugger; } 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 bRecordRecompilerAsm(void) { return m_bRecordRecompilerAsm; }
static inline bool bShowTLBMisses(void) { return m_bShowTLBMisses; } static inline bool bShowTLBMisses(void) { return m_bShowTLBMisses; }
static inline bool bShowDivByZero(void) { return m_bShowDivByZero; } static inline bool bShowDivByZero(void) { return m_bShowDivByZero; }
@ -33,8 +34,8 @@ private:
void RefreshSettings(void); void RefreshSettings(void);
//Settings that can be changed on the fly
static bool m_bHaveDebugger; static bool m_bHaveDebugger;
static bool m_Stepping;
static bool m_bRecordRecompilerAsm; static bool m_bRecordRecompilerAsm;
static bool m_bShowTLBMisses; static bool m_bShowTLBMisses;
static bool m_bShowDivByZero; static bool m_bShowDivByZero;

View File

@ -229,6 +229,7 @@ enum SettingID
Debugger_ShowRecompMemSize, Debugger_ShowRecompMemSize,
Debugger_DebugLanguage, Debugger_DebugLanguage,
Debugger_RecordExecutionTimes, Debugger_RecordExecutionTimes,
Debugger_SteppingOps,
Debugger_HaveExecutionBP, Debugger_HaveExecutionBP,
//Trace //Trace

View File

@ -314,6 +314,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false)); AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false));
AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false)); AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false));
AddHandler(Debugger_RecordExecutionTimes, new CSettingTypeApplication("Debugger", "Record Execution Times", 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_HaveExecutionBP, new CSettingTypeTempBool(false));
AddHandler(Debugger_DebugLanguage, new CSettingTypeApplication("Debugger", "Debug Language", false)); AddHandler(Debugger_DebugLanguage, new CSettingTypeApplication("Debugger", "Debug Language", false));
AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false)); AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false));

View File

@ -19,36 +19,14 @@
CBreakpoints::CBreakpoints() CBreakpoints::CBreakpoints()
{ {
m_Debugging = FALSE;
m_Skipping = FALSE; m_Skipping = FALSE;
} }
void CBreakpoints::Pause()
{
KeepDebugging();
g_System->Pause();
}
void CBreakpoints::Resume() void CBreakpoints::Resume()
{ {
g_System->ExternalEvent(SysEvent_ResumeCPU_FromMenu); 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 CBreakpoints::isSkipping()
{ {
bool ret = m_Skipping; bool ret = m_Skipping;

View File

@ -40,9 +40,6 @@ public:
void Resume(); void Resume();
void Skip(); void Skip();
bool isDebugging();
void KeepDebugging();
void StopDebugging();
bool isSkipping(); bool isSkipping();
bool RBPAdd(uint32_t address, bool bTemporary = false); bool RBPAdd(uint32_t address, bool bTemporary = false);
@ -67,6 +64,5 @@ private:
breakpoints_t m_WriteMem; breakpoints_t m_WriteMem;
breakpoints_t m_Execution; breakpoints_t m_Execution;
bool m_Debugging;
bool m_Skipping; bool m_Skipping;
}; };

View File

@ -120,7 +120,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
m_AddressEdit.SetValue(0x80000000, false, true); m_AddressEdit.SetValue(0x80000000, false, true);
ShowAddress(0x80000000, TRUE); ShowAddress(0x80000000, TRUE);
if (m_Breakpoints->isDebugging()) if (isStepping())
{ {
m_ViewPCButton.EnableWindow(TRUE); m_ViewPCButton.EnableWindow(TRUE);
m_StepButton.EnableWindow(TRUE); m_StepButton.EnableWindow(TRUE);
@ -491,7 +491,7 @@ void CDebugCommandsView::ShowAddress(DWORD address, BOOL top)
{ {
m_StartAddress = address; m_StartAddress = address;
if (!m_Breakpoints->isDebugging()) if (!isStepping())
{ {
// Disable buttons // Disable buttons
m_ViewPCButton.EnableWindow(FALSE); m_ViewPCButton.EnableWindow(FALSE);
@ -756,7 +756,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc
RGB(0xFF, 0xEE, 0xCC); RGB(0xFF, 0xEE, 0xCC);
} }
else if (address == pc && m_Breakpoints->isDebugging()) else if (address == pc && isStepping())
{ {
// pc // pc
pLVCD->clrTextBk = RGB(0x88, 0x88, 0x88); pLVCD->clrTextBk = RGB(0x88, 0x88, 0x88);
@ -793,7 +793,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
{ {
colors = { 0xFFFFFF, 0xFF0000 }; colors = { 0xFFFFFF, 0xFF0000 };
} }
else if (address == pc && m_Breakpoints->isDebugging()) else if (address == pc && isStepping())
{ {
colors = { 0xFFFFAA, 0x222200 }; colors = { 0xFFFFAA, 0x222200 };
} }
@ -838,7 +838,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
pLVCD->clrTextBk = _byteswap_ulong(colors.bg) >> 8; pLVCD->clrTextBk = _byteswap_ulong(colors.bg) >> 8;
pLVCD->clrText = _byteswap_ulong(colors.fg) >> 8; pLVCD->clrText = _byteswap_ulong(colors.fg) >> 8;
if (!m_Breakpoints->isDebugging()) if (!isStepping())
{ {
return CDRF_DODEFAULT; return CDRF_DODEFAULT;
} }
@ -1084,7 +1084,7 @@ void CDebugCommandsView::RemoveSelectedBreakpoints()
void CDebugCommandsView::CPUSkip() void CDebugCommandsView::CPUSkip()
{ {
m_Breakpoints->KeepDebugging(); g_Settings->SaveBool(Debugger_SteppingOps, true);
m_Breakpoints->Skip(); m_Breakpoints->Skip();
m_Breakpoints->Resume(); m_Breakpoints->Resume();
} }
@ -1093,7 +1093,7 @@ void CDebugCommandsView::CPUStepInto()
{ {
m_Debugger->Debug_RefreshStackWindow(); m_Debugger->Debug_RefreshStackWindow();
m_Debugger->Debug_RefreshStackTraceWindow(); m_Debugger->Debug_RefreshStackTraceWindow();
m_Breakpoints->KeepDebugging(); g_Settings->SaveBool(Debugger_SteppingOps, true);
m_Breakpoints->Resume(); m_Breakpoints->Resume();
} }
@ -1101,7 +1101,7 @@ void CDebugCommandsView::CPUResume()
{ {
m_Debugger->Debug_RefreshStackWindow(); m_Debugger->Debug_RefreshStackWindow();
m_Debugger->Debug_RefreshStackTraceWindow(); m_Debugger->Debug_RefreshStackTraceWindow();
m_Breakpoints->StopDebugging(); g_Settings->SaveBool(Debugger_SteppingOps, false);
m_Breakpoints->Resume(); m_Breakpoints->Resume();
m_RegisterTabs.SetColorsEnabled(false); m_RegisterTabs.SetColorsEnabled(false);
m_RegisterTabs.RefreshEdits(); 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*/) 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); ShowAddress(g_Reg->m_PROGRAM_COUNTER, TRUE);
} }
@ -1330,7 +1330,7 @@ LRESULT CDebugCommandsView::OnPCChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND
m_bIgnorePCChange = false; m_bIgnorePCChange = false;
return 0; return 0;
} }
if (g_Reg != NULL && m_Breakpoints->isDebugging()) if (g_Reg != NULL && isStepping())
{ {
g_Reg->m_PROGRAM_COUNTER = m_PCEdit.GetValue(); g_Reg->m_PROGRAM_COUNTER = m_PCEdit.GetValue();
} }

View File

@ -70,7 +70,8 @@ public:
class CDebugCommandsView : class CDebugCommandsView :
public CDebugDialog<CDebugCommandsView>, public CDebugDialog<CDebugCommandsView>,
public CDialogResize<CDebugCommandsView>, public CDialogResize<CDebugCommandsView>,
public CToolTipDialog<CDebugCommandsView> public CToolTipDialog<CDebugCommandsView>,
public CDebugSettings
{ {
friend class CEditOp; friend class CEditOp;

View File

@ -263,9 +263,7 @@ void CRegisterTabs::RefreshEdits()
void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam) void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam)
{ {
CBreakpoints* breakpoints = ((CDebuggerUI*)g_Debugger)->Breakpoints(); if (g_Reg == NULL || !isStepping())
if (g_Reg == NULL || !breakpoints->isDebugging())
{ {
return; return;
} }
@ -709,8 +707,7 @@ BOOL CEditReg64::Attach(HWND hWndNew)
LRESULT CEditReg64::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CEditReg64::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
CBreakpoints* breakpoints = ((CDebuggerUI*)g_Debugger)->Breakpoints(); if (!isStepping())
if (!breakpoints->isDebugging())
{ {
goto canceled; goto canceled;
} }

View File

@ -11,7 +11,9 @@
#pragma once #pragma once
#include "Breakpoints.h" #include "Breakpoints.h"
class CEditReg64 : public CWindowImpl<CEditReg64, CEdit> class CEditReg64 :
public CWindowImpl<CEditReg64, CEdit>,
private CDebugSettings
{ {
public: public:
static uint64_t ParseValue(char* wordPair); static uint64_t ParseValue(char* wordPair);
@ -28,7 +30,9 @@ public:
END_MSG_MAP() END_MSG_MAP()
}; };
class CRegisterTabs : public CTabCtrl class CRegisterTabs :
public CTabCtrl,
public CDebugSettings
{ {
private: private:
typedef union typedef union

View File

@ -103,7 +103,7 @@ LRESULT CDebugStackTrace::OnListDblClicked(NMHDR* pNMHDR)
void CDebugStackTrace::Refresh() void CDebugStackTrace::Refresh()
{ {
if (!m_Debugger->Breakpoints()->isDebugging()) if (!isStepping())
{ {
return; return;
} }

View File

@ -21,7 +21,8 @@ typedef struct {
class CDebugStackTrace : class CDebugStackTrace :
public CDebugDialog<CDebugStackTrace>, public CDebugDialog<CDebugStackTrace>,
public CDialogResize<CDebugStackTrace> public CDialogResize<CDebugStackTrace>,
private CDebugSettings
{ {
public: public:
enum { IDD = IDD_Debugger_StackTrace }; enum { IDD = IDD_Debugger_StackTrace };

View File

@ -367,15 +367,11 @@ CDMALog* CDebuggerUI::DMALog()
void CDebuggerUI::BreakpointHit() void CDebuggerUI::BreakpointHit()
{ {
#ifdef tofix g_Settings->SaveBool(Debugger_SteppingOps, true);
m_Breakpoints->KeepDebugging();
#endif
Debug_ShowCommandsLocation(g_Reg->m_PROGRAM_COUNTER, false); Debug_ShowCommandsLocation(g_Reg->m_PROGRAM_COUNTER, false);
Debug_RefreshStackWindow(); Debug_RefreshStackWindow();
Debug_RefreshStackTraceWindow(); Debug_RefreshStackTraceWindow();
#ifdef tofix g_System->Pause();
m_Breakpoints->Pause();
#endif
} }
// CDebugger implementation // CDebugger implementation
@ -392,7 +388,7 @@ bool CDebuggerUI::CPUStepStarted()
uint32_t PROGRAM_COUNTER = g_Reg->m_PROGRAM_COUNTER; uint32_t PROGRAM_COUNTER = g_Reg->m_PROGRAM_COUNTER;
uint32_t JumpToLocation = R4300iOp::m_JumpToLocation; uint32_t JumpToLocation = R4300iOp::m_JumpToLocation;
m_ScriptSystem->HookCPUExec()->InvokeByParamInRange(PROGRAM_COUNTER); //m_ScriptSystem->HookCPUExec()->InvokeByParamInRange(PROGRAM_COUNTER);
// PC breakpoints // PC breakpoints
@ -408,7 +404,7 @@ bool CDebuggerUI::CPUStepStarted()
if (op >= R4300i_LDL && op <= R4300i_SD && op != R4300i_CACHE) // Read and write instructions 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 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(); return !m_Breakpoints->isSkipping();
} }

View File

@ -10,6 +10,7 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64-core/Debugger.h> #include <Project64-core/Debugger.h>
#include <Project64-core/Settings/DebugSettings.h>
class CDumpMemory; class CDumpMemory;
class CDebugMemoryView; class CDebugMemoryView;
@ -27,7 +28,8 @@ class CBreakpoints;
class CScriptSystem; class CScriptSystem;
class CDebuggerUI : class CDebuggerUI :
public CDebugger public CDebugger,
public CDebugSettings
{ {
public: public:
CDebuggerUI(); CDebuggerUI();