* gdbstub beginnings

* gdbstub: finish gdb impl things, next up is integration with melonDS

* holy fuck the gdbstub works

* gdb breakpoints work, but there's a mysterious crash on continue

* fix memory corruption that sometimes happened, and make resetting the console thru gdb work

* remove some gdb debug printing

* fix things in gdbstub

* separate option for enabling gdbstub

* add mode-dependent CPU registers

* C++ize the GDBstub code

* add gdbstub config in emu settings dialog

* make sure gdb is disabled when jit is enabled

* Remove unnecessary compiler flags, mark ARMJIT assembly code as no-execute-stack

This hardens the binary a little bit against common exploitation methods

* add option to wait for debugger attach on startup

* only insert GNU stack notes on linux

* disable gdbstub enable checkbox when jit is enabled

* fix non-linux incompatibilities

* enable gdbstub by default

* fix issues with gdbstub settings disable stuff

* format stuff

* update gdb test code

* Fix segfault when calling StubCallbacks->GetCPU()

C++ overrides are hard. Please I'm just a lowly C programmer.

* fix packet size not being sent correctly

Thanks to @GlowingUmbreon on Github for troubleshooting this

* fix select(2) calls (i should read docs more properly)

* fix GDB command sequencing/parsing issue (hopefully)

* [GDB] implement no-ack mode

* fix sending ack on handshake

* get lldb to work
This commit is contained in:
PoroCYon
2023-10-22 15:35:31 +02:00
committed by GitHub
parent 3d58a338a1
commit 3ab752b8ca
29 changed files with 3210 additions and 49 deletions

View File

@ -89,7 +89,22 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
ui->spnJITMaximumBlockSize->setDisabled(true);
#endif
#ifdef GDBSTUB_ENABLED
ui->cbGdbEnabled->setChecked(Config::GdbEnabled);
ui->intGdbPortA7->setValue(Config::GdbPortARM7);
ui->intGdbPortA9->setValue(Config::GdbPortARM9);
ui->cbGdbBOSA7->setChecked(Config::GdbARM7BreakOnStartup);
ui->cbGdbBOSA9->setChecked(Config::GdbARM9BreakOnStartup);
#else
ui->cbGdbEnabled->setDisabled(true);
ui->intGdbPortA7->setDisabled(true);
ui->intGdbPortA9->setDisabled(true);
ui->cbGdbBOSA7->setDisabled(true);
ui->cbGdbBOSA9->setDisabled(true);
#endif
on_chkEnableJIT_toggled();
on_cbGdbEnabled_toggled();
on_chkExternalBIOS_toggled();
const int imgsizes[] = {256, 512, 1024, 2048, 4096, 0};
@ -223,6 +238,12 @@ void EmuSettingsDialog::done(int r)
bool dsiSDFolderSync = ui->cbDSiSDFolder->isChecked();
std::string dsiSDFolderPath = ui->txtDSiSDFolder->text().toStdString();
bool gdbEnabled = ui->cbGdbEnabled->isChecked();
int gdbPortA7 = ui->intGdbPortA7->value();
int gdbPortA9 = ui->intGdbPortA9->value();
bool gdbBOSA7 = ui->cbGdbBOSA7->isChecked();
bool gdbBOSA9 = ui->cbGdbBOSA9->isChecked();
if (consoleType != Config::ConsoleType
|| directBoot != Config::DirectBoot
#ifdef JIT_ENABLED
@ -231,6 +252,13 @@ void EmuSettingsDialog::done(int r)
|| jitBranchOptimisations != Config::JIT_BranchOptimisations
|| jitLiteralOptimisations != Config::JIT_LiteralOptimisations
|| jitFastMemory != Config::JIT_FastMemory
#endif
#ifdef GDBSTUB_ENABLED
|| gdbEnabled != Config::GdbEnabled
|| gdbPortA7 != Config::GdbPortARM7
|| gdbPortA9 != Config::GdbPortARM9
|| gdbBOSA7 != Config::GdbARM7BreakOnStartup
|| gdbBOSA9 != Config::GdbARM9BreakOnStartup
#endif
|| externalBiosEnable != Config::ExternalBIOSEnable
|| bios9Path != Config::BIOS9Path
@ -285,13 +313,20 @@ void EmuSettingsDialog::done(int r)
Config::DSiSDFolderSync = dsiSDFolderSync;
Config::DSiSDFolderPath = dsiSDFolderPath;
#ifdef JIT_ENABLED
#ifdef JIT_ENABLED
Config::JIT_Enable = jitEnable;
Config::JIT_MaxBlockSize = jitMaxBlockSize;
Config::JIT_BranchOptimisations = jitBranchOptimisations;
Config::JIT_LiteralOptimisations = jitLiteralOptimisations;
Config::JIT_FastMemory = jitFastMemory;
#endif
#endif
#ifdef GDBSTUB_ENABLED
Config::GdbEnabled = gdbEnabled;
Config::GdbPortARM7 = gdbPortA7;
Config::GdbPortARM9 = gdbPortA9;
Config::GdbARM7BreakOnStartup = gdbBOSA7;
Config::GdbARM9BreakOnStartup = gdbBOSA9;
#endif
Config::ConsoleType = consoleType;
Config::DirectBoot = directBoot;
@ -506,6 +541,31 @@ void EmuSettingsDialog::on_chkEnableJIT_toggled()
ui->chkJITFastMemory->setDisabled(disabled);
#endif
ui->spnJITMaximumBlockSize->setDisabled(disabled);
on_cbGdbEnabled_toggled();
}
void EmuSettingsDialog::on_cbGdbEnabled_toggled()
{
#ifdef GDBSTUB_ENABLED
bool disabled = !ui->cbGdbEnabled->isChecked();
bool jitenable = ui->chkEnableJIT->isChecked();
if (jitenable && !disabled) {
ui->cbGdbEnabled->setChecked(false);
disabled = true;
}
#else
bool disabled = true;
bool jitenable = true;
ui->cbGdbEnabled->setChecked(false);
#endif
ui->cbGdbEnabled->setDisabled(jitenable);
ui->intGdbPortA7->setDisabled(disabled);
ui->intGdbPortA9->setDisabled(disabled);
ui->cbGdbBOSA7->setDisabled(disabled);
ui->cbGdbBOSA9->setDisabled(disabled);
}
void EmuSettingsDialog::on_chkExternalBIOS_toggled()