Skip to content

Commit

Permalink
[wasm] [debugger] Skip thread static field (#56749)
Browse files Browse the repository at this point in the history
* Fix #56249

* Fix line test.

* Fix indentation.

* Addressing PR comments.

* Fix line number changed
  • Loading branch information
thaystg committed Aug 3, 2021
1 parent 90edb16 commit 52d216e
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -8025,6 +8025,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
buffer_add_string (buf, f->name);
buffer_add_typeid (buf, domain, mono_class_from_mono_type_internal (f->type));
buffer_add_int (buf, f->type->attrs);
if (CHECK_PROTOCOL_VERSION(2, 61))
buffer_add_int(buf, mono_class_field_is_special_static(f));
i ++;
}
g_assert (i == nfields);
Expand Down
3 changes: 3 additions & 0 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,9 @@ public async Task<List<FieldTypeClass>> GetTypeFields(SessionId sessionId, int t
string fieldNameStr = retDebuggerCmdReader.ReadString();
int typeId = retDebuggerCmdReader.ReadInt32(); //typeId
retDebuggerCmdReader.ReadInt32(); //attrs
int isSpecialStatic = retDebuggerCmdReader.ReadInt32(); //is_special_static
if (isSpecialStatic == 1)
continue;
if (fieldNameStr.Contains("k__BackingField"))
{
fieldNameStr = fieldNameStr.Replace("k__BackingField", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public async Task BreakOnDebuggerBreak()
{
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);",
"dotnet://debugger-test.dll/debugger-test2.cs", 56, 4,
"dotnet://debugger-test.dll/debugger-test2.cs", 58, 4,
"BreakOnDebuggerBreakCommand");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public async Task GetObjectValueWithInheritance()
{
var pause_location = await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);",
"dotnet://debugger-test.dll/debugger-test2.cs", 83, 4,
"dotnet://debugger-test.dll/debugger-test2.cs", 122, 4,
"TestWatchWithInheritance");
var frame_id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
var frame_locals = await GetProperties(frame_id);
Expand Down
21 changes: 20 additions & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task ExceptionThrownInJSOutOfBand()
[Fact]
public async Task InspectLocalsTypesAtBreakpointSite() =>
await CheckInspectLocalsAtBreakpointSite(
"dotnet://debugger-test.dll/debugger-test2.cs", 48, 8, "Types",
"dotnet://debugger-test.dll/debugger-test2.cs", 50, 8, "Types",
"window.setTimeout(function() { invoke_static_method (\"[debugger-test] Fancy:Types\")(); }, 1);",
use_cfo: false,
test_fn: (locals) =>
Expand Down Expand Up @@ -826,6 +826,25 @@ public async Task GetSourceUsingSourceLink()
Assert.True(source.IsOk);
}

[Fact]
public async Task InspectTaskAtLocals() => await CheckInspectLocalsAtBreakpointSite(
"InspectTask",
"RunInspectTask",
7,
"<RunInspectTask>b__0" ,
$"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] InspectTask:RunInspectTask'); }}, 1);",
wait_for_event_fn: async (pause_location) =>
{
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
var t_props = await GetObjectOnLocals(locals, "t");
await CheckProps(t_props, new
{
s_taskIdCounter = TNumber(0),
Status = TGetter("Status")
}, "t_props", num_fields: 53);
});

//TODO add tests covering basic stepping behavior as step in/out/over
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<WasmExtraFilesToDeploy Include="debugger-driver.html" />
<WasmExtraFilesToDeploy Include="other.js" />
<WasmExtraFilesToDeploy Include="runtime-debugger.js" />
<WasmExtraFilesToDeploy Include="weather.json" />

<!-- We want to bundle these assemblies, so build them first -->
<ProjectReference Include="..\lazy-debugger-test\lazy-debugger-test.csproj" Private="true"/>
Expand Down
39 changes: 39 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System;
using System.Diagnostics;
using System.Net.Http.Json;

public class Misc
{ //Only append content to this class as the test suite depends on line info
public static int CreateObject(int foo, int bar)
Expand Down Expand Up @@ -57,6 +59,43 @@ public static void BreakOnDebuggerBreakCommand()
}
}

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string Summary { get; set; }
}

public class InspectTask
{
public static async System.Threading.Tasks.Task RunInspectTask()
{
WeatherForecast[] forecasts = null;
var httpClient = new System.Net.Http.HttpClient();
var getJsonTask = httpClient.GetFromJsonAsync<WeatherForecast[]>("http://localhost:9400/weather.json");
try
{
await getJsonTask.ContinueWith(t =>
{
if (t.IsCompletedSuccessfully)
forecasts = t.Result;
if (t.IsFaulted)
throw t.Exception!;
});
}
catch (Exception ex)
{
Console.WriteLine($"error {ex}");
return;
}
}
}

public class TestParent2
{
public int k = 30;
Expand Down
32 changes: 32 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/weather.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"dateFormatted": "06/05/2018",
"temperatureC": 1,
"summary": "Freezing",
"temperatureF": 33
},
{
"dateFormatted": "07/05/2018",
"temperatureC": 14,
"summary": "Bracing",
"temperatureF": 57
},
{
"dateFormatted": "08/05/2018",
"temperatureC": -13,
"summary": "Freezing",
"temperatureF": 9
},
{
"dateFormatted": "09/05/2018",
"temperatureC": -16,
"summary": "Balmy",
"temperatureF": 4
},
{
"dateFormatted": "10/05/2018",
"temperatureC": -2,
"summary": "Chilly",
"temperatureF": 29
}
]

0 comments on commit 52d216e

Please sign in to comment.