From c83255cf7cd94dfe9da878a56c3e00ba56d2b24a Mon Sep 17 00:00:00 2001 From: "DELL_THAYS\\thays" Date: Mon, 25 Jul 2022 17:02:22 -0300 Subject: [PATCH 1/7] Removing console.debug message helper to make debugger work. --- ...buggerProxy.cs => FirefoxDebuggerProxy.cs} | 0 .../Firefox/FirefoxExecutionContext.cs | 3 ++- .../Firefox/FirefoxMonoProxy.cs | 21 +++++++++++++++---- .../debugger/BrowserDebugProxy/MonoProxy.cs | 7 ++++--- .../tests/debugger-test/debugger-driver.html | 2 ++ .../wasm-page-without-assets.html | 1 + src/mono/wasm/runtime/debug.ts | 2 -- 7 files changed, 26 insertions(+), 10 deletions(-) rename src/mono/wasm/debugger/BrowserDebugProxy/Firefox/{FireforDebuggerProxy.cs => FirefoxDebuggerProxy.cs} (100%) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FireforDebuggerProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxDebuggerProxy.cs similarity index 100% rename from src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FireforDebuggerProxy.cs rename to src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxDebuggerProxy.cs diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxExecutionContext.cs b/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxExecutionContext.cs index 253b7316779537..095970f4c799cb 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxExecutionContext.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxExecutionContext.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Threading; +using System.Threading.Tasks; #nullable enable @@ -12,7 +13,7 @@ internal sealed class FirefoxExecutionContext : ExecutionContext public string? ActorName { get; set; } public string? ThreadName { get; set; } public string? GlobalName { get; set; } - public Result LastDebuggerAgentBufferReceived { get; set; } + public Task? LastDebuggerAgentBufferReceived { get; set; } public FirefoxExecutionContext(MonoSDBHelper sdbAgent, int id, string actorName) : base(sdbAgent, id, actorName, PauseOnExceptionsKind.Unset) { diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxMonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxMonoProxy.cs index c34689b5e9e090..2152b8f306b274 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxMonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/Firefox/FirefoxMonoProxy.cs @@ -262,7 +262,8 @@ protected override async Task AcceptEvent(SessionId sessionId, JObject arg return true; if (args["type"] == null) - return await Task.FromResult(false); + return false; + switch (args["type"].Value()) { case "paused": @@ -318,6 +319,16 @@ await Task.WhenAll( case "target-available-form": { OnDefaultContextUpdate(sessionId, new FirefoxExecutionContext(new MonoSDBHelper (this, logger, sessionId), 0, args["target"]["consoleActor"].Value())); + var ctx = GetContextFixefox(sessionId); + ctx.GlobalName = args["target"]["actor"].Value(); + ctx.ThreadName = args["target"]["threadActor"].Value(); + ResetCmdId(); + if (await IsRuntimeAlreadyReadyAlready(sessionId, token)) + { + await ForwardMessageToIde(args, token); + await RuntimeReady(sessionId, token); + return true; + } break; } } @@ -364,6 +375,8 @@ protected override async Task AcceptCommand(MessageId sessionId, JObject a { var ctx = GetContextFixefox(sessionId); ctx.ThreadName = args["to"].Value(); + if (await IsRuntimeAlreadyReadyAlready(sessionId, token)) + await RuntimeReady(sessionId, token); break; } case "source": @@ -698,16 +711,16 @@ protected override async Task AcceptCommand(MessageId sessionId, JObject a return false; } - internal override void SaveLastDebuggerAgentBufferReceivedToContext(SessionId sessionId, Result res) + internal override void SaveLastDebuggerAgentBufferReceivedToContext(SessionId sessionId, Task debuggerAgentBufferTask) { var context = GetContextFixefox(sessionId); - context.LastDebuggerAgentBufferReceived = res; + context.LastDebuggerAgentBufferReceived = debuggerAgentBufferTask; } private async Task SendPauseToBrowser(SessionId sessionId, JObject args, CancellationToken token) { var context = GetContextFixefox(sessionId); - Result res = context.LastDebuggerAgentBufferReceived; + Result res = await context.LastDebuggerAgentBufferReceived; if (!res.IsOk) return false; diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 82541a4a755136..530c1661f3be26 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -1040,14 +1040,15 @@ protected virtual async Task SendCallStack(SessionId sessionId, ExecutionC return true; } - internal virtual void SaveLastDebuggerAgentBufferReceivedToContext(SessionId sessionId, Result res) + internal virtual void SaveLastDebuggerAgentBufferReceivedToContext(SessionId sessionId, Task debuggerAgentBufferTask) { } internal async Task OnReceiveDebuggerAgentEvent(SessionId sessionId, JObject args, CancellationToken token) { - Result res = await SendMonoCommand(sessionId, MonoCommands.GetDebuggerAgentBufferReceived(RuntimeId), token); - SaveLastDebuggerAgentBufferReceivedToContext(sessionId, res); + var debuggerAgentBufferTask = SendMonoCommand(sessionId, MonoCommands.GetDebuggerAgentBufferReceived(RuntimeId), token); + SaveLastDebuggerAgentBufferReceivedToContext(sessionId, debuggerAgentBufferTask); + var res = await debuggerAgentBufferTask; if (!res.IsOk) return false; diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html index 239039451ccdd7..bfa05daff5599f 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html @@ -17,6 +17,7 @@ this.run_all = getDotnetRuntime(0).INTERNAL.mono_bind_static_method ("[debugger-test] DebuggerTest:run_all"); this.static_method_table = {}; console.log ("ready"); + console.debug("mono_wasm_runtime_ready", "fe00e07a-5519-4dfe-b35a-f867dbaf2e28"); }, }; function invoke_static_method (method_name, ...args) { @@ -90,6 +91,7 @@ function load_wasm_page_without_assets () { console.log("load_wasm_page_without_assets") window.location.replace("http://localhost:9400/wasm-page-without-assets.html"); + console.debug ("mono_wasm_runtime_ready", "fe00e07a-5519-4dfe-b35a-f867dbaf2e28"); } diff --git a/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html b/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html index 992e9bac68a779..08a99681974647 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html +++ b/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html @@ -6,6 +6,7 @@