Skip to content

Commit

Permalink
[wasm][debugger]Trying to improve CI performance for debugger-tests (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
thaystg committed Jul 27, 2023
1 parent 6089ff6 commit b4357e1
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Result> SendMonoCommand(SessionId id, MonoCommands cmd, CancellationToken token) => SendCommand(id, "Runtime.evaluate", JObject.FromObject(cmd), token);
Expand Down Expand Up @@ -1277,7 +1278,11 @@ protected async Task<bool> Step(MessageId msgId, StepKind kind, CancellationToke
return false;

if (context.CallStack.Count <= 1 && kind == StepKind.Out)
return false;
{
Frame scope = context.CallStack.FirstOrDefault<Frame>();
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);
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ public async Task<AssemblyInfo> 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)
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/debugger/BrowserDebugProxy/ProxyOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
4 changes: 3 additions & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/ChromeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});


Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@
<Target Name="PrepareForWasmBuildApp" DependsOnTargets="Build">
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)native')"
Text="Cannot find %24(MicrosoftNetCoreAppRuntimePackRidDir)=$(MicrosoftNetCoreAppRuntimePackRidDir)native. Make sure to set the runtime configuration with %24(RuntimeConfiguration). Current value: $(RuntimeConfiguration)" />
<!-- Remove pdb from System.Private.CoreLib to have the same scenario that we have in a Blazor/Wasm user app -->
<Delete Files="$(MicrosoftNetCoreAppRuntimePackRidDir)native/System.Private.CoreLib.pdb" />
<ItemGroup>
<!-- Remove pdb from System.Private.CoreLib to have the same scenario that we have in a Blazor/Wasm user app -->
<FilesToDelete Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native/System.Private.CoreLib.pdb"/>
<!-- 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 -->
<FilesToDelete Condition="'$(ContinuousIntegrationBuild)' == 'true'" Include="$(MicrosoftNetCoreAppRuntimePackRidDir)lib/$(AspNetCoreAppCurrent)/*.pdb" Exclude="$(MicrosoftNetCoreAppRuntimePackRidDir)lib/$(AspNetCoreAppCurrent)/System.Console.pdb"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)"/>
<PropertyGroup>
<EnableDefaultWasmAssembliesToBundle>false</EnableDefaultWasmAssembliesToBundle>
<WasmAppDir>$(AppDir)</WasmAppDir>
Expand Down

0 comments on commit b4357e1

Please sign in to comment.