Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] [wasm][debugger] Fixing when trying to call mono functions in a non wasm page #77501

Merged
merged 2 commits into from
Nov 3, 2022
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