Skip to content

Commit b4357e1

Browse files
authored
[wasm][debugger]Trying to improve CI performance for debugger-tests (dotnet#89525)
* Trying to improve CI performance for debugger-tests to avoid the crashes and the timeouts. * Fixing one test and setting just my code TRUE as default. * Fix compilation * Fixing tests * Fixing test behavior and adding comments suggested by @radical
1 parent 6089ff6 commit b4357e1

File tree

7 files changed

+29
-6
lines changed

7 files changed

+29
-6
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public MonoProxy(ILogger logger, int runtimeId = 0, string loggerId = "", ProxyO
4242
RuntimeId = runtimeId;
4343
_options = options;
4444
_defaultPauseOnExceptions = PauseOnExceptionsKind.Unset;
45+
JustMyCode = options?.JustMyCode ?? false;
4546
}
4647

4748
internal virtual Task<Result> SendMonoCommand(SessionId id, MonoCommands cmd, CancellationToken token) => SendCommand(id, "Runtime.evaluate", JObject.FromObject(cmd), token);
@@ -1277,7 +1278,11 @@ protected async Task<bool> Step(MessageId msgId, StepKind kind, CancellationToke
12771278
return false;
12781279

12791280
if (context.CallStack.Count <= 1 && kind == StepKind.Out)
1280-
return false;
1281+
{
1282+
Frame scope = context.CallStack.FirstOrDefault<Frame>();
1283+
if (scope is null || !(await context.SdbAgent.IsAsyncMethod(scope.Method.DebugId, token)))
1284+
return false;
1285+
}
12811286
var ret = await TryStepOnManagedCodeAndStepOutIfNotPossible(msgId, context, kind, token);
12821287
if (ret)
12831288
SendResponse(msgId, Result.Ok(new JObject()), token);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ public async Task<AssemblyInfo> GetAssemblyInfo(int assemblyId, CancellationToke
911911
}
912912
else
913913
{
914-
if (asm.asmMetadataReader is null && proxy.JustMyCode) //load on demand
914+
if (asm.asmMetadataReader is null) //load on demand
915915
{
916916
var assemblyAndPdbData = await GetDataFromAssemblyAndPdbAsync(asm.Name, true, token);
917917
if (assemblyAndPdbData is not null)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ public int DevToolsDebugPort
2929
public string? LogPath { get; set; }
3030
public bool RunningForBlazor { get; set; }
3131
public bool IsFirefoxDebugging { get; set; }
32+
public bool JustMyCode { get; set; }
3233
}

src/mono/wasm/debugger/DebuggerTestSuite/ChromeProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ public async Task StartBrowserAndProxyAsync(HttpContext context,
8787

8888
_logger.LogInformation($"{messagePrefix} launching proxy for {con_str}");
8989

90-
_debuggerProxy = new DebuggerProxy(loggerFactory, loggerId: Id);
90+
var options = new ProxyOptions();
91+
options.JustMyCode = true;
92+
_debuggerProxy = new DebuggerProxy(loggerFactory, loggerId: Id, options: options);
9193
TestHarnessProxy.RegisterNewProxy(Id, _debuggerProxy);
9294
var browserUri = new Uri(con_str);
9395
WebSocket? ideSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false);

src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ public async Task InspectTaskAtLocals() => await CheckInspectLocalsAtBreakpointS
874874
await CheckProps(t_props, new
875875
{
876876
Status = TGetter("Status")
877-
}, "t_props", num_fields: 58);
877+
}, "t_props", num_fields: 33);
878878
});
879879

880880

@@ -938,6 +938,12 @@ await EvaluateAndCheck(
938938
[Fact]
939939
public async Task InspectLocalsUsingClassFromLibraryUsingDebugTypeFull()
940940
{
941+
/*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
942+
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
943+
instead.
944+
945+
This test specifically tries to inspect an object defined in the external library, so we need JMC=false here.*/
946+
await SetJustMyCode(false);
941947
var expression = $"{{ invoke_static_method('[debugger-test] DebugTypeFull:CallToEvaluateLocal'); }}";
942948

943949
await EvaluateAndCheck(
@@ -1002,6 +1008,8 @@ public async Task SetBreakpointInProjectWithColonInSourceName()
10021008
1160)]
10031009
public async Task InspectPropertiesOfObjectFromExternalLibrary(string className, int line)
10041010
{
1011+
//Setting JustMyCode = false because we are trying to inspect an object from an external library, and this is only allowed when JMC is disabled
1012+
await SetJustMyCode(false);
10051013
var expression = $"{{ invoke_static_method('[debugger-test] {className}:Run'); }}";
10061014

10071015
await EvaluateAndCheck(

src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ await EvaluateAndCheck(
10451045
[InlineData(false)]
10461046
public async Task SteppingIntoLibrarySymbolsLoadedFromSymbolServer(bool justMyCode)
10471047
{
1048+
//The test behavior is expecting to start with JustMyCode disabled
1049+
await SetJustMyCode(false);
10481050
string cachePath = _env.CreateTempDirectory("symbols-cache");
10491051
_testOutput.WriteLine($"** Using cache path: {cachePath}");
10501052
var searchPaths = new JArray

src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@
5252
<Target Name="PrepareForWasmBuildApp" DependsOnTargets="Build">
5353
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)native')"
5454
Text="Cannot find %24(MicrosoftNetCoreAppRuntimePackRidDir)=$(MicrosoftNetCoreAppRuntimePackRidDir)native. Make sure to set the runtime configuration with %24(RuntimeConfiguration). Current value: $(RuntimeConfiguration)" />
55-
<!-- Remove pdb from System.Private.CoreLib to have the same scenario that we have in a Blazor/Wasm user app -->
56-
<Delete Files="$(MicrosoftNetCoreAppRuntimePackRidDir)native/System.Private.CoreLib.pdb" />
55+
<ItemGroup>
56+
<!-- Remove pdb from System.Private.CoreLib to have the same scenario that we have in a Blazor/Wasm user app -->
57+
<FilesToDelete Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native/System.Private.CoreLib.pdb"/>
58+
<!-- Remove pdb from all libraries in CI to improve CI performance and have the same scenario that we have in a Blazor/Wasm user app -->
59+
<FilesToDelete Condition="'$(ContinuousIntegrationBuild)' == 'true'" Include="$(MicrosoftNetCoreAppRuntimePackRidDir)lib/$(AspNetCoreAppCurrent)/*.pdb" Exclude="$(MicrosoftNetCoreAppRuntimePackRidDir)lib/$(AspNetCoreAppCurrent)/System.Console.pdb"/>
60+
</ItemGroup>
61+
<Delete Files="@(FilesToDelete)"/>
5762
<PropertyGroup>
5863
<EnableDefaultWasmAssembliesToBundle>false</EnableDefaultWasmAssembliesToBundle>
5964
<WasmAppDir>$(AppDir)</WasmAppDir>

0 commit comments

Comments
 (0)