From e5340ad4524d43d0bd6437fabfed39952a5bde69 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 2 Aug 2021 17:52:20 -0300 Subject: [PATCH 1/5] Fix #56249 --- src/mono/mono/component/debugger-agent.c | 2 + .../BrowserDebugProxy/MonoSDBHelper.cs | 3 ++ .../DebuggerTestSuite/BreakpointTests.cs | 2 +- .../wasm/debugger/DebuggerTestSuite/Tests.cs | 20 +++++++++- .../tests/debugger-test/debugger-test.csproj | 1 + .../tests/debugger-test/debugger-test2.cs | 39 +++++++++++++++++++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index fbe89da9bda49..91de21bee9b78 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -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); diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs index 77b3695ff7d30..bbb7eb88e7f47 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs @@ -945,6 +945,9 @@ public async Task> 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", ""); diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index 7bfc088150682..ed5d59e7ef572 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -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"); } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs index 35bc79fcb0a27..82c1b563cd217 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs @@ -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", 49, 8, "Types", "window.setTimeout(function() { invoke_static_method (\"[debugger-test] Fancy:Types\")(); }, 1);", use_cfo: false, test_fn: (locals) => @@ -826,6 +826,24 @@ public async Task GetSourceUsingSourceLink() Assert.True(source.IsOk); } + [Fact] + public async Task InspectTaskAtLocals() => await CheckInspectLocalsAtBreakpointSite( + "InspectTask", + "RunInspectTask", + 7, + "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()); + + var t_arr = await GetObjectOnLocals(locals, "t"); + await CheckProps(t_arr, new + { + s_taskIdCounter = TNumber(0) + }, "t_arr", num_fields: 53); + }); + //TODO add tests covering basic stepping behavior as step in/out/over } } 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 797fa16751648..0503feaaff07e 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj @@ -11,6 +11,7 @@ + diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs index b9d97c8e23484..157109c74580c 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs @@ -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) @@ -56,3 +58,40 @@ public static void BreakOnDebuggerBreakCommand() Debugger.Break(); } } + +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("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; + } + } +} From 904ab39b8e82f7e79e1a8d5b307fb99045c73ef0 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 2 Aug 2021 18:02:50 -0300 Subject: [PATCH 2/5] Fix line test. --- src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs index 82c1b563cd217..3068101ee269d 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs @@ -91,7 +91,7 @@ public async Task ExceptionThrownInJSOutOfBand() [Fact] public async Task InspectLocalsTypesAtBreakpointSite() => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test2.cs", 49, 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) => From d2e727e1bb4d8923ce97652245ebab352e550030 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 2 Aug 2021 20:05:27 -0300 Subject: [PATCH 3/5] Fix indentation. --- src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs index 3068101ee269d..8a54265ef3afc 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs @@ -838,7 +838,7 @@ public async Task GetSourceUsingSourceLink() var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); var t_arr = await GetObjectOnLocals(locals, "t"); - await CheckProps(t_arr, new + await CheckProps(t_arr, new { s_taskIdCounter = TNumber(0) }, "t_arr", num_fields: 53); From 3de9286e32ec7ec29634c573c684097fcd3f2b72 Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 3 Aug 2021 10:20:37 -0300 Subject: [PATCH 4/5] Addressing PR comments. --- .../wasm/debugger/DebuggerTestSuite/Tests.cs | 9 +++--- .../debugger/tests/debugger-test/weather.json | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/mono/wasm/debugger/tests/debugger-test/weather.json diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs index 8a54265ef3afc..b09e32a28765e 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs @@ -837,11 +837,12 @@ public async Task GetSourceUsingSourceLink() { var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var t_arr = await GetObjectOnLocals(locals, "t"); - await CheckProps(t_arr, new + var t_props = await GetObjectOnLocals(locals, "t"); + await CheckProps(t_props, new { - s_taskIdCounter = TNumber(0) - }, "t_arr", num_fields: 53); + s_taskIdCounter = TNumber(0), + Status = TGetter("Status") + }, "t_props", num_fields: 53); }); //TODO add tests covering basic stepping behavior as step in/out/over diff --git a/src/mono/wasm/debugger/tests/debugger-test/weather.json b/src/mono/wasm/debugger/tests/debugger-test/weather.json new file mode 100644 index 0000000000000..e1ca33d0beb84 --- /dev/null +++ b/src/mono/wasm/debugger/tests/debugger-test/weather.json @@ -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 + } +] From 31ef2b3384751231fd0cb7c3845ec7c65eaf19cd Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 3 Aug 2021 14:27:29 -0300 Subject: [PATCH 5/5] Fix line number changed --- src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs index 6b4dcd65900be..51064a7bf3ff6 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs @@ -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(); var frame_locals = await GetProperties(frame_id);