add option to break on data/prefetch errors when GDB stub is connected

This commit is contained in:
Joshua Smith 2024-11-14 14:13:36 -05:00
parent 7c1d2a64f4
commit 197634d411
7 changed files with 36 additions and 2 deletions

View File

@ -123,6 +123,7 @@ ARM::ARM(u32 num, bool jit, std::optional<GDBArgs> gdb, melonDS::NDS& nds) :
)
GdbStub.Init();
IsSingleStep = false;
BreakOnError = gdb->BreakOnError;
#endif
}
@ -545,6 +546,16 @@ void ARMv5::PrefetchAbort()
{
Log(LogLevel::Warn, "ARM9: prefetch abort (%08X)\n", R[15]);
#ifdef GDBSTUB_ENABLED
Gdb::StubState s = GdbStub.Poll();
if (BreakOnError && s != Gdb::StubState::NoConn)
{
BreakReq = true;
GdbCheckB();
return;
}
#endif
u32 oldcpsr = CPSR;
CPSR &= ~0xBF;
CPSR |= 0x97;
@ -568,6 +579,16 @@ void ARMv5::DataAbort()
{
Log(LogLevel::Warn, "ARM9: data abort (%08X)\n", R[15]);
#ifdef GDBSTUB_ENABLED
Gdb::StubState s = GdbStub.Poll();
if (BreakOnError && s != Gdb::StubState::NoConn)
{
BreakReq = true;
GdbCheckB();
return;
}
#endif
u32 oldcpsr = CPSR;
CPSR &= ~0xBF;
CPSR |= 0x97;

View File

@ -206,6 +206,7 @@ protected:
bool IsSingleStep;
bool BreakReq;
bool BreakOnStartup;
bool BreakOnError;
u16 Port;
public:

View File

@ -79,6 +79,7 @@ struct GDBArgs
u16 PortARM9 = 0;
bool ARM7BreakOnStartup = false;
bool ARM9BreakOnStartup = false;
bool BreakOnError = false;
};
/// Arguments to pass into the NDS constructor.

View File

@ -310,6 +310,7 @@ LegacyEntry LegacyFile[] =
#ifdef GDBSTUB_ENABLED
{"GdbEnabled", 1, "Gdb.Enabled", false},
{"GdbBreakOnError", 1, "Gdb.BreakOnError", true},
{"GdbPortARM7", 0, "Gdb.ARM7.Port", true},
{"GdbPortARM9", 0, "Gdb.ARM9.Port", true},
{"GdbARM7BreakOnStartup", 1, "Gdb.ARM7.BreakOnStartup", true},

View File

@ -1285,6 +1285,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
static_cast<u16>(gdbopt.GetInt("ARM9.Port")),
gdbopt.GetBool("ARM7.BreakOnStartup"),
gdbopt.GetBool("ARM9.BreakOnStartup"),
gdbopt.GetBool("BreakOnError")
};
auto gdbargs = gdbopt.GetBool("Enabled") ? std::make_optional(_gdbargs) : std::nullopt;
#else

View File

@ -96,6 +96,7 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
#ifdef GDBSTUB_ENABLED
ui->cbGdbEnabled->setChecked(instcfg.GetBool("Gdb.Enabled"));
ui->cbGdbBreakOnError->setChecked(instcfg.GetBool("Gdb.BreakOnError"));
ui->intGdbPortA7->setValue(instcfg.GetInt("Gdb.ARM7.Port"));
ui->intGdbPortA9->setValue(instcfg.GetInt("Gdb.ARM9.Port"));
ui->cbGdbBOSA7->setChecked(instcfg.GetBool("Gdb.ARM7.BreakOnStartup"));
@ -294,6 +295,7 @@ void EmuSettingsDialog::done(int r)
#endif
#ifdef GDBSTUB_ENABLED
instcfg.SetBool("Gdb.Enabled", ui->cbGdbEnabled->isChecked());
instcfg.SetBool("Gdb.BreakOnError", ui->cbGdbBreakOnError->isChecked());
instcfg.SetInt("Gdb.ARM7.Port", ui->intGdbPortA7->value());
instcfg.SetInt("Gdb.ARM9.Port", ui->intGdbPortA9->value());
instcfg.SetBool("Gdb.ARM7.BreakOnStartup", ui->cbGdbBOSA7->isChecked());

View File

@ -607,14 +607,21 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="7">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="cbGdbBreakOnError">
<property name="text">
<string>Break on data error</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="7">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Note: melonDS must be restarted in order for these changes to have effect</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="7">
<item row="4" column="0" colspan="7">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Note: GDB stub cannot be used together with the JIT recompiler</string>