diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index dd4dc6e844218..c77f961fea9bd 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -42,6 +42,7 @@ public MonoProxy(ILogger logger, int runtimeId = 0, string loggerId = "", ProxyO RuntimeId = runtimeId; _options = options; _defaultPauseOnExceptions = PauseOnExceptionsKind.Unset; + JustMyCode = options?.JustMyCode ?? false; } internal virtual Task SendMonoCommand(SessionId id, MonoCommands cmd, CancellationToken token) => SendCommand(id, "Runtime.evaluate", JObject.FromObject(cmd), token); @@ -1277,7 +1278,11 @@ protected async Task Step(MessageId msgId, StepKind kind, CancellationToke return false; if (context.CallStack.Count <= 1 && kind == StepKind.Out) - return false; + { + Frame scope = context.CallStack.FirstOrDefault(); + if (scope is null || !(await context.SdbAgent.IsAsyncMethod(scope.Method.DebugId, token))) + return false; + } var ret = await TryStepOnManagedCodeAndStepOutIfNotPossible(msgId, context, kind, token); if (ret) SendResponse(msgId, Result.Ok(new JObject()), token); diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs index d385e616862d2..f8023955317fd 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs @@ -911,7 +911,7 @@ public async Task GetAssemblyInfo(int assemblyId, CancellationToke } else { - if (asm.asmMetadataReader is null && proxy.JustMyCode) //load on demand + if (asm.asmMetadataReader is null) //load on demand { var assemblyAndPdbData = await GetDataFromAssemblyAndPdbAsync(asm.Name, true, token); if (assemblyAndPdbData is not null) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/ProxyOptions.cs b/src/mono/wasm/debugger/BrowserDebugProxy/ProxyOptions.cs index 0fdfdfc8a8e01..140958f738292 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/ProxyOptions.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/ProxyOptions.cs @@ -29,4 +29,5 @@ public int DevToolsDebugPort public string? LogPath { get; set; } public bool RunningForBlazor { get; set; } public bool IsFirefoxDebugging { get; set; } + public bool JustMyCode { get; set; } } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/ChromeProvider.cs b/src/mono/wasm/debugger/DebuggerTestSuite/ChromeProvider.cs index 49c25ca6f4fe1..90eefd43b41d1 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/ChromeProvider.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/ChromeProvider.cs @@ -87,7 +87,9 @@ public async Task StartBrowserAndProxyAsync(HttpContext context, _logger.LogInformation($"{messagePrefix} launching proxy for {con_str}"); - _debuggerProxy = new DebuggerProxy(loggerFactory, loggerId: Id); + var options = new ProxyOptions(); + options.JustMyCode = true; + _debuggerProxy = new DebuggerProxy(loggerFactory, loggerId: Id, options: options); TestHarnessProxy.RegisterNewProxy(Id, _debuggerProxy); var browserUri = new Uri(con_str); WebSocket? ideSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false); diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs index 1cea900c2d29d..35fd867cb7ab4 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs @@ -874,7 +874,7 @@ public async Task InspectTaskAtLocals() => await CheckInspectLocalsAtBreakpointS await CheckProps(t_props, new { Status = TGetter("Status") - }, "t_props", num_fields: 58); + }, "t_props", num_fields: 33); }); @@ -938,6 +938,12 @@ await EvaluateAndCheck( [Fact] public async Task InspectLocalsUsingClassFromLibraryUsingDebugTypeFull() { + /*DebugType.Full generates symbols in a format that we don't understand (vs portable). If JMC=true (default for tests) then we will not load the assemblies + that don't have debug symbols. With JMC=false, the assembly will be loaded, even with unusable symbols, and the proxy will use the assembly metadata + instead. + + This test specifically tries to inspect an object defined in the external library, so we need JMC=false here.*/ + await SetJustMyCode(false); var expression = $"{{ invoke_static_method('[debugger-test] DebugTypeFull:CallToEvaluateLocal'); }}"; await EvaluateAndCheck( @@ -1002,6 +1008,8 @@ public async Task SetBreakpointInProjectWithColonInSourceName() 1160)] public async Task InspectPropertiesOfObjectFromExternalLibrary(string className, int line) { + //Setting JustMyCode = false because we are trying to inspect an object from an external library, and this is only allowed when JMC is disabled + await SetJustMyCode(false); var expression = $"{{ invoke_static_method('[debugger-test] {className}:Run'); }}"; await EvaluateAndCheck( diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs index 19875081df6d6..15af44015ef79 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs @@ -1045,6 +1045,8 @@ await EvaluateAndCheck( [InlineData(false)] public async Task SteppingIntoLibrarySymbolsLoadedFromSymbolServer(bool justMyCode) { + //The test behavior is expecting to start with JustMyCode disabled + await SetJustMyCode(false); string cachePath = _env.CreateTempDirectory("symbols-cache"); _testOutput.WriteLine($"** Using cache path: {cachePath}"); var searchPaths = new JArray diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj index 3dad6526e0c50..4bd104e189426 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj @@ -52,8 +52,13 @@ - - + + + + + + + false $(AppDir)