Skip to content

Commit

Permalink
[wasm][debugger] Fixing when trying to call mono functions in a non w…
Browse files Browse the repository at this point in the history
…asm page (#77496)

* Fixing when trying to call mono functions in a non wasm page

* Adding a log message as suggested by @radical
  • Loading branch information
thaystg committed Oct 28, 2022
1 parent 8c496e7 commit 24cb35e
Showing 1 changed file with 31 additions and 18 deletions.
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 @@ -1524,27 +1524,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

0 comments on commit 24cb35e

Please sign in to comment.