Skip to content

Commit 96c24ea

Browse files
[release/7.0] [wasm][debugger] Fixing when trying to call mono functions in a non wasm page (#77501)
* Fixing when trying to call mono functions in a non wasm page * Adding a log message as suggested by @radical Co-authored-by: Thays Grazia <[email protected]>
1 parent d0e0f16 commit 96c24ea

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,27 +1547,40 @@ async Task<string[]> GetLoadedFiles(SessionId sessionId, ExecutionContext contex
15471547

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

1557-
if (context.PauseOnExceptions != PauseOnExceptionsKind.None && context.PauseOnExceptions != PauseOnExceptionsKind.Unset)
1558-
await context.SdbAgent.EnableExceptions(context.PauseOnExceptions, token);
1557+
if (context.PauseOnExceptions != PauseOnExceptionsKind.None && context.PauseOnExceptions != PauseOnExceptionsKind.Unset)
1558+
await context.SdbAgent.EnableExceptions(context.PauseOnExceptions, token);
15591559

1560-
await context.SdbAgent.SetProtocolVersion(token);
1561-
await context.SdbAgent.EnableReceiveRequests(EventKind.UserBreak, token);
1562-
await context.SdbAgent.EnableReceiveRequests(EventKind.EnC, token);
1563-
await context.SdbAgent.EnableReceiveRequests(EventKind.MethodUpdate, token);
1560+
await context.SdbAgent.SetProtocolVersion(token);
1561+
await context.SdbAgent.EnableReceiveRequests(EventKind.UserBreak, token);
1562+
await context.SdbAgent.EnableReceiveRequests(EventKind.EnC, token);
1563+
await context.SdbAgent.EnableReceiveRequests(EventKind.MethodUpdate, token);
15641564

1565-
DebugStore store = await LoadStore(sessionId, true, token);
1566-
context.ready.SetResult(store);
1567-
await SendEvent(sessionId, "Mono.runtimeReady", new JObject(), token);
1568-
await SendMonoCommand(sessionId, MonoCommands.SetDebuggerAttached(RuntimeId), token);
1569-
context.SdbAgent.ResetStore(store);
1570-
return store;
1565+
DebugStore store = await LoadStore(sessionId, true, token);
1566+
context.ready.SetResult(store);
1567+
await SendEvent(sessionId, "Mono.runtimeReady", new JObject(), token);
1568+
await SendMonoCommand(sessionId, MonoCommands.SetDebuggerAttached(RuntimeId), token);
1569+
context.SdbAgent.ResetStore(store);
1570+
return store;
1571+
}
1572+
catch (DebuggerAgentException e)
1573+
{
1574+
//it's not a wasm page then the command throws an error
1575+
if (!e.Message.Contains("getDotnetRuntime is not defined"))
1576+
logger.LogDebug($"Unexpected error on RuntimeReady {e}");
1577+
return null;
1578+
}
1579+
catch (Exception e)
1580+
{
1581+
logger.LogDebug($"Unexpected error on RuntimeReady {e}");
1582+
return null;
1583+
}
15711584
}
15721585

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

0 commit comments

Comments
 (0)