Skip to content
Merged
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
49 changes: 31 additions & 18 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,27 +1546,40 @@ async Task<string[]> GetLoadedFiles(SessionId sessionId, ExecutionContext contex

protected async Task<DebugStore> RuntimeReady(SessionId sessionId, CancellationToken token)
{
ExecutionContext context = GetContext(sessionId);
if (Interlocked.CompareExchange(ref context.ready, new TaskCompletionSource<DebugStore>(), null) != null)
return await context.ready.Task;
var res = await context.SdbAgent.SendDebuggerAgentCommand(CmdEventRequest.ClearAllBreakpoints, null, token, false);
if (res.HasError) //it's not a wasm page then the command returns an error
return null;
try
{
ExecutionContext context = GetContext(sessionId);
if (Interlocked.CompareExchange(ref context.ready, new TaskCompletionSource<DebugStore>(), null) != null)
return await context.ready.Task;
await context.SdbAgent.SendDebuggerAgentCommand(CmdEventRequest.ClearAllBreakpoints, null, token);

if (context.PauseOnExceptions != PauseOnExceptionsKind.None && context.PauseOnExceptions != PauseOnExceptionsKind.Unset)
await context.SdbAgent.EnableExceptions(context.PauseOnExceptions, token);
if (context.PauseOnExceptions != PauseOnExceptionsKind.None && context.PauseOnExceptions != PauseOnExceptionsKind.Unset)
await context.SdbAgent.EnableExceptions(context.PauseOnExceptions, token);

await context.SdbAgent.SetProtocolVersion(token);
await context.SdbAgent.EnableReceiveRequests(EventKind.UserBreak, token);
await context.SdbAgent.EnableReceiveRequests(EventKind.EnC, token);
await context.SdbAgent.EnableReceiveRequests(EventKind.MethodUpdate, token);
await context.SdbAgent.SetProtocolVersion(token);
await context.SdbAgent.EnableReceiveRequests(EventKind.UserBreak, token);
await context.SdbAgent.EnableReceiveRequests(EventKind.EnC, token);
await context.SdbAgent.EnableReceiveRequests(EventKind.MethodUpdate, token);

DebugStore store = await LoadStore(sessionId, true, token);
context.ready.SetResult(store);
await SendEvent(sessionId, "Mono.runtimeReady", new JObject(), token);
await SendMonoCommand(sessionId, MonoCommands.SetDebuggerAttached(RuntimeId), token);
context.SdbAgent.ResetStore(store);
return store;
DebugStore store = await LoadStore(sessionId, true, token);
context.ready.SetResult(store);
await SendEvent(sessionId, "Mono.runtimeReady", new JObject(), token);
await SendMonoCommand(sessionId, MonoCommands.SetDebuggerAttached(RuntimeId), token);
context.SdbAgent.ResetStore(store);
return store;
}
catch (DebuggerAgentException e)
{
//it's not a wasm page then the command throws an error
if (!e.Message.Contains("getDotnetRuntime is not defined"))
logger.LogDebug($"Unexpected error on RuntimeReady {e}");
return null;
}
catch (Exception e)
{
logger.LogDebug($"Unexpected error on RuntimeReady {e}");
return null;
}
}

private static IEnumerable<IGrouping<SourceId, SourceLocation>> GetBPReqLocations(DebugStore store, BreakpointRequest req, bool ifNoneFoundThenFindNext = false)
Expand Down