Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Internal Debugger: Start program paused #873

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading