Configuration: Add GDB stub related configuration

This commit is contained in:
merry 2022-02-08 19:49:54 +00:00
parent c00d49214b
commit fb4b9a3003
6 changed files with 243 additions and 6 deletions

View file

@ -153,6 +153,16 @@ namespace Ryujinx.HLE
/// </summary> /// </summary>
public Action RefreshInputConfig { internal get; set; } public Action RefreshInputConfig { internal get; set; }
/// <summary>
/// Enables gdbstub to allow for debugging of the guest .
/// </summary>
public bool EnableGdbStub { get; internal set; }
/// <summary>
/// A TCP port to use to expose a gdbstub for a debugger to connect to.
/// </summary>
public ushort GdbStubPort { get; internal set; }
public HLEConfiguration(VirtualFileSystem virtualFileSystem, public HLEConfiguration(VirtualFileSystem virtualFileSystem,
LibHacHorizonManager libHacHorizonManager, LibHacHorizonManager libHacHorizonManager,
ContentManager contentManager, ContentManager contentManager,
@ -175,7 +185,9 @@ namespace Ryujinx.HLE
MemoryManagerMode memoryManagerMode, MemoryManagerMode memoryManagerMode,
bool ignoreMissingServices, bool ignoreMissingServices,
AspectRatio aspectRatio, AspectRatio aspectRatio,
float audioVolume) float audioVolume,
bool enableGdbStub,
ushort gdbStubPort)
{ {
VirtualFileSystem = virtualFileSystem; VirtualFileSystem = virtualFileSystem;
LibHacHorizonManager = libHacHorizonManager; LibHacHorizonManager = libHacHorizonManager;
@ -200,6 +212,8 @@ namespace Ryujinx.HLE
IgnoreMissingServices = ignoreMissingServices; IgnoreMissingServices = ignoreMissingServices;
AspectRatio = aspectRatio; AspectRatio = aspectRatio;
AudioVolume = audioVolume; AudioVolume = audioVolume;
EnableGdbStub = enableGdbStub;
GdbStubPort = gdbStubPort;
} }
} }
} }

View file

@ -14,7 +14,7 @@ namespace Ryujinx.Configuration
/// <summary> /// <summary>
/// The current version of the file format /// The current version of the file format
/// </summary> /// </summary>
public const int CurrentVersion = 37; public const int CurrentVersion = 38;
/// <summary> /// <summary>
/// Version of the configuration file format /// Version of the configuration file format
@ -275,6 +275,16 @@ namespace Ryujinx.Configuration
/// </summary> /// </summary>
public List<InputConfig> InputConfig { get; set; } public List<InputConfig> InputConfig { get; set; }
/// <summary>
/// Enables or disables the GDB stub
/// </summary>
public bool EnableGdbStub { get; set; }
/// <summary>
/// Which TCP port should the GDB stub listen on
/// </summary>
public ushort GdbStubPort { get; set; }
/// <summary> /// <summary>
/// Loads a configuration file from disk /// Loads a configuration file from disk
/// </summary> /// </summary>

View file

@ -389,6 +389,30 @@ namespace Ryujinx.Configuration
} }
} }
/// <summary>
/// Debug configuration section
/// </summary>
public class DebugSection
{
/// <summary>
/// Enables or disables the GDB stub
/// </summary>
public ReactiveObject<bool> EnableGdbStub { get; private set; }
/// <summary>
/// Which TCP port should the GDB stub listen on
/// </summary>
public ReactiveObject<ushort> GdbStubPort { get; private set; }
public DebugSection()
{
EnableGdbStub = new ReactiveObject<bool>();
EnableGdbStub.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableGdbStub));
GdbStubPort = new ReactiveObject<ushort>();
GdbStubPort.Event += static (sender, e) => LogValueChange(sender, e, nameof(GdbStubPort));
}
}
/// <summary> /// <summary>
/// The default configuration instance /// The default configuration instance
/// </summary> /// </summary>
@ -419,6 +443,11 @@ namespace Ryujinx.Configuration
/// </summary> /// </summary>
public HidSection Hid { get; private set; } public HidSection Hid { get; private set; }
/// <summary>
/// The Debug
/// </summary>
public DebugSection Debug { get; private set; }
/// <summary> /// <summary>
/// Enables or disables Discord Rich Presence /// Enables or disables Discord Rich Presence
/// </summary> /// </summary>
@ -446,6 +475,7 @@ namespace Ryujinx.Configuration
System = new SystemSection(); System = new SystemSection();
Graphics = new GraphicsSection(); Graphics = new GraphicsSection();
Hid = new HidSection(); Hid = new HidSection();
Debug = new DebugSection();
EnableDiscordIntegration = new ReactiveObject<bool>(); EnableDiscordIntegration = new ReactiveObject<bool>();
CheckUpdatesOnStart = new ReactiveObject<bool>(); CheckUpdatesOnStart = new ReactiveObject<bool>();
ShowConfirmExit = new ReactiveObject<bool>(); ShowConfirmExit = new ReactiveObject<bool>();
@ -523,6 +553,8 @@ namespace Ryujinx.Configuration
KeyboardConfig = new List<object>(), KeyboardConfig = new List<object>(),
ControllerConfig = new List<object>(), ControllerConfig = new List<object>(),
InputConfig = Hid.InputConfig, InputConfig = Hid.InputConfig,
EnableGdbStub = Debug.EnableGdbStub,
GdbStubPort = Debug.GdbStubPort,
}; };
return configurationFile; return configurationFile;
@ -648,6 +680,8 @@ namespace Ryujinx.Configuration
} }
} }
}; };
Debug.EnableGdbStub.Value = false;
Debug.GdbStubPort.Value = 55555;
} }
public void Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath) public void Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
@ -1027,6 +1061,16 @@ namespace Ryujinx.Configuration
configurationFileUpdated = true; configurationFileUpdated = true;
} }
if (configurationFileFormat.Version < 38)
{
Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 38.");
configurationFileFormat.EnableGdbStub = false;
configurationFileFormat.GdbStubPort = 55555;
configurationFileUpdated = true;
}
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog; Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading; Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading;
Graphics.ResScale.Value = configurationFileFormat.ResScale; Graphics.ResScale.Value = configurationFileFormat.ResScale;
@ -1085,6 +1129,8 @@ namespace Ryujinx.Configuration
Hid.EnableMouse.Value = configurationFileFormat.EnableMouse; Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
Hid.Hotkeys.Value = configurationFileFormat.Hotkeys; Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
Hid.InputConfig.Value = configurationFileFormat.InputConfig; Hid.InputConfig.Value = configurationFileFormat.InputConfig;
Debug.EnableGdbStub.Value = configurationFileFormat.EnableGdbStub;
Debug.GdbStubPort.Value = configurationFileFormat.GdbStubPort;
if (Hid.InputConfig.Value == null) if (Hid.InputConfig.Value == null)
{ {

View file

@ -571,7 +571,9 @@ namespace Ryujinx.Ui
ConfigurationState.Instance.System.MemoryManagerMode, ConfigurationState.Instance.System.MemoryManagerMode,
ConfigurationState.Instance.System.IgnoreMissingServices, ConfigurationState.Instance.System.IgnoreMissingServices,
ConfigurationState.Instance.Graphics.AspectRatio, ConfigurationState.Instance.Graphics.AspectRatio,
ConfigurationState.Instance.System.AudioVolume); ConfigurationState.Instance.System.AudioVolume,
ConfigurationState.Instance.Debug.EnableGdbStub,
ConfigurationState.Instance.Debug.GdbStubPort);
_emulationContext = new HLE.Switch(configuration); _emulationContext = new HLE.Switch(configuration);
} }
@ -673,6 +675,24 @@ namespace Ryujinx.Ui
shadersDumpWarningDialog.Dispose(); shadersDumpWarningDialog.Dispose();
} }
if (ConfigurationState.Instance.Debug.EnableGdbStub.Value)
{
MessageDialog gdbStubWarningDialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
{
Title = "Ryujinx - Warning",
Text = "You have the GDB stub enabled, which is designed to be used by developers only.",
SecondaryText = "For optimal performance, it's recommended to disable the GDB stub. Would you like to disable the GDB stub now?"
};
if (gdbStubWarningDialog.Run() == (int)ResponseType.Yes)
{
ConfigurationState.Instance.Debug.EnableGdbStub.Value = false;
SaveConfig();
}
gdbStubWarningDialog.Dispose();
}
} }
public void LoadApplication(string path, bool startFullscreen = false) public void LoadApplication(string path, bool startFullscreen = false)

View file

@ -102,7 +102,8 @@ namespace Ryujinx.Ui.Windows
[GUI] ToggleButton _configureController7; [GUI] ToggleButton _configureController7;
[GUI] ToggleButton _configureController8; [GUI] ToggleButton _configureController8;
[GUI] ToggleButton _configureControllerH; [GUI] ToggleButton _configureControllerH;
[GUI] ToggleButton _gdbStubToggle;
[GUI] Adjustment _gdbStubPortSpinAdjustment;
#pragma warning restore CS0649, IDE0044 #pragma warning restore CS0649, IDE0044
public SettingsWindow(MainWindow parent, VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this(parent, new Builder("Ryujinx.Ui.Windows.SettingsWindow.glade"), virtualFileSystem, contentManager) { } public SettingsWindow(MainWindow parent, VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this(parent, new Builder("Ryujinx.Ui.Windows.SettingsWindow.glade"), virtualFileSystem, contentManager) { }
@ -282,6 +283,11 @@ namespace Ryujinx.Ui.Windows
_custThemeToggle.Click(); _custThemeToggle.Click();
} }
if (ConfigurationState.Instance.Debug.EnableGdbStub)
{
_gdbStubToggle.Click();
}
// Custom EntryCompletion Columns. If added to glade, need to override more signals // Custom EntryCompletion Columns. If added to glade, need to override more signals
ListStore tzList = new ListStore(typeof(string), typeof(string), typeof(string)); ListStore tzList = new ListStore(typeof(string), typeof(string), typeof(string));
_systemTimeZoneCompletion.Model = tzList; _systemTimeZoneCompletion.Model = tzList;
@ -329,6 +335,8 @@ namespace Ryujinx.Ui.Windows
_fsLogSpinAdjustment.Value = ConfigurationState.Instance.System.FsGlobalAccessLogMode; _fsLogSpinAdjustment.Value = ConfigurationState.Instance.System.FsGlobalAccessLogMode;
_systemTimeOffset = ConfigurationState.Instance.System.SystemTimeOffset; _systemTimeOffset = ConfigurationState.Instance.System.SystemTimeOffset;
_gdbStubPortSpinAdjustment.Value = ConfigurationState.Instance.Debug.GdbStubPort;
_gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0); _gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0);
_gameDirsBoxStore = new ListStore(typeof(string)); _gameDirsBoxStore = new ListStore(typeof(string));
_gameDirsBox.Model = _gameDirsBoxStore; _gameDirsBox.Model = _gameDirsBoxStore;
@ -531,6 +539,8 @@ namespace Ryujinx.Ui.Windows
ConfigurationState.Instance.Graphics.ResScale.Value = int.Parse(_resScaleCombo.ActiveId); ConfigurationState.Instance.Graphics.ResScale.Value = int.Parse(_resScaleCombo.ActiveId);
ConfigurationState.Instance.Graphics.ResScaleCustom.Value = resScaleCustom; ConfigurationState.Instance.Graphics.ResScaleCustom.Value = resScaleCustom;
ConfigurationState.Instance.System.AudioVolume.Value = (float)_audioVolumeSlider.Value / 100.0f; ConfigurationState.Instance.System.AudioVolume.Value = (float)_audioVolumeSlider.Value / 100.0f;
ConfigurationState.Instance.Debug.EnableGdbStub.Value = _gdbStubToggle.Active;
ConfigurationState.Instance.Debug.GdbStubPort.Value = (ushort)_gdbStubPortSpinAdjustment.Value;
_previousVolumeLevel = ConfigurationState.Instance.System.AudioVolume.Value; _previousVolumeLevel = ConfigurationState.Instance.System.AudioVolume.Value;

View file

@ -40,6 +40,12 @@
<property name="inline-completion">True</property> <property name="inline-completion">True</property>
<property name="inline-selection">True</property> <property name="inline-selection">True</property>
</object> </object>
<object class="GtkAdjustment" id="_gdbStubPortSpinAdjustment">
<property name="lower">1</property>
<property name="upper">65535</property>
<property name="step-increment">1</property>
<property name="page-increment">5</property>
</object>
<object class="GtkWindow" id="_settingsWin"> <object class="GtkWindow" id="_settingsWin">
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="title" translatable="yes">Ryujinx - Settings</property> <property name="title" translatable="yes">Ryujinx - Settings</property>
@ -2621,6 +2627,137 @@
<property name="tab-fill">False</property> <property name="tab-fill">False</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkBox" id="TabDebug">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">10</property>
<property name="margin-top">5</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="CatDebug">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-bottom">5</property>
<property name="label" translatable="yes">Debug (WARNING: For Developer Use Only)</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="DebugOptions">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="margin-left">10</property>
<property name="margin-right">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="_gdbStubToggle">
<property name="label" translatable="yes">Enable GDB Stub</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Enables or disables GDB stub (for developer use only)</property>
<property name="halign">start</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Specifies which TCP port for the GDB stub to listen on. Possible values are 1-65535.</property>
<property name="label" translatable="yes">GDB Stub Port</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">Specifies which TCP port for the GDB stub to listen on. Possible values are 1-65535.</property>
<property name="text" translatable="yes">55555</property>
<property name="input-purpose">number</property>
<property name="adjustment">_gdbStubPortSpinAdjustment</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">9</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">5</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Debug</property>
</object>
<packing>
<property name="position">5</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>