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()
{
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

@ -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,