Log SharpDbg logs
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Ardalis.GuardClauses;
|
using Ardalis.GuardClauses;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using SharpDbg.InMemory;
|
using SharpDbg.InMemory;
|
||||||
using SharpIDE.Application.Features.Run;
|
using SharpIDE.Application.Features.Run;
|
||||||
|
|
||||||
@@ -7,12 +8,15 @@ namespace SharpIDE.Application.Features.Debugging;
|
|||||||
|
|
||||||
public static class DebuggerProcessStreamHelper
|
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<DebuggingService> logger)
|
||||||
{
|
{
|
||||||
if (debuggerExecutableInfoNullable is not {} debuggerExecutableInfo) throw new ArgumentNullException(nameof(debuggerExecutableInfoNullable), "Debugger executable info cannot be null.");
|
if (debuggerExecutableInfoNullable is not {} debuggerExecutableInfo) throw new ArgumentNullException(nameof(debuggerExecutableInfoNullable), "Debugger executable info cannot be null.");
|
||||||
if (debuggerExecutableInfo.UseInMemorySharpDbg)
|
if (debuggerExecutableInfo.UseInMemorySharpDbg)
|
||||||
{
|
{
|
||||||
var (input, output) = SharpDbgInMemory.NewDebugAdapterStreams();
|
var (input, output) = SharpDbgInMemory.NewDebugAdapterStreams(s =>
|
||||||
|
{
|
||||||
|
logger.LogInformation("SharpDbgInMemory: {Message}", s);
|
||||||
|
});
|
||||||
return (input, output, false);
|
return (input, output, false);
|
||||||
}
|
}
|
||||||
var debuggerExecutablePath = debuggerExecutableInfo.DebuggerExecutablePath;
|
var debuggerExecutablePath = debuggerExecutableInfo.DebuggerExecutablePath;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using Ardalis.GuardClauses;
|
using Ardalis.GuardClauses;
|
||||||
using Microsoft.Diagnostics.NETCore.Client;
|
using Microsoft.Diagnostics.NETCore.Client;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol;
|
using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol;
|
||||||
using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages;
|
using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -13,17 +14,19 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
|||||||
namespace SharpIDE.Application.Features.Debugging;
|
namespace SharpIDE.Application.Features.Debugging;
|
||||||
|
|
||||||
#pragma warning disable VSTHRD101
|
#pragma warning disable VSTHRD101
|
||||||
public class DebuggingService
|
public class DebuggingService(ILogger<DebuggingService> logger)
|
||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<DebuggerSessionId, DebugProtocolHost> _debugProtocolHosts = [];
|
private readonly ConcurrentDictionary<DebuggerSessionId, DebugProtocolHost> _debugProtocolHosts = [];
|
||||||
|
|
||||||
|
private readonly ILogger<DebuggingService> _logger = logger;
|
||||||
|
|
||||||
/// <returns>The debugging session ID</returns>
|
/// <returns>The debugging session ID</returns>
|
||||||
public async Task<DebuggerSessionId> Attach(int debuggeeProcessId, DebuggerExecutableInfo? debuggerExecutableInfo, Dictionary<SharpIdeFile, List<Breakpoint>> breakpointsByFile, SharpIdeProjectModel project, CancellationToken cancellationToken = default)
|
public async Task<DebuggerSessionId> Attach(int debuggeeProcessId, DebuggerExecutableInfo? debuggerExecutableInfo, Dictionary<SharpIdeFile, List<Breakpoint>> breakpointsByFile, SharpIdeProjectModel project, 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.");
|
||||||
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
|
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 debugProtocolHost = new DebugProtocolHost(inputStream, outputStream, false);
|
||||||
var initializedEventTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
var initializedEventTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|||||||
Reference in New Issue
Block a user