diff --git a/src/SharpIDE.Application/Features/Debugging/DebuggerProcessStreamHelper.cs b/src/SharpIDE.Application/Features/Debugging/DebuggerProcessStreamHelper.cs index 2d9607a..2fb3b4f 100644 --- a/src/SharpIDE.Application/Features/Debugging/DebuggerProcessStreamHelper.cs +++ b/src/SharpIDE.Application/Features/Debugging/DebuggerProcessStreamHelper.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using Ardalis.GuardClauses; +using Microsoft.Extensions.Logging; using SharpDbg.InMemory; using SharpIDE.Application.Features.Run; @@ -7,12 +8,15 @@ namespace SharpIDE.Application.Features.Debugging; public static class DebuggerProcessStreamHelper { - public static (Stream Input, Stream Output, bool IsNetCoreDbg) NewDebuggerProcessStreamsForInfo(DebuggerExecutableInfo? debuggerExecutableInfoNullable) + public static (Stream Input, Stream Output, bool IsNetCoreDbg) NewDebuggerProcessStreamsForInfo(DebuggerExecutableInfo? debuggerExecutableInfoNullable, ILogger logger) { if (debuggerExecutableInfoNullable is not {} debuggerExecutableInfo) throw new ArgumentNullException(nameof(debuggerExecutableInfoNullable), "Debugger executable info cannot be null."); if (debuggerExecutableInfo.UseInMemorySharpDbg) { - var (input, output) = SharpDbgInMemory.NewDebugAdapterStreams(); + var (input, output) = SharpDbgInMemory.NewDebugAdapterStreams(s => + { + logger.LogInformation("SharpDbgInMemory: {Message}", s); + }); return (input, output, false); } var debuggerExecutablePath = debuggerExecutableInfo.DebuggerExecutablePath; diff --git a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs index 6b9934e..e598952 100644 --- a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs +++ b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using Ardalis.GuardClauses; using Microsoft.Diagnostics.NETCore.Client; +using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol; using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages; using Newtonsoft.Json.Linq; @@ -13,17 +14,19 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence; namespace SharpIDE.Application.Features.Debugging; #pragma warning disable VSTHRD101 -public class DebuggingService +public class DebuggingService(ILogger logger) { private readonly ConcurrentDictionary _debugProtocolHosts = []; + private readonly ILogger _logger = logger; + /// The debugging session ID public async Task Attach(int debuggeeProcessId, DebuggerExecutableInfo? debuggerExecutableInfo, Dictionary> breakpointsByFile, SharpIdeProjectModel project, CancellationToken cancellationToken = default) { Guard.Against.NegativeOrZero(debuggeeProcessId, nameof(debuggeeProcessId), "Process ID must be a positive integer."); await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); - var (inputStream, outputStream, isNetCoreDbg) = DebuggerProcessStreamHelper.NewDebuggerProcessStreamsForInfo(debuggerExecutableInfo); + var (inputStream, outputStream, isNetCoreDbg) = DebuggerProcessStreamHelper.NewDebuggerProcessStreamsForInfo(debuggerExecutableInfo, _logger); var debugProtocolHost = new DebugProtocolHost(inputStream, outputStream, false); var initializedEventTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);