[Debugger] Make waiting for step a setting
This commit is contained in:
parent
7d9d54aaa8
commit
8a85f1e6a4
|
@ -23,7 +23,10 @@ __interface CDebugger
|
|||
virtual void OpenStackTraceWindow(void) = 0;
|
||||
virtual void OpenStackViewWindow(void) = 0;
|
||||
virtual void TLBChanged(void) = 0;
|
||||
virtual void FrameDrawn(void) = 0;
|
||||
virtual void WaitForStep(void) = 0;
|
||||
virtual bool ExecutionBP(uint32_t address) = 0;
|
||||
|
||||
virtual bool CPUStepStarted(void) = 0;
|
||||
virtual void CPUStep(void) = 0;
|
||||
virtual void FrameDrawn(void) = 0;
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
void CN64System::StartEmulationThead()
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Start");
|
||||
|
||||
CThread * thread = new CThread((CThread::CTHREAD_START_ROUTINE)StartEmulationThread);
|
||||
thread->Start(thread);
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done");
|
||||
|
|
|
@ -298,6 +298,18 @@ void CInterpreterCPU::ExecuteCPU()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (isDebugging())
|
||||
{
|
||||
if (HaveExecutionBP() && g_Debugger->ExecutionBP(PROGRAM_COUNTER))
|
||||
{
|
||||
g_Settings->SaveBool(Debugger_SteppingOps, true);
|
||||
}
|
||||
if (isStepping())
|
||||
{
|
||||
g_Debugger->WaitForStep();
|
||||
}
|
||||
}
|
||||
|
||||
if (CDebugSettings::HaveDebugger() && !g_Debugger->CPUStepStarted())
|
||||
{
|
||||
// Skip command if instructed by the debugger
|
||||
|
|
|
@ -18,6 +18,7 @@ bool CDebugSettings::m_Registered = false;
|
|||
bool CDebugSettings::m_HaveDebugger = true;
|
||||
bool CDebugSettings::m_Debugging = true;
|
||||
bool CDebugSettings::m_Stepping = true;
|
||||
bool CDebugSettings::m_WaitingForStep = false;
|
||||
bool CDebugSettings::m_bRecordRecompilerAsm = false;
|
||||
bool CDebugSettings::m_bShowTLBMisses = false;
|
||||
bool CDebugSettings::m_bShowDivByZero = false;
|
||||
|
@ -37,6 +38,7 @@ CDebugSettings::CDebugSettings()
|
|||
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_WaitingForStep, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
|
||||
|
||||
RefreshSettings();
|
||||
}
|
||||
|
@ -54,6 +56,7 @@ CDebugSettings::~CDebugSettings()
|
|||
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_WaitingForStep, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +68,8 @@ void CDebugSettings::RefreshSettings()
|
|||
m_bShowDivByZero = m_HaveDebugger && g_Settings->LoadBool(Debugger_ShowDivByZero);
|
||||
m_RecordExecutionTimes = g_Settings->LoadBool(Debugger_RecordExecutionTimes);
|
||||
m_Stepping = g_Settings->LoadBool(Debugger_SteppingOps);
|
||||
m_WaitingForStep = g_Settings->LoadBool(Debugger_WaitingForStep);
|
||||
m_HaveExecutionBP = g_Settings->LoadBool(Debugger_HaveExecutionBP);
|
||||
|
||||
m_Debugging = m_HaveDebugger && m_HaveExecutionBP;
|
||||
m_Debugging = m_HaveDebugger && (m_HaveExecutionBP || m_WaitingForStep);
|
||||
}
|
|
@ -21,6 +21,7 @@ public:
|
|||
static inline bool HaveDebugger(void) { return m_HaveDebugger; }
|
||||
static inline bool isDebugging(void) { return m_Debugging; }
|
||||
static inline bool isStepping(void) { return m_Stepping; }
|
||||
static inline bool WaitingForStep(void) { return m_WaitingForStep; }
|
||||
static inline bool bRecordRecompilerAsm(void) { return m_bRecordRecompilerAsm; }
|
||||
static inline bool bShowTLBMisses(void) { return m_bShowTLBMisses; }
|
||||
static inline bool bShowDivByZero(void) { return m_bShowDivByZero; }
|
||||
|
@ -38,6 +39,7 @@ private:
|
|||
static bool m_HaveDebugger;
|
||||
static bool m_Debugging;
|
||||
static bool m_Stepping;
|
||||
static bool m_WaitingForStep;
|
||||
static bool m_bRecordRecompilerAsm;
|
||||
static bool m_bShowTLBMisses;
|
||||
static bool m_bShowDivByZero;
|
||||
|
|
|
@ -231,6 +231,7 @@ enum SettingID
|
|||
Debugger_RecordExecutionTimes,
|
||||
Debugger_SteppingOps,
|
||||
Debugger_HaveExecutionBP,
|
||||
Debugger_WaitingForStep,
|
||||
|
||||
//Trace
|
||||
Debugger_TraceMD5,
|
||||
|
|
|
@ -316,6 +316,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
|
|||
AddHandler(Debugger_RecordExecutionTimes, new CSettingTypeApplication("Debugger", "Record Execution Times", false));
|
||||
AddHandler(Debugger_SteppingOps, new CSettingTypeTempBool(false));
|
||||
AddHandler(Debugger_HaveExecutionBP, new CSettingTypeTempBool(false));
|
||||
AddHandler(Debugger_WaitingForStep, new CSettingTypeTempBool(false));
|
||||
AddHandler(Debugger_DebugLanguage, new CSettingTypeApplication("Debugger", "Debug Language", false));
|
||||
AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false));
|
||||
AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t)false));
|
||||
|
|
|
@ -22,11 +22,6 @@ CBreakpoints::CBreakpoints()
|
|||
m_Skipping = FALSE;
|
||||
}
|
||||
|
||||
void CBreakpoints::Resume()
|
||||
{
|
||||
g_System->ExternalEvent(SysEvent_ResumeCPU_FromMenu);
|
||||
}
|
||||
|
||||
bool CBreakpoints::isSkipping()
|
||||
{
|
||||
bool ret = m_Skipping;
|
||||
|
|
|
@ -36,8 +36,6 @@ public:
|
|||
BPSTATE WriteBPExists(uint32_t address, bool bRemoveTemp = false);
|
||||
BPSTATE ExecutionBPExists(uint32_t address, bool bRemoveTemp = false);
|
||||
|
||||
void Pause();
|
||||
void Resume();
|
||||
void Skip();
|
||||
|
||||
bool isSkipping();
|
||||
|
|
|
@ -45,9 +45,10 @@ void CCommandList::Attach(HWND hWndNew)
|
|||
CDebugCommandsView* CDebugCommandsView::_this = NULL;
|
||||
HHOOK CDebugCommandsView::hWinMessageHook = NULL;
|
||||
|
||||
CDebugCommandsView::CDebugCommandsView(CDebuggerUI * debugger) :
|
||||
CDebugCommandsView::CDebugCommandsView(CDebuggerUI * debugger, SyncEvent &StepEvent) :
|
||||
CDebugDialog<CDebugCommandsView>(debugger),
|
||||
CToolTipDialog<CDebugCommandsView>()
|
||||
CToolTipDialog<CDebugCommandsView>(),
|
||||
m_StepEvent(StepEvent)
|
||||
{
|
||||
m_HistoryIndex = -1;
|
||||
m_bIgnoreAddrChange = false;
|
||||
|
@ -64,6 +65,9 @@ CDebugCommandsView::~CDebugCommandsView()
|
|||
|
||||
LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
g_Settings->RegisterChangeCB(Debugger_WaitingForStep, this, (CSettings::SettingChangedFunc)StaticWaitingForStepChanged);
|
||||
g_Settings->RegisterChangeCB(Debugger_SteppingOps, this, (CSettings::SettingChangedFunc)StaticSteppingOpsChanged);
|
||||
|
||||
m_CommandList.Attach(GetDlgItem(IDC_CMD_LIST));
|
||||
m_BreakpointList.Attach(GetDlgItem(IDC_BP_LIST));
|
||||
m_AddressEdit.Attach(GetDlgItem(IDC_ADDR_EDIT));
|
||||
|
@ -139,6 +143,9 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
|
|||
|
||||
LRESULT CDebugCommandsView::OnDestroy(void)
|
||||
{
|
||||
g_Settings->UnregisterChangeCB(Debugger_SteppingOps, this, (CSettings::SettingChangedFunc)StaticSteppingOpsChanged);
|
||||
g_Settings->UnregisterChangeCB(Debugger_WaitingForStep, this, (CSettings::SettingChangedFunc)StaticWaitingForStepChanged);
|
||||
|
||||
UnhookWindowsHookEx(hWinMessageHook);
|
||||
m_OpEdit.Detach();
|
||||
m_ForwardButton.Detach();
|
||||
|
@ -161,7 +168,12 @@ void CDebugCommandsView::InterceptKeyDown(WPARAM wParam, LPARAM /*lParam*/)
|
|||
switch (wParam)
|
||||
{
|
||||
case VK_F1: CPUSkip(); break;
|
||||
case VK_F2: CPUStepInto(); break;
|
||||
case VK_F2:
|
||||
if (WaitingForStep())
|
||||
{
|
||||
m_StepEvent.Trigger();
|
||||
}
|
||||
break;
|
||||
case VK_F3:
|
||||
// reserved step over
|
||||
break;
|
||||
|
@ -1084,28 +1096,16 @@ void CDebugCommandsView::RemoveSelectedBreakpoints()
|
|||
|
||||
void CDebugCommandsView::CPUSkip()
|
||||
{
|
||||
g_Settings->SaveBool(Debugger_SteppingOps, true);
|
||||
m_Breakpoints->Skip();
|
||||
m_Breakpoints->Resume();
|
||||
}
|
||||
|
||||
void CDebugCommandsView::CPUStepInto()
|
||||
{
|
||||
m_Debugger->Debug_RefreshStackWindow();
|
||||
m_Debugger->Debug_RefreshStackTraceWindow();
|
||||
g_Settings->SaveBool(Debugger_SteppingOps, true);
|
||||
m_Breakpoints->Resume();
|
||||
}
|
||||
|
||||
void CDebugCommandsView::CPUResume()
|
||||
{
|
||||
m_Debugger->Debug_RefreshStackWindow();
|
||||
m_Debugger->Debug_RefreshStackTraceWindow();
|
||||
g_Settings->SaveBool(Debugger_SteppingOps, false);
|
||||
m_Breakpoints->Resume();
|
||||
m_RegisterTabs.SetColorsEnabled(false);
|
||||
m_RegisterTabs.RefreshEdits();
|
||||
ShowAddress(m_StartAddress, TRUE);
|
||||
if (WaitingForStep())
|
||||
{
|
||||
m_StepEvent.Trigger();
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CDebugCommandsView::OnBackButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/)
|
||||
|
@ -1161,8 +1161,10 @@ LRESULT CDebugCommandsView::OnGoButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND
|
|||
|
||||
LRESULT CDebugCommandsView::OnStepButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CPUStepInto();
|
||||
m_AddressEdit.SetFocus();
|
||||
if (WaitingForStep())
|
||||
{
|
||||
m_StepEvent.Trigger();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1473,9 +1475,6 @@ LRESULT CDebugCommandsView::OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lP
|
|||
{
|
||||
CheckCPUType();
|
||||
}
|
||||
|
||||
ShowAddress(m_StartAddress, TRUE);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1513,10 +1512,10 @@ LRESULT CDebugCommandsView::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lPar
|
|||
switch (type)
|
||||
{
|
||||
case SB_LINEUP:
|
||||
ShowAddress(m_StartAddress - 8, TRUE);
|
||||
ShowAddress(m_StartAddress - 4, TRUE);
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
ShowAddress(m_StartAddress + 8, TRUE);
|
||||
ShowAddress(m_StartAddress + 4, TRUE);
|
||||
break;
|
||||
case SB_THUMBTRACK:
|
||||
{
|
||||
|
@ -1529,6 +1528,37 @@ LRESULT CDebugCommandsView::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lPar
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void CDebugCommandsView::WaitingForStepChanged(void)
|
||||
{
|
||||
if (WaitingForStep())
|
||||
{
|
||||
ShowAddress(g_Reg->m_PROGRAM_COUNTER, false);
|
||||
m_Debugger->Debug_RefreshStackWindow();
|
||||
m_Debugger->Debug_RefreshStackTraceWindow();
|
||||
m_StepButton.EnableWindow(true);
|
||||
m_GoButton.EnableWindow(true);
|
||||
m_AddressEdit.SetFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_StepButton.EnableWindow(false);
|
||||
m_GoButton.EnableWindow(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CDebugCommandsView::SteppingOpsChanged(void)
|
||||
{
|
||||
if (!g_Settings->LoadBool(Debugger_SteppingOps))
|
||||
{
|
||||
m_Debugger->Debug_RefreshStackWindow();
|
||||
m_Debugger->Debug_RefreshStackTraceWindow();
|
||||
m_RegisterTabs.SetColorsEnabled(false);
|
||||
m_RegisterTabs.RefreshEdits();
|
||||
ShowAddress(m_StartAddress, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDebugCommandsView::Reset()
|
||||
{
|
||||
ClearEditedOps();
|
||||
|
|
|
@ -78,7 +78,7 @@ class CDebugCommandsView :
|
|||
public:
|
||||
enum { IDD = IDD_Debugger_Commands };
|
||||
|
||||
CDebugCommandsView(CDebuggerUI * debugger);
|
||||
CDebugCommandsView(CDebuggerUI * debugger, SyncEvent &StepEvent);
|
||||
virtual ~CDebugCommandsView(void);
|
||||
|
||||
void ShowAddress(DWORD address, BOOL top);
|
||||
|
@ -160,6 +160,9 @@ private:
|
|||
TOOLTIP(IDC_SYMBOLS_BTN, "Symbols...")
|
||||
END_TOOLTIP_MAP()
|
||||
|
||||
static void StaticSteppingOpsChanged(CDebugCommandsView * __this) { __this->SteppingOpsChanged(); }
|
||||
static void StaticWaitingForStepChanged(CDebugCommandsView * __this) { __this->WaitingForStepChanged(); }
|
||||
|
||||
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
@ -228,8 +231,9 @@ private:
|
|||
static const char* GetDataAddressNotes(uint32_t vAddr);
|
||||
|
||||
void CPUSkip();
|
||||
void CPUStepInto();
|
||||
void CPUResume();
|
||||
void WaitingForStepChanged(void);
|
||||
void SteppingOpsChanged(void);
|
||||
|
||||
void AddBranchArrow(int startPos, int endPos);
|
||||
void ClearBranchArrows();
|
||||
|
@ -257,6 +261,7 @@ private:
|
|||
CScrollBar m_Scrollbar;
|
||||
|
||||
CRegisterTabs m_RegisterTabs;
|
||||
SyncEvent & m_StepEvent;
|
||||
|
||||
CButton m_BackButton;
|
||||
CButton m_ForwardButton;
|
||||
|
|
|
@ -30,7 +30,8 @@ CDebuggerUI::CDebuggerUI() :
|
|||
m_StackTrace(NULL),
|
||||
m_StackView(NULL),
|
||||
m_DMALogView(NULL),
|
||||
m_DMALog(NULL)
|
||||
m_DMALog(NULL),
|
||||
m_StepEvent(false)
|
||||
{
|
||||
g_Debugger = this;
|
||||
|
||||
|
@ -238,7 +239,7 @@ void CDebuggerUI::OpenCommandWindow()
|
|||
{
|
||||
if (m_CommandsView == NULL)
|
||||
{
|
||||
m_CommandsView = new CDebugCommandsView(this);
|
||||
m_CommandsView = new CDebugCommandsView(this, m_StepEvent);
|
||||
}
|
||||
m_CommandsView->ShowWindow();
|
||||
}
|
||||
|
@ -365,15 +366,6 @@ CDMALog* CDebuggerUI::DMALog()
|
|||
return m_DMALog;
|
||||
}
|
||||
|
||||
void CDebuggerUI::BreakpointHit()
|
||||
{
|
||||
g_Settings->SaveBool(Debugger_SteppingOps, true);
|
||||
Debug_ShowCommandsLocation(g_Reg->m_PROGRAM_COUNTER, false);
|
||||
Debug_RefreshStackWindow();
|
||||
Debug_RefreshStackTraceWindow();
|
||||
g_System->Pause();
|
||||
}
|
||||
|
||||
// CDebugger implementation
|
||||
|
||||
void CDebuggerUI::TLBChanged()
|
||||
|
@ -390,13 +382,6 @@ bool CDebuggerUI::CPUStepStarted()
|
|||
|
||||
m_ScriptSystem->HookCPUExec()->InvokeByParamInRange(PROGRAM_COUNTER);
|
||||
|
||||
// PC breakpoints
|
||||
|
||||
if (isDebugging() && m_Breakpoints->ExecutionBPExists(PROGRAM_COUNTER, true))
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
|
||||
// Memory breakpoints
|
||||
|
||||
OPCODE Opcode = R4300iOp::m_Opcode;
|
||||
|
@ -466,7 +451,7 @@ bool CDebuggerUI::CPUStepStarted()
|
|||
return !m_Breakpoints->isSkipping();
|
||||
|
||||
breakpoint_hit:
|
||||
BreakpointHit();
|
||||
g_Settings->SaveBool(Debugger_SteppingOps, true);
|
||||
return !m_Breakpoints->isSkipping();
|
||||
}
|
||||
|
||||
|
@ -532,4 +517,16 @@ void CDebuggerUI::FrameDrawn()
|
|||
m_ScriptSystem->HookFrameDrawn()->InvokeAll();
|
||||
|
||||
ReleaseDC(hMainWnd, hdc);
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::WaitForStep(void)
|
||||
{
|
||||
g_Settings->SaveBool(Debugger_WaitingForStep, true);
|
||||
m_StepEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT);
|
||||
g_Settings->SaveBool(Debugger_WaitingForStep, false);
|
||||
}
|
||||
|
||||
bool CDebuggerUI::ExecutionBP(uint32_t address)
|
||||
{
|
||||
return m_Breakpoints != NULL && m_Breakpoints->ExecutionBPExists(address, true) != CBreakpoints::BP_NOT_SET;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Common/SyncEvent.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
|
||||
class CDumpMemory;
|
||||
|
@ -51,7 +52,7 @@ private:
|
|||
CScriptSystem * m_ScriptSystem;
|
||||
CDMALog * m_DMALog;
|
||||
|
||||
void BreakpointHit(void);
|
||||
SyncEvent m_StepEvent;
|
||||
|
||||
protected:
|
||||
void TLBChanged(void);
|
||||
|
@ -81,6 +82,9 @@ public:
|
|||
void Debug_RefreshStackTraceWindow(void);
|
||||
void OpenDMALogWindow(void);
|
||||
|
||||
bool ExecutionBP(uint32_t address);
|
||||
void WaitForStep(void);
|
||||
|
||||
CBreakpoints* Breakpoints();
|
||||
CDebugSymbols* Symbols();
|
||||
CScriptSystem* ScriptSystem();
|
||||
|
|
Loading…
Reference in New Issue