diff --git a/src/ARM.cpp b/src/ARM.cpp index b7b703dadc..c115d72802 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -123,6 +123,7 @@ ARM::ARM(u32 num, bool jit, std::optional 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; diff --git a/src/ARM.h b/src/ARM.h index b652e74d08..ecb3bd5163 100644 --- a/src/ARM.h +++ b/src/ARM.h @@ -206,6 +206,7 @@ class ARM bool IsSingleStep; bool BreakReq; bool BreakOnStartup; + bool BreakOnError; u16 Port; public: diff --git a/src/Args.h b/src/Args.h index 2c405e297c..da52117c9a 100644 --- a/src/Args.h +++ b/src/Args.h @@ -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. diff --git a/src/NDS.cpp b/src/NDS.cpp index 1023d3c0af..617f3118dc 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -444,7 +444,7 @@ void NDS::Reset() else { ARM9ClockShift = 1; - MainRAMMask = 0x3FFFFF; + MainRAMMask = useExtendedMemory ? 0x7FFFFF : 0x3FFFFF; } // has to be called before InitTimings // otherwise some PU settings are completely @@ -4345,4 +4345,9 @@ void NDS::ARM7IOWrite32(u32 addr, u32 val) Log(LogLevel::Debug, "unknown ARM7 IO write32 %08X %08X %08X\n", addr, val, ARM7.R[15]); } +void NDS::SetMemoryExtension(bool enabled) +{ + useExtendedMemory = enabled; +} + } diff --git a/src/NDS.h b/src/NDS.h index b2bfb38596..b356b837ca 100644 --- a/src/NDS.h +++ b/src/NDS.h @@ -469,6 +469,8 @@ class NDS virtual void ARM7IOWrite16(u32 addr, u16 val); virtual void ARM7IOWrite32(u32 addr, u32 val); + void SetMemoryExtension(bool enabled); + #ifdef JIT_ENABLED [[nodiscard]] bool IsJITEnabled() const noexcept { return EnableJIT; } void SetJITArgs(std::optional args) noexcept; @@ -527,6 +529,7 @@ class NDS void EnterSleepMode(); template u32 RunFrame(); + bool useExtendedMemory = false; public: NDS(NDSArgs&& args, void* userdata = nullptr) noexcept : NDS(std::move(args), 0, userdata) {} diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 02be5b6569..95e4a6b42b 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -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}, diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index 2ac3f42d98..b51e3bb50b 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -1285,6 +1285,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB static_cast(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 @@ -1352,6 +1353,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB nds = new NDS(std::move(ndsargs), this); NDS::Current = nds; + nds->SetMemoryExtension(localCfg.GetBool("Debug.ExtendedMemory")); nds->Reset(); loadRTCData(); //emuThread->updateVideoRenderer(); // not actually needed? diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.cpp b/src/frontend/qt_sdl/EmuSettingsDialog.cpp index b37f711845..b53e96ccdf 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.cpp +++ b/src/frontend/qt_sdl/EmuSettingsDialog.cpp @@ -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")); @@ -108,6 +109,8 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new ui->cbGdbBOSA9->setDisabled(true); #endif + ui->cbDebugExtendedMem->setChecked(instcfg.GetBool("Debug.ExtendedMemory")); + on_chkEnableJIT_toggled(); on_cbGdbEnabled_toggled(); on_chkExternalBIOS_toggled(); @@ -294,11 +297,13 @@ 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()); instcfg.SetBool("Gdb.ARM9.BreakOnStartup", ui->cbGdbBOSA9->isChecked()); #endif + instcfg.SetBool("Debug.ExtendedMemory", ui->cbDebugExtendedMem->isChecked()); cfg.SetInt("Emu.ConsoleType", ui->cbxConsoleType->currentIndex()); cfg.SetBool("Emu.DirectBoot", ui->chkDirectBoot->isChecked()); diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.ui b/src/frontend/qt_sdl/EmuSettingsDialog.ui index 2746e1da7f..a5de75a6ba 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.ui +++ b/src/frontend/qt_sdl/EmuSettingsDialog.ui @@ -580,7 +580,7 @@ - + Qt::Vertical @@ -607,14 +607,28 @@ - + + + + Break on data error + + + + + + + Enable extended main RAM (8Mb) + + + + Note: melonDS must be restarted in order for these changes to have effect - + Note: GDB stub cannot be used together with the JIT recompiler