Skip to content

Commit

Permalink
feature: Internal Debugger: Start program paused
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
  • Loading branch information
maximilien-noal committed Sep 30, 2024
1 parent fdcd265 commit a990326
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Spice86.Core/CLI/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ namespace Spice86.Core.CLI;
/// <summary> Configuration for spice86, that is what to run and how. Set on startup. </summary>
public sealed class Configuration {
/// <summary>
/// Gets or sets whether the A20 gate is silenced. If <c>true</c> memory addresses will rollover above 1 MB.
/// Gets if the A20 gate is silenced. If <c>true</c> memory addresses will rollover above 1 MB.
/// </summary>
[Option(nameof(A20Gate), Default = false, Required = false, HelpText = "Whether the 20th address line is silenced. Used for legacy 8086 programs.")]
public bool A20Gate { get; init; }

/// <summary>
/// Gets if the program will be paused on startup. If <see cref="GdbPort"/> is set, the program will be paused anyway.
/// </summary>
[Option(nameof(Debug), Default = false, Required = false, HelpText = "Gets if the program will be paused on startup.")]
public bool Debug { get; init; }

/// <summary> Path to C drive, default is exe parent. </summary>
[Option('c', nameof(CDrive), Default = null, Required = false, HelpText = "Path to C drive, default is exe parent")]
Expand Down
8 changes: 7 additions & 1 deletion src/Spice86.Core/Emulator/ProgramExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
public sealed class ProgramExecutor : IDisposable {
private bool _disposed;
private readonly ILoggerService _loggerService;
private readonly IPauseHandler _pauseHandler;
private readonly Configuration _configuration;
private readonly GdbServer? _gdbServer;
private readonly EmulationLoop _emulationLoop;
Expand Down Expand Up @@ -62,6 +63,7 @@ public ProgramExecutor(Configuration configuration,
_configuration = configuration;
_loggerService = loggerService;
_emulatorStateSerializer = emulatorStateSerializer;
_pauseHandler = pauseHandler;
_emulationLoop = new EmulationLoop(_loggerService, functionHandler, cpu, state, timer,
emulatorBreakpointsManager, pauseHandler);
if (configuration.GdbPort.HasValue) {
Expand All @@ -86,7 +88,11 @@ public ProgramExecutor(Configuration configuration,
/// Starts the loaded program.
/// </summary>
public void Run() {
_gdbServer?.StartServerAndWait();
if (_gdbServer is not null) {
_gdbServer?.StartServerAndWait();
} else if (_configuration.Debug) {
_pauseHandler.RequestPause("Starting the emulated program paused was requested");
}
_emulationLoop.Run();

if (_configuration.DumpDataOnExit is not false) {
Expand Down

0 comments on commit a990326

Please sign in to comment.