From 407dccb1dbf8a28cf0b0edb72bb714a756385a0b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 11 Oct 2024 21:26:04 +1000 Subject: [PATCH] Qt: Move GDB server enable to advanced options And expose the port as a setting. --- src/core/settings.cpp | 12 +++++++++++- src/core/settings.h | 5 ++++- src/duckstation-qt/advancedsettingswidget.cpp | 16 ++++++++++++---- src/duckstation-qt/mainwindow.cpp | 1 - src/duckstation-qt/mainwindow.ui | 9 --------- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index d502f8f2f..e6112790b 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -435,8 +435,12 @@ void Settings::Load(SettingsInterface& si, SettingsInterface& controller_si) debugging.show_vram = si.GetBoolValue("Debug", "ShowVRAM"); debugging.dump_cpu_to_vram_copies = si.GetBoolValue("Debug", "DumpCPUToVRAMCopies"); debugging.dump_vram_to_cpu_copies = si.GetBoolValue("Debug", "DumpVRAMToCPUCopies"); + +#ifndef __ANDROID__ debugging.enable_gdb_server = si.GetBoolValue("Debug", "EnableGDBServer"); - debugging.gdb_server_port = static_cast(si.GetIntValue("Debug", "GDBServerPort")); + debugging.gdb_server_port = static_cast(si.GetUIntValue("Debug", "GDBServerPort", DEFAULT_GDB_SERVER_PORT)); +#endif + debugging.show_gpu_state = si.GetBoolValue("Debug", "ShowGPUState"); debugging.show_cdrom_state = si.GetBoolValue("Debug", "ShowCDROMState"); debugging.show_spu_state = si.GetBoolValue("Debug", "ShowSPUState"); @@ -709,6 +713,12 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const si.SetBoolValue("Debug", "ShowVRAM", debugging.show_vram); si.SetBoolValue("Debug", "DumpCPUToVRAMCopies", debugging.dump_cpu_to_vram_copies); si.SetBoolValue("Debug", "DumpVRAMToCPUCopies", debugging.dump_vram_to_cpu_copies); + +#ifndef __ANDROID__ + si.SetBoolValue("Debug", "EnableGDBServer", debugging.enable_gdb_server); + si.SetUIntValue("Debug", "GDBServerPort", debugging.gdb_server_port); +#endif + si.SetBoolValue("Debug", "ShowGPUState", debugging.show_gpu_state); si.SetBoolValue("Debug", "ShowCDROMState", debugging.show_cdrom_state); si.SetBoolValue("Debug", "ShowSPUState", debugging.show_spu_state); diff --git a/src/core/settings.h b/src/core/settings.h index 4a5faa884..a6f44650d 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -226,8 +226,10 @@ struct Settings bool dump_cpu_to_vram_copies : 1 = false; bool dump_vram_to_cpu_copies : 1 = false; +#ifndef __ANDROID__ bool enable_gdb_server : 1 = false; - u16 gdb_server_port = 1234; + u16 gdb_server_port = DEFAULT_GDB_SERVER_PORT; +#endif // Mutable because the imgui window can close itself. mutable bool show_gpu_state = false; @@ -555,6 +557,7 @@ struct Settings #ifndef __ANDROID__ static constexpr bool DEFAULT_SAVE_STATE_BACKUPS = true; static constexpr bool DEFAULT_FAST_BOOT_VALUE = false; + static constexpr u16 DEFAULT_GDB_SERVER_PORT = 2345; #else static constexpr bool DEFAULT_SAVE_STATE_BACKUPS = false; static constexpr bool DEFAULT_FAST_BOOT_VALUE = true; diff --git a/src/duckstation-qt/advancedsettingswidget.cpp b/src/duckstation-qt/advancedsettingswidget.cpp index fe4dc99a4..bc41b29c0 100644 --- a/src/duckstation-qt/advancedsettingswidget.cpp +++ b/src/duckstation-qt/advancedsettingswidget.cpp @@ -265,6 +265,10 @@ void AdvancedSettingsWidget::addTweakOptions() addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Allow Booting Without SBI File"), "CDROM", "AllowBootingWithoutSBIFile", false); + addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Enable GDB Server"), "Debug", "EnableGDBServer", false); + addIntRangeTweakOption(m_dialog, m_ui.tweakOptionTable, tr("GDB Server Port"), "Debug", "GDBServerPort", 1, 65535, + Settings::DEFAULT_GDB_SERVER_PORT); + addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Export Shared Memory"), "Hacks", "ExportSharedMemory", false); addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Enable PCDrv"), "PCDrv", "Enabled", false); @@ -300,10 +304,12 @@ void AdvancedSettingsWidget::onResetToDefaultClicked() setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM Region Check setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM SubQ Skew setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Allow booting without SBI file - setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Export Shared Memory - setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV - setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV Writes - setDirectoryOption(m_ui.tweakOptionTable, i++, ""); // PCDrv Root Directory + setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable GDB Server + setIntRangeTweakOption(m_ui.tweakOptionTable, i++, Settings::DEFAULT_GDB_SERVER_PORT); // GDB Server Port + setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Export Shared Memory + setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV + setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV Writes + setDirectoryOption(m_ui.tweakOptionTable, i++, ""); // PCDrv Root Directory return; } @@ -329,6 +335,8 @@ void AdvancedSettingsWidget::onResetToDefaultClicked() sif->DeleteValue("CDROM", "RegionCheck"); sif->DeleteValue("CDROM", "SubQSkew"); sif->DeleteValue("CDROM", "AllowBootingWithoutSBIFile"); + sif->DeleteValue("Debug", "EnableGDBServer"); + sif->DeleteValue("Debug", "GDBServerPort"); sif->DeleteValue("PCDrv", "Enabled"); sif->DeleteValue("PCDrv", "EnableWrites"); sif->DeleteValue("PCDrv", "Root"); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 5b047d4c2..da14d9c1e 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -2094,7 +2094,6 @@ void MainWindow::connectSignals() connect(m_ui.actionCoverDownloader, &QAction::triggered, this, &MainWindow::onToolsCoverDownloaderTriggered); connect(m_ui.actionMediaCapture, &QAction::toggled, this, &MainWindow::onToolsMediaCaptureToggled); connect(m_ui.actionCPUDebugger, &QAction::triggered, this, &MainWindow::openCPUDebugger); - SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableGDBServer, "Debug", "EnableGDBServer", false); connect(m_ui.actionOpenDataDirectory, &QAction::triggered, this, &MainWindow::onToolsOpenDataDirectoryTriggered); connect(m_ui.actionOpenTextureDirectory, &QAction::triggered, this, &MainWindow::onToolsOpenTextureDirectoryTriggered); connect(m_ui.actionReloadTextureReplacements, &QAction::triggered, g_emu_thread, &EmuThread::reloadTextureReplacements); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index ac295481a..cad3559c0 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -160,7 +160,6 @@ - @@ -798,14 +797,6 @@ CPU D&ebugger - - - true - - - Enable GDB Server - -