[Proeject64] Add execution break point in recompiler

This commit is contained in:
zilmar 2018-01-21 10:18:52 +11:00
parent 2c802bd638
commit 0ffb6bb159
13 changed files with 96 additions and 41 deletions

View File

@ -54,6 +54,7 @@ const char * SystemEventName(SystemEvent event)
case SysEvent_Interrupt_DP: return "SysEvent_Interrupt_DP";
case SysEvent_ResetFunctionTimes: return "SysEvent_ResetFunctionTimes";
case SysEvent_DumpFunctionTimes: return "SysEvent_DumpFunctionTimes";
case SysEvent_ResetRecompilerCode: return "SysEvent_ResetRecompilerCode";
}
static char unknown[100];
sprintf(unknown, "unknown(%d)", event);
@ -256,6 +257,9 @@ void CSystemEvents::ExecuteEvents()
bPause = true;
}
break;
case SysEvent_ResetRecompilerCode:
g_Recompiler->ResetRecompCode(true);
break;
default:
g_Notify->BreakPoint(__FILE__, __LINE__);
break;

View File

@ -51,6 +51,7 @@ enum SystemEvent
SysEvent_Interrupt_DP,
SysEvent_ResetFunctionTimes,
SysEvent_DumpFunctionTimes,
SysEvent_ResetRecompilerCode,
};
const char * SystemEventName(SystemEvent event);

View File

@ -202,6 +202,7 @@ void CN64System::ExternalEvent(SystemEvent action)
case SysEvent_PauseCPU_FromMenu:
case SysEvent_ResetFunctionTimes:
case SysEvent_DumpFunctionTimes:
case SysEvent_ResetRecompilerCode:
QueueEvent(action);
break;
case SysEvent_PauseCPU_AppLostFocus:
@ -1164,6 +1165,10 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
}
}
if (m_Random.get_state() != SecondCPU->m_Random.get_state())
{
ErrorFound = true;
}
if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; }
if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; }
if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; }

View File

@ -5388,6 +5388,11 @@ void CArmRecompilerOps::CompileWriteTLBMiss(ArmReg AddressReg, ArmReg LookUpReg)
m_RegWorkingSet.SetArmRegProtected(TlbStoreReg, false);
}
void CArmRecompilerOps::CompileExecuteBP(void)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
CRegInfo & CArmRecompilerOps::GetRegWorkingSet(void)
{
return m_RegWorkingSet;

View File

@ -224,6 +224,7 @@ private:
void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet);
void CompileReadTLBMiss(ArmReg AddressReg, ArmReg LookUpReg);
void CompileWriteTLBMiss(ArmReg AddressReg, ArmReg LookUpReg);
void CompileExecuteBP(void);
/********* Helper Functions *********/
typedef CRegInfo::REG_STATE REG_STATE;

View File

@ -20,6 +20,7 @@
#include <Project64-core/N64System/Recompiler/LoopAnalysis.h>
#include <Project64-core/N64System/Recompiler/SectionInfo.h>
#include <Project64-core/ExceptionHandler.h>
#include <Project64-core/Debugger.h>
void InPermLoop();
@ -474,6 +475,13 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
{
m_BlockInfo->SetVAddrLast(m_RecompilerOps->GetCurrentPC());
}
if (isDebugging() && HaveExecutionBP() && g_Debugger->ExecutionBP(m_RecompilerOps->GetCurrentPC()))
{
m_RecompilerOps->CompileExecuteBP();
break;
}
m_RecompilerOps->PreCompileOpcode();
switch (Opcode.op)

View File

@ -14,7 +14,8 @@
class CCodeBlock;
class CCodeSection
class CCodeSection :
private CDebugSettings
{
public:
typedef std::list<CCodeSection *> SECTION_LIST;

View File

@ -222,4 +222,5 @@ public:
virtual void PreCompileOpcode(void) = 0;
virtual void PostCompileOpcode(void) = 0;
virtual void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false) = 0;
virtual void CompileExecuteBP(void) = 0;
};

View File

@ -26,6 +26,7 @@
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
#include <Project64-core/N64System/N64Class.h>
#include <Project64-core/ExceptionHandler.h>
#include <Project64-core/Debugger.h>
#include <stdio.h>
CCodeSection * CX86RecompilerOps::m_Section = NULL;
@ -46,6 +47,46 @@ g_Notify->BreakPoint(__FILE__, __LINE__);
}
}*/
void x86_compiler_Break_Point()
{
g_Settings->SaveBool(Debugger_SteppingOps, true);
do
{
g_Debugger->WaitForStep();
if (CDebugSettings::SkipOp())
{
// Skip command if instructed by the debugger
g_Settings->SaveBool(Debugger_SkipOp, false);
g_Reg->m_PROGRAM_COUNTER += 4;
uint32_t OpcodeValue;
if (!g_MMU->LW_VAddr(g_Reg->m_PROGRAM_COUNTER, OpcodeValue))
{
g_Reg->DoTLBReadMiss(false, g_Reg->m_PROGRAM_COUNTER);
continue;
}
continue;
}
CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, g_System->CountPerOp());
g_System->SyncCPU(g_SyncSystem);
}
} while (CDebugSettings::isStepping());
if (R4300iOp::m_NextInstruction != NORMAL)
{
CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, g_System->CountPerOp());
g_System->SyncCPU(g_SyncSystem);
}
}
}
void CX86RecompilerOps::PreCompileOpcode(void)
{
if (m_NextInstruction != DELAY_SLOT_DONE)
@ -9705,6 +9746,32 @@ void CX86RecompilerOps::CompileSystemCheck(uint32_t TargetPC, const CRegInfo & R
SetJump32(Jump, (uint32_t *)*g_RecompPos);
}
void CX86RecompilerOps::CompileExecuteBP(void)
{
bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
if (bDelay)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
m_RegWorkingSet.WriteBackRegisters();
UpdateCounters(m_RegWorkingSet, true, true);
if (g_SyncSystem)
{
#ifdef _WIN32
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
#else
PushImm32((uint32_t)g_BaseSystem);
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
AddConstToX86Reg(x86_ESP, 4);
#endif
}
Call_Direct((void *)x86_compiler_Break_Point, "x86_compiler_Break_Point");
ExitCodeBlock();
m_NextInstruction = END_BLOCK;
}
void CX86RecompilerOps::OverflowDelaySlot(bool TestTimer)
{
m_RegWorkingSet.WriteBackRegisters();

View File

@ -234,6 +234,7 @@ public:
static void UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles);
void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false);
void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet);
void CompileExecuteBP(void);
static void ChangeDefaultRoundingModel();
void OverflowDelaySlot(bool TestTimer);

View File

@ -52,6 +52,7 @@ bool CBreakpoints::AddExecution(uint32_t address, bool bTemporary)
{
g_Settings->SaveBool(Debugger_HaveExecutionBP, true);
}
g_BaseSystem->ExternalEvent(SysEvent_ResetRecompilerCode);
return !res.second;
}

View File

@ -85,8 +85,6 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
DlgResize_Init(false, true);
DlgToolTip_Init();
CheckCPUType();
GetWindowRect(&m_DefaultWindowRect);
// Setup address input
@ -248,25 +246,6 @@ LRESULT CDebugCommandsView::OnOpKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*l
return 1;
}
void CDebugCommandsView::CheckCPUType()
{
CPU_TYPE cpuType;
if (g_Settings->LoadBool(Setting_ForceInterpreterCPU))
{
cpuType = CPU_Interpreter;
}
else
{
cpuType = g_System->CpuType();
}
if (cpuType != CPU_Interpreter)
{
MessageBox("Interpreter mode required", "Invalid CPU Type", MB_OK);
}
}
// Check if KSEG0 addr is out of bounds
bool CDebugCommandsView::AddressSafe(uint32_t vaddr)
{
@ -1460,22 +1439,6 @@ LRESULT CDebugCommandsView::OnListBoxClicked(WORD /*wNotifyCode*/, WORD wID, HWN
return FALSE;
}
LRESULT CDebugCommandsView::OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
WORD type = LOWORD(wParam);
if (type == WA_INACTIVE)
{
return FALSE;
}
if (type == WA_CLICKACTIVE)
{
CheckCPUType();
}
return FALSE;
}
LRESULT CDebugCommandsView::OnSizing(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CRect listRect;

View File

@ -89,7 +89,6 @@ public:
private:
BEGIN_MSG_MAP_EX(CDebugCommandsView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
MESSAGE_HANDLER(WM_SIZING, OnSizing)
MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo)
MESSAGE_HANDLER(WM_VSCROLL, OnScroll)
@ -164,7 +163,6 @@ private:
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);
LRESULT OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@ -212,7 +210,6 @@ private:
void EndOpEdit();
void GotoEnteredAddress();
void CheckCPUType();
void RefreshBreakpointList();
void RemoveSelectedBreakpoints();