Forge
csharp5e452b8e
1using DotnetDebug.Core;
2
3namespace DotnetDebugMcp;
4
5internal static class DapHelpers
6{
7 internal static Task<bool> TrySetUnhandledExceptionBreakpointsAsync(DapClient client) =>
8 DapShared.TrySetUnhandledExceptionBreakpointsAsync(client);
9
10 internal static (DapClient client, int threadId) GetSessionAndThreadId()
11 {
12 var client = DebugSession.CurrentClient
13 ?? throw new InvalidOperationException("No active debug session. Run debug_launch first.");
14 var threadId = DebugSession.LastStoppedThreadId;
15 if (threadId == 0)
16 throw new InvalidOperationException("Execution has not stopped on a breakpoint yet (no stopped event received). Ensure the target hits a breakpoint after debug_launch, or use debug_continue and wait for the next stop.");
17 return (client, threadId);
18 }
19
20 internal static Task WithRetryVoidAsync(Func<Task> action) =>
21 DapShared.WithRetryVoidAsync(action);
22
23 internal static Task<T> WithRetryAsync<T>(Func<Task<T>> action) =>
24 DapShared.WithRetryAsync(action);
25
26 internal static string ResolveBreakpointFilePath(string workspaceRoot, string filePath) =>
27 DapShared.ResolveBreakpointFilePath(workspaceRoot, filePath);
28
29 internal static string FormatException(Exception ex)
30 {
31 var msg = ex.Message;
32 if (ex.InnerException != null)
33 msg += "\nInner: " + ex.InnerException.Message;
34 msg += "\n" + ex.StackTrace;
35 return msg;
36 }
37}
38
View only · write via MCP/CIDE