Core: Add option to step code at break opcode

This commit is contained in:
zilmar 2022-08-01 11:43:17 +09:30
parent 4b60f4f3e9
commit 0419ba232e
9 changed files with 203 additions and 176 deletions

View File

@ -248,6 +248,7 @@ CJniBridegSettings::CJniBridegSettings()
ADD_SETTING(Debugger_EndOnPermLoop);
ADD_SETTING(Debugger_BreakOnUnhandledMemory);
ADD_SETTING(Debugger_BreakOnAddressError);
ADD_SETTING(Debugger_StepOnBreakOpCode);
ADD_SETTING(Debugger_ShowPifErrors);
ADD_SETTING(Debugger_ShowDivByZero);
ADD_SETTING(Debugger_RecordRecompilerAsm);

View File

@ -188,7 +188,7 @@ R4300iOp::Func * R4300iOp::BuildInterpreter()
Jump_Special[10] = UnknownOpcode;
Jump_Special[11] = UnknownOpcode;
Jump_Special[12] = SPECIAL_SYSCALL;
Jump_Special[13] = UnknownOpcode;
Jump_Special[13] = SPECIAL_BREAK;
Jump_Special[14] = UnknownOpcode;
Jump_Special[15] = SPECIAL_SYNC;
Jump_Special[16] = SPECIAL_MFHI;
@ -1334,9 +1334,17 @@ void R4300iOp::SPECIAL_SYSCALL()
void R4300iOp::SPECIAL_BREAK()
{
g_Reg->DoBreakException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP);
g_System->m_PipelineStage = PIPELINE_STAGE_JUMP;
g_System->m_JumpToLocation = (*_PROGRAM_COUNTER);
if (StepOnBreakOpCode())
{
g_Settings->SaveBool(Debugger_SteppingOps, true);
g_Debugger->WaitForStep();
}
else
{
g_Reg->DoBreakException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP);
g_System->m_PipelineStage = PIPELINE_STAGE_JUMP;
g_System->m_JumpToLocation = (*_PROGRAM_COUNTER);
}
}
void R4300iOp::SPECIAL_SYNC()

View File

@ -13,199 +13,199 @@ public:
typedef void(*Func)();
// Opcode functions
static void J();
static void JAL();
static void BNE();
static void BEQ();
static void BLEZ();
static void BGTZ();
static void ADDI();
static void ADDIU();
static void SLTI();
static void SLTIU();
static void ANDI();
static void ORI();
static void XORI();
static void LUI();
static void BEQL();
static void BNEL();
static void BLEZL();
static void BGTZL();
static void DADDIU();
static void LDL();
static void LDR();
static void LB();
static void LH();
static void LWL();
static void LW();
static void LBU();
static void LHU();
static void LWR();
static void LWU();
static void SB();
static void SH();
static void SWL();
static void SW();
static void SDL();
static void SDR();
static void SWR();
static void CACHE();
static void LL();
static void LWC1();
static void LDC1();
static void LD();
static void SC();
static void SWC1();
static void SDC1();
static void SD();
static void J();
static void JAL();
static void BNE();
static void BEQ();
static void BLEZ();
static void BGTZ();
static void ADDI();
static void ADDIU();
static void SLTI();
static void SLTIU();
static void ANDI();
static void ORI();
static void XORI();
static void LUI();
static void BEQL();
static void BNEL();
static void BLEZL();
static void BGTZL();
static void DADDIU();
static void LDL();
static void LDR();
static void LB();
static void LH();
static void LWL();
static void LW();
static void LBU();
static void LHU();
static void LWR();
static void LWU();
static void SB();
static void SH();
static void SWL();
static void SW();
static void SDL();
static void SDR();
static void SWR();
static void CACHE();
static void LL();
static void LWC1();
static void LDC1();
static void LD();
static void SC();
static void SWC1();
static void SDC1();
static void SD();
// R4300i opcodes: Special
static void SPECIAL_SLL();
static void SPECIAL_SRL();
static void SPECIAL_SRA();
static void SPECIAL_SLLV();
static void SPECIAL_SRLV();
static void SPECIAL_SRAV();
static void SPECIAL_JR();
static void SPECIAL_JALR();
static void SPECIAL_SYSCALL();
static void SPECIAL_BREAK();
static void SPECIAL_SYNC();
static void SPECIAL_MFHI();
static void SPECIAL_MTHI();
static void SPECIAL_MFLO();
static void SPECIAL_MTLO();
static void SPECIAL_DSLLV();
static void SPECIAL_DSRLV();
static void SPECIAL_DSRAV();
static void SPECIAL_MULT();
static void SPECIAL_MULTU();
static void SPECIAL_DIV();
static void SPECIAL_DIVU();
static void SPECIAL_DMULT();
static void SPECIAL_DMULTU();
static void SPECIAL_DDIV();
static void SPECIAL_DDIVU();
static void SPECIAL_ADD();
static void SPECIAL_ADDU();
static void SPECIAL_SUB();
static void SPECIAL_SUBU();
static void SPECIAL_AND();
static void SPECIAL_OR();
static void SPECIAL_XOR();
static void SPECIAL_NOR();
static void SPECIAL_SLT();
static void SPECIAL_SLTU();
static void SPECIAL_DADD();
static void SPECIAL_DADDU();
static void SPECIAL_DSUB();
static void SPECIAL_DSUBU();
static void SPECIAL_TGE();
static void SPECIAL_TGEU();
static void SPECIAL_TLT();
static void SPECIAL_TLTU();
static void SPECIAL_TEQ();
static void SPECIAL_TNE();
static void SPECIAL_DSLL();
static void SPECIAL_DSRL();
static void SPECIAL_DSRA();
static void SPECIAL_DSLL32();
static void SPECIAL_DSRL32();
static void SPECIAL_DSRA32();
static void SPECIAL_SLL();
static void SPECIAL_SRL();
static void SPECIAL_SRA();
static void SPECIAL_SLLV();
static void SPECIAL_SRLV();
static void SPECIAL_SRAV();
static void SPECIAL_JR();
static void SPECIAL_JALR();
static void SPECIAL_SYSCALL();
static void SPECIAL_BREAK();
static void SPECIAL_SYNC();
static void SPECIAL_MFHI();
static void SPECIAL_MTHI();
static void SPECIAL_MFLO();
static void SPECIAL_MTLO();
static void SPECIAL_DSLLV();
static void SPECIAL_DSRLV();
static void SPECIAL_DSRAV();
static void SPECIAL_MULT();
static void SPECIAL_MULTU();
static void SPECIAL_DIV();
static void SPECIAL_DIVU();
static void SPECIAL_DMULT();
static void SPECIAL_DMULTU();
static void SPECIAL_DDIV();
static void SPECIAL_DDIVU();
static void SPECIAL_ADD();
static void SPECIAL_ADDU();
static void SPECIAL_SUB();
static void SPECIAL_SUBU();
static void SPECIAL_AND();
static void SPECIAL_OR();
static void SPECIAL_XOR();
static void SPECIAL_NOR();
static void SPECIAL_SLT();
static void SPECIAL_SLTU();
static void SPECIAL_DADD();
static void SPECIAL_DADDU();
static void SPECIAL_DSUB();
static void SPECIAL_DSUBU();
static void SPECIAL_TGE();
static void SPECIAL_TGEU();
static void SPECIAL_TLT();
static void SPECIAL_TLTU();
static void SPECIAL_TEQ();
static void SPECIAL_TNE();
static void SPECIAL_DSLL();
static void SPECIAL_DSRL();
static void SPECIAL_DSRA();
static void SPECIAL_DSLL32();
static void SPECIAL_DSRL32();
static void SPECIAL_DSRA32();
// R4300i opcodes: RegImm
static void REGIMM_BLTZ();
static void REGIMM_BGEZ();
static void REGIMM_BLTZL();
static void REGIMM_BGEZL();
static void REGIMM_BLTZAL();
static void REGIMM_BGEZAL();
static void REGIMM_TEQI();
static void REGIMM_TGEI();
static void REGIMM_TGEIU();
static void REGIMM_TLTI();
static void REGIMM_TLTIU();
static void REGIMM_TNEI();
static void REGIMM_BLTZ();
static void REGIMM_BGEZ();
static void REGIMM_BLTZL();
static void REGIMM_BGEZL();
static void REGIMM_BLTZAL();
static void REGIMM_BGEZAL();
static void REGIMM_TEQI();
static void REGIMM_TGEI();
static void REGIMM_TGEIU();
static void REGIMM_TLTI();
static void REGIMM_TLTIU();
static void REGIMM_TNEI();
// COP0 functions
static void COP0_MF();
static void COP0_MT();
static void COP0_MF();
static void COP0_MT();
// COP0 CO functions
static void COP0_CO_TLBR();
static void COP0_CO_TLBWI();
static void COP0_CO_TLBWR();
static void COP0_CO_TLBP();
static void COP0_CO_ERET();
static void COP0_CO_TLBR();
static void COP0_CO_TLBWI();
static void COP0_CO_TLBWR();
static void COP0_CO_TLBP();
static void COP0_CO_ERET();
// COP1 functions
static void COP1_MF();
static void COP1_DMF();
static void COP1_CF();
static void COP1_MT();
static void COP1_DMT();
static void COP1_CT();
static void COP1_MF();
static void COP1_DMF();
static void COP1_CF();
static void COP1_MT();
static void COP1_DMT();
static void COP1_CT();
// COP1: BC1 functions
static void COP1_BCF();
static void COP1_BCT();
static void COP1_BCFL();
static void COP1_BCTL();
static void COP1_BCF();
static void COP1_BCT();
static void COP1_BCFL();
static void COP1_BCTL();
// COP1: S functions
static void COP1_S_ADD();
static void COP1_S_SUB();
static void COP1_S_MUL();
static void COP1_S_DIV();
static void COP1_S_SQRT();
static void COP1_S_ABS();
static void COP1_S_MOV();
static void COP1_S_NEG();
static void COP1_S_ROUND_L();
static void COP1_S_TRUNC_L();
static void COP1_S_CEIL_L();
static void COP1_S_FLOOR_L();
static void COP1_S_ROUND_W();
static void COP1_S_TRUNC_W();
static void COP1_S_CEIL_W();
static void COP1_S_FLOOR_W();
static void COP1_S_CVT_D();
static void COP1_S_CVT_W();
static void COP1_S_CVT_L();
static void COP1_S_CMP();
static void COP1_S_ADD();
static void COP1_S_SUB();
static void COP1_S_MUL();
static void COP1_S_DIV();
static void COP1_S_SQRT();
static void COP1_S_ABS();
static void COP1_S_MOV();
static void COP1_S_NEG();
static void COP1_S_ROUND_L();
static void COP1_S_TRUNC_L();
static void COP1_S_CEIL_L();
static void COP1_S_FLOOR_L();
static void COP1_S_ROUND_W();
static void COP1_S_TRUNC_W();
static void COP1_S_CEIL_W();
static void COP1_S_FLOOR_W();
static void COP1_S_CVT_D();
static void COP1_S_CVT_W();
static void COP1_S_CVT_L();
static void COP1_S_CMP();
// COP1: D functions
static void COP1_D_ADD();
static void COP1_D_SUB();
static void COP1_D_MUL();
static void COP1_D_DIV();
static void COP1_D_SQRT();
static void COP1_D_ABS();
static void COP1_D_MOV();
static void COP1_D_NEG();
static void COP1_D_ROUND_L();
static void COP1_D_TRUNC_L();
static void COP1_D_CEIL_L();
static void COP1_D_FLOOR_L();
static void COP1_D_ROUND_W();
static void COP1_D_TRUNC_W();
static void COP1_D_CEIL_W();
static void COP1_D_FLOOR_W();
static void COP1_D_CVT_S();
static void COP1_D_CVT_W();
static void COP1_D_CVT_L();
static void COP1_D_CMP();
static void COP1_D_ADD();
static void COP1_D_SUB();
static void COP1_D_MUL();
static void COP1_D_DIV();
static void COP1_D_SQRT();
static void COP1_D_ABS();
static void COP1_D_MOV();
static void COP1_D_NEG();
static void COP1_D_ROUND_L();
static void COP1_D_TRUNC_L();
static void COP1_D_CEIL_L();
static void COP1_D_FLOOR_L();
static void COP1_D_ROUND_W();
static void COP1_D_TRUNC_W();
static void COP1_D_CEIL_W();
static void COP1_D_FLOOR_W();
static void COP1_D_CVT_S();
static void COP1_D_CVT_W();
static void COP1_D_CVT_L();
static void COP1_D_CMP();
// COP1: W functions
static void COP1_W_CVT_S();
static void COP1_W_CVT_D();
static void COP1_W_CVT_S();
static void COP1_W_CVT_D();
// COP1: L functions
static void COP1_L_CVT_S();
static void COP1_L_CVT_D();
static void COP1_L_CVT_S();
static void COP1_L_CVT_D();
// Other functions
static void UnknownOpcode();
static void UnknownOpcode();
static Func* BuildInterpreter();

View File

@ -322,6 +322,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Debugger_EndOnPermLoop, new CSettingTypeApplication("Debugger", "End On Perm Loop", false));
AddHandler(Debugger_BreakOnUnhandledMemory, new CSettingTypeApplication("Debugger", "Break On Unhandled Memory", false));
AddHandler(Debugger_BreakOnAddressError, new CSettingTypeApplication("Debugger", "Break On Address Error", false));
AddHandler(Debugger_StepOnBreakOpCode, new CSettingTypeApplication("Debugger", "Step On Break OpCode", false));
AddHandler(Debugger_ShowPifErrors, new CSettingTypeApplication("Debugger", "Show Pif Errors", false));
AddHandler(Debugger_DisableGameFixes, new CSettingTypeApplication("Debugger", "Disable Game Fixes", false));
AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false));

View File

@ -26,6 +26,7 @@ uint32_t CDebugSettings::m_RcpIntrBreakpoints = 0;
bool CDebugSettings::m_EndOnPermLoop = false;
bool CDebugSettings::m_BreakOnUnhandledMemory = false;
bool CDebugSettings::m_BreakOnAddressError = false;
bool CDebugSettings::m_StepOnBreakOpCode = false;
CDebugSettings::CDebugSettings()
{
@ -52,6 +53,7 @@ CDebugSettings::CDebugSettings()
g_Settings->RegisterChangeCB(Debugger_EndOnPermLoop, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_BreakOnUnhandledMemory, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_BreakOnAddressError, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_StepOnBreakOpCode, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
RefreshSettings();
}
@ -80,6 +82,7 @@ CDebugSettings::~CDebugSettings()
g_Settings->UnregisterChangeCB(Debugger_EndOnPermLoop, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_BreakOnUnhandledMemory, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_BreakOnAddressError, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_StepOnBreakOpCode, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
}
}
@ -104,6 +107,7 @@ void CDebugSettings::RefreshSettings()
m_EndOnPermLoop = m_HaveDebugger && g_Settings->LoadBool(Debugger_EndOnPermLoop);
m_BreakOnUnhandledMemory = m_HaveDebugger && g_Settings->LoadBool(Debugger_BreakOnUnhandledMemory);
m_BreakOnAddressError = m_HaveDebugger && g_Settings->LoadBool(Debugger_BreakOnAddressError);
m_StepOnBreakOpCode = m_HaveDebugger && g_Settings->LoadBool(Debugger_StepOnBreakOpCode);
m_Debugging = m_HaveDebugger && (m_HaveExecutionBP || m_WaitingForStep || m_HaveWriteBP || m_HaveReadBP);
}

View File

@ -29,6 +29,7 @@ public:
static inline bool EndOnPermLoop(void) { return m_EndOnPermLoop; }
static inline bool BreakOnUnhandledMemory(void) { return m_BreakOnUnhandledMemory; }
static inline bool BreakOnAddressError(void) { return m_BreakOnAddressError; }
static inline bool StepOnBreakOpCode(void) { return m_StepOnBreakOpCode; }
private:
static void StaticRefreshSettings(CDebugSettings * _this)
@ -59,6 +60,7 @@ private:
static bool m_EndOnPermLoop;
static bool m_BreakOnUnhandledMemory;
static bool m_BreakOnAddressError;
static bool m_StepOnBreakOpCode;
static int32_t m_RefCount;
static bool m_Registered;

View File

@ -239,6 +239,7 @@ enum SettingID
Debugger_EndOnPermLoop,
Debugger_BreakOnUnhandledMemory,
Debugger_BreakOnAddressError,
Debugger_StepOnBreakOpCode,
Debugger_ShowPifErrors,
Debugger_ShowDivByZero,
Debugger_RecordRecompilerAsm,

View File

@ -27,6 +27,7 @@ CMainMenu::CMainMenu(CMainGui * hMainWindow) :
m_ChangeSettingList.push_back(Debugger_EndOnPermLoop);
m_ChangeSettingList.push_back(Debugger_BreakOnUnhandledMemory);
m_ChangeSettingList.push_back(Debugger_BreakOnAddressError);
m_ChangeSettingList.push_back(Debugger_StepOnBreakOpCode);
m_ChangeSettingList.push_back(Debugger_ShowPifErrors);
m_ChangeSettingList.push_back(Debugger_ShowDListAListCount);
m_ChangeSettingList.push_back(Debugger_DebugLanguage);
@ -507,6 +508,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
case ID_DEBUG_BREAK_ON_ADDRESS_ERROR:
g_Settings->SaveBool(Debugger_BreakOnAddressError, !g_Settings->LoadBool(Debugger_BreakOnAddressError));
break;
case ID_DEBUG_STEP_ON_BREAK_OPCODE:
g_Settings->SaveBool(Debugger_StepOnBreakOpCode, !g_Settings->LoadBool(Debugger_StepOnBreakOpCode));
break;
case ID_DEBUG_SHOW_PIF_ERRORS:
g_Settings->SaveBool(Debugger_ShowPifErrors, !g_Settings->LoadBool(Debugger_ShowPifErrors));
break;
@ -1240,6 +1244,12 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
Item.SetItemTicked(true);
}
DebugNotificationMenu.push_back(Item);
Item.Reset(ID_DEBUG_STEP_ON_BREAK_OPCODE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Step on break OpCode");
if (g_Settings->LoadBool(Debugger_StepOnBreakOpCode))
{
Item.SetItemTicked(true);
}
DebugNotificationMenu.push_back(Item);
Item.Reset(ID_DEBUG_SHOW_PIF_ERRORS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"On PIF errors");
if (g_Settings->LoadBool(Debugger_ShowPifErrors))
{

View File

@ -33,7 +33,7 @@ enum MainMenuID
ID_OPTIONS_DECREASE_SPEED,
// Debugger menu
ID_DEBUG_END_ON_PERM_LOOP,
ID_DEBUG_END_ON_PERM_LOOP, ID_DEBUG_STEP_ON_BREAK_OPCODE,
ID_DEBUG_BREAK_ON_UNHANDLED_MEM, ID_DEBUG_BREAK_ON_ADDRESS_ERROR, ID_DEBUG_SHOW_PIF_ERRORS,
ID_DEBUG_SHOW_DLIST_COUNT, ID_DEBUG_SHOW_RECOMP_MEM_SIZE, ID_DEBUG_SHOW_DIV_BY_ZERO,
ID_DEBUG_RECORD_RECOMPILER_ASM, ID_DEBUG_DISABLE_GAMEFIX, ID_DEBUG_LANGUAGE,