Skip to content

Commit 52d216e

Browse files
authored
[wasm] [debugger] Skip thread static field (#56749)
* Fix #56249 * Fix line test. * Fix indentation. * Addressing PR comments. * Fix line number changed
1 parent 90edb16 commit 52d216e

File tree

8 files changed

+99
-3
lines changed

8 files changed

+99
-3
lines changed

src/mono/mono/component/debugger-agent.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8025,6 +8025,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
80258025
buffer_add_string (buf, f->name);
80268026
buffer_add_typeid (buf, domain, mono_class_from_mono_type_internal (f->type));
80278027
buffer_add_int (buf, f->type->attrs);
8028+
if (CHECK_PROTOCOL_VERSION(2, 61))
8029+
buffer_add_int(buf, mono_class_field_is_special_static(f));
80288030
i ++;
80298031
}
80308032
g_assert (i == nfields);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,9 @@ public async Task<List<FieldTypeClass>> GetTypeFields(SessionId sessionId, int t
981981
string fieldNameStr = retDebuggerCmdReader.ReadString();
982982
int typeId = retDebuggerCmdReader.ReadInt32(); //typeId
983983
retDebuggerCmdReader.ReadInt32(); //attrs
984+
int isSpecialStatic = retDebuggerCmdReader.ReadInt32(); //is_special_static
985+
if (isSpecialStatic == 1)
986+
continue;
984987
if (fieldNameStr.Contains("k__BackingField"))
985988
{
986989
fieldNameStr = fieldNameStr.Replace("k__BackingField", "");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public async Task BreakOnDebuggerBreak()
259259
{
260260
await EvaluateAndCheck(
261261
"window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);",
262-
"dotnet://debugger-test.dll/debugger-test2.cs", 56, 4,
262+
"dotnet://debugger-test.dll/debugger-test2.cs", 58, 4,
263263
"BreakOnDebuggerBreakCommand");
264264
}
265265

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public async Task GetObjectValueWithInheritance()
340340
{
341341
var pause_location = await EvaluateAndCheck(
342342
"window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);",
343-
"dotnet://debugger-test.dll/debugger-test2.cs", 83, 4,
343+
"dotnet://debugger-test.dll/debugger-test2.cs", 122, 4,
344344
"TestWatchWithInheritance");
345345
var frame_id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
346346
var frame_locals = await GetProperties(frame_id);

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ await CheckInspectLocalsAtBreakpointSite(
9191
[Fact]
9292
public async Task InspectLocalsTypesAtBreakpointSite() =>
9393
await CheckInspectLocalsAtBreakpointSite(
94-
"dotnet://debugger-test.dll/debugger-test2.cs", 48, 8, "Types",
94+
"dotnet://debugger-test.dll/debugger-test2.cs", 50, 8, "Types",
9595
"window.setTimeout(function() { invoke_static_method (\"[debugger-test] Fancy:Types\")(); }, 1);",
9696
use_cfo: false,
9797
test_fn: (locals) =>
@@ -826,6 +826,25 @@ public async Task GetSourceUsingSourceLink()
826826
Assert.True(source.IsOk);
827827
}
828828

829+
[Fact]
830+
public async Task InspectTaskAtLocals() => await CheckInspectLocalsAtBreakpointSite(
831+
"InspectTask",
832+
"RunInspectTask",
833+
7,
834+
"<RunInspectTask>b__0" ,
835+
$"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] InspectTask:RunInspectTask'); }}, 1);",
836+
wait_for_event_fn: async (pause_location) =>
837+
{
838+
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
839+
840+
var t_props = await GetObjectOnLocals(locals, "t");
841+
await CheckProps(t_props, new
842+
{
843+
s_taskIdCounter = TNumber(0),
844+
Status = TGetter("Status")
845+
}, "t_props", num_fields: 53);
846+
});
847+
829848
//TODO add tests covering basic stepping behavior as step in/out/over
830849
}
831850
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<WasmExtraFilesToDeploy Include="debugger-driver.html" />
1212
<WasmExtraFilesToDeploy Include="other.js" />
1313
<WasmExtraFilesToDeploy Include="runtime-debugger.js" />
14+
<WasmExtraFilesToDeploy Include="weather.json" />
1415

1516
<!-- We want to bundle these assemblies, so build them first -->
1617
<ProjectReference Include="..\lazy-debugger-test\lazy-debugger-test.csproj" Private="true"/>

src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
using System;
55
using System.Diagnostics;
6+
using System.Net.Http.Json;
7+
68
public class Misc
79
{ //Only append content to this class as the test suite depends on line info
810
public static int CreateObject(int foo, int bar)
@@ -57,6 +59,43 @@ public static void BreakOnDebuggerBreakCommand()
5759
}
5860
}
5961

62+
public class WeatherForecast
63+
{
64+
public DateTime Date { get; set; }
65+
66+
public int TemperatureC { get; set; }
67+
68+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
69+
70+
public string Summary { get; set; }
71+
}
72+
73+
public class InspectTask
74+
{
75+
public static async System.Threading.Tasks.Task RunInspectTask()
76+
{
77+
WeatherForecast[] forecasts = null;
78+
var httpClient = new System.Net.Http.HttpClient();
79+
var getJsonTask = httpClient.GetFromJsonAsync<WeatherForecast[]>("http://localhost:9400/weather.json");
80+
try
81+
{
82+
await getJsonTask.ContinueWith(t =>
83+
{
84+
if (t.IsCompletedSuccessfully)
85+
forecasts = t.Result;
86+
87+
if (t.IsFaulted)
88+
throw t.Exception!;
89+
});
90+
}
91+
catch (Exception ex)
92+
{
93+
Console.WriteLine($"error {ex}");
94+
return;
95+
}
96+
}
97+
}
98+
6099
public class TestParent2
61100
{
62101
public int k = 30;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"dateFormatted": "06/05/2018",
4+
"temperatureC": 1,
5+
"summary": "Freezing",
6+
"temperatureF": 33
7+
},
8+
{
9+
"dateFormatted": "07/05/2018",
10+
"temperatureC": 14,
11+
"summary": "Bracing",
12+
"temperatureF": 57
13+
},
14+
{
15+
"dateFormatted": "08/05/2018",
16+
"temperatureC": -13,
17+
"summary": "Freezing",
18+
"temperatureF": 9
19+
},
20+
{
21+
"dateFormatted": "09/05/2018",
22+
"temperatureC": -16,
23+
"summary": "Balmy",
24+
"temperatureF": 4
25+
},
26+
{
27+
"dateFormatted": "10/05/2018",
28+
"temperatureC": -2,
29+
"summary": "Chilly",
30+
"temperatureF": 29
31+
}
32+
]

0 commit comments

Comments
 (0)