debugger continue on exception
This commit is contained in:
@@ -7,9 +7,9 @@ public class Debugger
|
|||||||
{
|
{
|
||||||
public required SharpIdeProjectModel Project { get; init; }
|
public required SharpIdeProjectModel Project { get; init; }
|
||||||
public required int ProcessId { get; init; }
|
public required int ProcessId { get; init; }
|
||||||
|
private DebuggingService _debuggingService = new DebuggingService();
|
||||||
public async Task Attach(CancellationToken cancellationToken)
|
public async Task Attach(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var debuggingService = new DebuggingService();
|
await _debuggingService.Attach(ProcessId, cancellationToken);
|
||||||
await debuggingService.Attach(ProcessId, cancellationToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace SharpIDE.Application.Features.Debugging;
|
|||||||
|
|
||||||
public class DebuggingService
|
public class DebuggingService
|
||||||
{
|
{
|
||||||
|
private DebugProtocolHost _debugProtocolHost = null!;
|
||||||
public async Task Attach(int debuggeeProcessId, CancellationToken cancellationToken = default)
|
public async Task Attach(int debuggeeProcessId, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
Guard.Against.NegativeOrZero(debuggeeProcessId, nameof(debuggeeProcessId), "Process ID must be a positive integer.");
|
Guard.Against.NegativeOrZero(debuggeeProcessId, nameof(debuggeeProcessId), "Process ID must be a positive integer.");
|
||||||
@@ -32,6 +33,7 @@ public class DebuggingService
|
|||||||
process.Start();
|
process.Start();
|
||||||
|
|
||||||
var debugProtocolHost = new DebugProtocolHost(process.StandardInput.BaseStream, process.StandardOutput.BaseStream, false);
|
var debugProtocolHost = new DebugProtocolHost(process.StandardInput.BaseStream, process.StandardOutput.BaseStream, false);
|
||||||
|
_debugProtocolHost = debugProtocolHost;
|
||||||
debugProtocolHost.LogMessage += (sender, args) =>
|
debugProtocolHost.LogMessage += (sender, args) =>
|
||||||
{
|
{
|
||||||
//Console.WriteLine($"Log message: {args.Message}");
|
//Console.WriteLine($"Log message: {args.Message}");
|
||||||
@@ -58,10 +60,15 @@ public class DebuggingService
|
|||||||
var signatureResponse = VsSigner.Sign(responder.Arguments.Value);
|
var signatureResponse = VsSigner.Sign(responder.Arguments.Value);
|
||||||
responder.SetResponse(new HandshakeResponse(signatureResponse));
|
responder.SetResponse(new HandshakeResponse(signatureResponse));
|
||||||
});
|
});
|
||||||
debugProtocolHost.RegisterEventType<StoppedEvent>(@event =>
|
debugProtocolHost.RegisterEventType<StoppedEvent>(async void (@event) =>
|
||||||
{
|
{
|
||||||
;
|
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); // The VS Code Debug Protocol throws if you try to send a request from the dispatcher thread
|
||||||
var threadId = @event.ThreadId;
|
if (@event.Reason is StoppedEvent.ReasonValue.Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Stopped due to exception, continuing");
|
||||||
|
var continueRequest = new ContinueRequest { ThreadId = @event.ThreadId!.Value };
|
||||||
|
_debugProtocolHost.SendRequestSync(continueRequest);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
debugProtocolHost.VerifySynchronousOperationAllowed();
|
debugProtocolHost.VerifySynchronousOperationAllowed();
|
||||||
var initializeRequest = new InitializeRequest
|
var initializeRequest = new InitializeRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user