[wasm] [debugger] Skip thread static field (#56749)
authorThays Grazia <thaystg@gmail.com>
Tue, 3 Aug 2021 21:00:24 +0000 (18:00 -0300)
committerGitHub <noreply@github.com>
Tue, 3 Aug 2021 21:00:24 +0000 (16:00 -0500)
* Fix #56249

* Fix line test.

* Fix indentation.

* Addressing PR comments.

* Fix line number changed

src/mono/mono/component/debugger-agent.c
src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs
src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs
src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj
src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs
src/mono/wasm/debugger/tests/debugger-test/weather.json [new file with mode: 0644]

index d5c8a34..2b6842c 100644 (file)
@@ -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);
index 2cb7841..9b4b51c 100644 (file)
@@ -981,6 +981,9 @@ namespace Microsoft.WebAssembly.Diagnostics
                 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", "");
index 7bfc088..ed5d59e 100644 (file)
@@ -259,7 +259,7 @@ namespace DebuggerTests
         {
             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");
         }
 
index 6b4dcd6..51064a7 100644 (file)
@@ -340,7 +340,7 @@ namespace DebuggerTests
         {
             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);
index 35bc79f..b09e32a 100644 (file)
@@ -91,7 +91,7 @@ namespace DebuggerTests
         [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) =>
@@ -826,6 +826,25 @@ namespace DebuggerTests
             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
     }
 }
index 797fa16..0503fea 100644 (file)
@@ -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"/>
index d360819..2a5d525 100644 (file)
@@ -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)
@@ -57,6 +59,43 @@ public class UserBreak {
     }
 }
 
+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;
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 (file)
index 0000000..e1ca33d
--- /dev/null
@@ -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
+  }
+]