diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DevToolsProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DevToolsProxy.cs index 119705b60fc13b..7e8fe78eebd98b 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DevToolsProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DevToolsProxy.cs @@ -268,7 +268,7 @@ public async Task Run(Uri browserUri, WebSocket ideSocket) { while (!x.IsCancellationRequested) { - Task task = await Task.WhenAny(pending_ops.ToArray()); + Task completedTask = await Task.WhenAny(pending_ops.ToArray()); if (client_initiated_close.Task.IsCompleted) { @@ -280,34 +280,34 @@ public async Task Run(Uri browserUri, WebSocket ideSocket) } //logger.LogTrace ("pump {0} {1}", task, pending_ops.IndexOf (task)); - if (task == pending_ops[0]) + if (completedTask == pending_ops[0]) { - string msg = ((Task)task).Result; + string msg = ((Task)completedTask).Result; if (msg != null) { pending_ops[0] = ReadOne(browser, x.Token); //queue next read ProcessBrowserMessage(msg, x.Token); } } - else if (task == pending_ops[1]) + else if (completedTask == pending_ops[1]) { - string msg = ((Task)task).Result; + string msg = ((Task)completedTask).Result; if (msg != null) { pending_ops[1] = ReadOne(ide, x.Token); //queue next read ProcessIdeMessage(msg, x.Token); } } - else if (task == pending_ops[2]) + else if (completedTask == pending_ops[2]) { - bool res = ((Task)task).Result; + bool res = ((Task)completedTask).Result; throw new Exception("side task must always complete with an exception, what's going on???"); } else { //must be a background task - pending_ops.Remove(task); - DevToolsQueue queue = GetQueueForTask(task); + pending_ops.Remove(completedTask); + DevToolsQueue queue = GetQueueForTask(completedTask); if (queue != null) { if (queue.TryPumpIfCurrentCompleted(x.Token, out Task tsk)) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs index 82057f4c75bd39..a9d17696c4faa9 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs @@ -9,9 +9,6 @@ namespace DebuggerTests { - // https://github.com/dotnet/runtime/issues/62661 - [Trait("Category", "windows-failing")] - [Trait("Category", "linux-failing")] public class ArrayTests : DebuggerTestBase { @@ -234,10 +231,10 @@ async Task TestSimpleArrayLocals(int line, int col, string entry_method_name, st var locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); Assert.Equal(4, locals.Count()); - CheckArray(locals, $"{local_var_name_prefix}_arr", $"{etype_name}[]", $"{etype_name}[{array?.Length ?? 0}]"); - CheckArray(locals, $"{local_var_name_prefix}_arr_empty", $"{etype_name}[]", $"{etype_name}[0]"); - CheckObject(locals, $"{local_var_name_prefix}_arr_null", $"{etype_name}[]", is_null: true); - CheckBool(locals, "call_other", test_prev_frame); + await CheckArray(locals, $"{local_var_name_prefix}_arr", $"{etype_name}[]", $"{etype_name}[{array?.Length ?? 0}]"); + await CheckArray(locals, $"{local_var_name_prefix}_arr_empty", $"{etype_name}[]", $"{etype_name}[0]"); + await CheckObject(locals, $"{local_var_name_prefix}_arr_null", $"{etype_name}[]", is_null: true); + await CheckBool(locals, "call_other", test_prev_frame); var local_arr_name = $"{local_var_name_prefix}_arr"; @@ -308,7 +305,7 @@ public async Task InspectObjectArrayMembers(bool use_cfo) var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, method_name); var locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); Assert.Single(locals); - CheckObject(locals, "c", "DebuggerTests.Container"); + await CheckObject(locals, "c", "DebuggerTests.Container"); var c_props = await GetObjectOnFrame(pause_location["callFrames"][frame_idx], "c"); await CheckProps(c_props, new @@ -554,6 +551,7 @@ await CompareObjectPropertiesFor(frame_locals, "this", label: "this#0"); } +#if false // https://github.com/dotnet/runtime/issues/63560 [Fact] public async Task InvalidArrayId() => await CheckInspectLocalsAtBreakpointSite( "DebuggerTests.Container", "PlaceholderMethod", 1, "PlaceholderMethod", @@ -619,31 +617,40 @@ public async Task InvalidValueTypeArrayIndex() => await CheckInspectLocalsAtBrea id_args["arrayIdx"] = "qwe"; await GetProperties($"dotnet:valuetype:{id_args.ToString(Newtonsoft.Json.Formatting.None)}", expect_ok: false); }); +#endif [Fact] public async Task InvalidAccessors() => await CheckInspectLocalsAtBreakpointSite( "DebuggerTests.Container", "PlaceholderMethod", 1, "PlaceholderMethod", "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ArrayTestsClass:ObjectArrayMembers'); }, 1);", locals_fn: async (locals) => - { - var this_obj = GetAndAssertObjectWithName(locals, "this"); - var c_obj = GetAndAssertObjectWithName(await GetProperties(this_obj["value"]["objectId"].Value()), "c"); - var c_obj_id = c_obj["value"]?["objectId"]?.Value(); - Assert.NotNull(c_obj_id); + { + var this_obj = GetAndAssertObjectWithName(locals, "this"); + var this_obj_id = this_obj["value"]?["objectId"]?.Value(); + Assert.NotNull(this_obj_id); - var c_props = await GetProperties(c_obj_id); + var this_props = await GetProperties(this_obj_id); - var pf_arr = GetAndAssertObjectWithName(c_props, "PointsField"); + var pf_arr = GetAndAssertObjectWithName(this_props, "PointsField"); + + // Validate the way we test the accessors, with a valid one + var res = await InvokeGetter(pf_arr, "0", expect_ok: true); + await CheckValue(res.Value["result"], TValueType("DebuggerTests.Point"), "pf_arr[0]"); + var pf_arr0_props = await GetProperties(res.Value["result"]["objectId"]?.Value()); + await CheckProps(pf_arr0_props, new + { + X = TNumber(5) + }, "pf_arr0_props", num_fields: 4); - var invalid_accessors = new object[] { "NonExistant", "10000", "-2", 10000, -2, null, String.Empty }; - foreach (var invalid_accessor in invalid_accessors) - { - // var res = await InvokeGetter (JObject.FromObject (new { value = new { objectId = obj_id } }), invalid_accessor, expect_ok: true); - var res = await InvokeGetter(pf_arr, invalid_accessor, expect_ok: true); - AssertEqual("undefined", res.Value["result"]?["type"]?.ToString(), "Expected to get undefined result for non-existant accessor"); - } + var invalid_accessors = new object[] { "NonExistant", "10000", "-2", 10000, -2, null, String.Empty }; + foreach (var invalid_accessor in invalid_accessors) + { + // var res = await InvokeGetter (JObject.FromObject (new { value = new { objectId = obj_id } }), invalid_accessor, expect_ok: true); + res = await InvokeGetter(pf_arr, invalid_accessor, expect_ok: true); + AssertEqual("undefined", res.Value["result"]?["type"]?.ToString(), "Expected to get undefined result for non-existant accessor"); + } }); - + [Theory] [InlineData(false)] [InlineData(true)] diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/AssignmentTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/AssignmentTests.cs index 7a5111b3647122..16c61e13ba4224 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/AssignmentTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/AssignmentTests.cs @@ -49,7 +49,7 @@ await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-assignmen locals_fn: async (locals) => { Assert.Equal(2, locals.Count()); - Check(locals, "r", checkDefault); + await Check(locals, "r", checkDefault); await Task.CompletedTask; } ); @@ -59,7 +59,7 @@ await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-assignmen locals_fn: async (locals) => { Assert.Equal(2, locals.Count()); - Check(locals, "r", checkValue); + await Check(locals, "r", checkValue); await Task.CompletedTask; } ); diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index b80a8f429b4827..2c24a924f557eb 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -334,7 +334,7 @@ public async Task DebugHotReloadMethodChangedUserBreak() CheckNumber(locals, "b", 15); pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 12, "StaticMethod1"); locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckBool(locals, "c", true); + await CheckBool(locals, "c", true); } [Fact] @@ -374,7 +374,7 @@ public async Task DebugHotReloadMethodAddBreakpoint() pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 30, 12, "StaticMethod3"); locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckBool(locals, "c", true); + await CheckBool(locals, "c", true); await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 31, 12, "StaticMethod3", locals_fn: async (locals) => diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/CallFunctionOnTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/CallFunctionOnTests.cs index 92e36a3bdca1e2..3e7d482b9ac290 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/CallFunctionOnTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/CallFunctionOnTests.cs @@ -260,7 +260,7 @@ public async Task RunOnVTArray(bool roundtrip) => await RunCallFunctionOn( for (int i = 0; i < ret_len; i++) { - var act_i = CheckValueType(obj_own_val, i.ToString(), "Math.SimpleStruct"); + var act_i = await CheckValueType(obj_own_val, i.ToString(), "Math.SimpleStruct"); // Valuetypes can get sent as part of the container's getProperties, so ensure that we can access it var act_i_props = await GetProperties(act_i["value"]["objectId"]?.Value()); diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/CustomViewTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/CustomViewTests.cs index 06516155b7d399..e3ec38820cd64e 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/CustomViewTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/CustomViewTests.cs @@ -27,11 +27,11 @@ public async Task UsingDebuggerDisplay() "run"); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckObject(locals, "a", "DebuggerTests.WithDisplayString", description:"Some one Value 2 End"); - CheckObject(locals, "c", "DebuggerTests.DebuggerDisplayMethodTest", description: "First Int:32 Second Int:43"); - CheckObject(locals, "myList", "System.Collections.Generic.List", description: "Count = 4"); - CheckObject(locals, "person1", "DebuggerTests.Person", description: "FirstName: Anton, SurName: Mueller, Age: 44"); - CheckObject(locals, "person2", "DebuggerTests.Person", description: "FirstName: Lisa, SurName: Müller, Age: 41"); + await CheckObject(locals, "a", "DebuggerTests.WithDisplayString", description:"Some one Value 2 End"); + await CheckObject(locals, "c", "DebuggerTests.DebuggerDisplayMethodTest", description: "First Int:32 Second Int:43"); + await CheckObject(locals, "myList", "System.Collections.Generic.List", description: "Count = 4"); + await CheckObject(locals, "person1", "DebuggerTests.Person", description: "FirstName: Anton, SurName: Mueller, Age: 44"); + await CheckObject(locals, "person2", "DebuggerTests.Person", description: "FirstName: Lisa, SurName: Müller, Age: 41"); } [Fact] @@ -47,17 +47,17 @@ public async Task UsingDebuggerTypeProxy() var frame = pause_location["callFrames"][0]; var locals = await GetProperties(frame["callFrameId"].Value()); - CheckObject(locals, "myList", "System.Collections.Generic.List", description: "Count = 4"); + await CheckObject(locals, "myList", "System.Collections.Generic.List", description: "Count = 4"); var props = await GetObjectOnFrame(frame, "myList"); Assert.Equal(1, props.Count()); - CheckArray(props, "Items", "int[]", "int[4]"); + await CheckArray(props, "Items", "int[]", "int[4]"); - CheckObject(locals, "b", "DebuggerTests.WithProxy", description:"DebuggerTests.WithProxy"); + await CheckObject(locals, "b", "DebuggerTests.WithProxy", description:"DebuggerTests.WithProxy"); props = await GetObjectOnFrame(frame, "b"); - CheckString(props, "Val2", "one"); + await CheckString(props, "Val2", "one"); - CheckObject(locals, "openWith", "System.Collections.Generic.Dictionary", description: "Count = 3"); + await CheckObject(locals, "openWith", "System.Collections.Generic.Dictionary", description: "Count = 3"); props = await GetObjectOnFrame(frame, "openWith"); Assert.Equal(1, props.Count()); @@ -95,8 +95,10 @@ async Task CheckProperties(JObject pause_location) var task = CheckProperties(pause_location); tasks.Add(task); } + await Task.WhenAll(tasks); foreach(Task task in tasks) { + //FIXME: blocks Assert.True(task.Result); } } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs index d6fcc282f09cd6..5660e8c55011b3 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs @@ -205,7 +205,7 @@ await EvaluateAndCheck( // sets breakpoint by method name and line offset internal async Task CheckInspectLocalsAtBreakpointSite(string type, string method, int line_offset, string bp_function_name, string eval_expression, - Action locals_fn = null, Func wait_for_event_fn = null, bool use_cfo = false, string assembly = "debugger-test.dll", int col = 0) + Func locals_fn = null, Func wait_for_event_fn = null, bool use_cfo = false, string assembly = "debugger-test.dll", int col = 0) { UseCallFunctionOnBeforeGetProperties = use_cfo; @@ -236,7 +236,7 @@ internal async Task CheckInspectLocalsAtBreakpointSite(string type, string metho if (locals_fn != null) { var locals = await GetProperties(pause_location?["callFrames"]?[0]?["callFrameId"]?.Value()); - locals_fn(locals); + await locals_fn(locals); } } @@ -279,31 +279,31 @@ internal void CheckNumberAsString(JToken locals, string name, string value) Assert.True(false, $"Could not find variable '{name}'"); } - internal void CheckString(JToken locals, string name, string value) + internal async Task CheckString(JToken locals, string name, string value) { var l = GetAndAssertObjectWithName(locals, name); - CheckValue(l["value"], TString(value), name).Wait(); + await CheckValue(l["value"], TString(value), name); } - internal JToken CheckSymbol(JToken locals, string name, string value) + internal async Task CheckSymbol(JToken locals, string name, string value) { var l = GetAndAssertObjectWithName(locals, name); - CheckValue(l["value"], TSymbol(value), name).Wait(); + await CheckValue(l["value"], TSymbol(value), name); return l; } - internal JToken Check(JToken locals, string name, JObject expected) + internal async Task Check(JToken locals, string name, JObject expected) { var l = GetAndAssertObjectWithName(locals, name); - CheckValue(l["value"], expected, name).Wait(); + await CheckValue(l["value"], expected, name); return l; } - internal JToken CheckObject(JToken locals, string name, string class_name, string subtype = null, bool is_null = false, string description = null) + internal async Task CheckObject(JToken locals, string name, string class_name, string subtype = null, bool is_null = false, string description = null) { var l = GetAndAssertObjectWithName(locals, name); var val = l["value"]; - CheckValue(val, TObject(class_name, is_null: is_null, description: description), name).Wait(); + await CheckValue(val, TObject(class_name, is_null: is_null, description: description), name); Assert.True(val["isValueType"] == null || !val["isValueType"].Value()); return l; @@ -354,10 +354,10 @@ async Task CheckDateTimeMembers(JToken v, DateTime exp_dt, string label = "") } } - internal JToken CheckBool(JToken locals, string name, bool expected) + internal async Task CheckBool(JToken locals, string name, bool expected) { var l = GetAndAssertObjectWithName(locals, name); - CheckValue(l["value"], TBool(expected), name).Wait(); + await CheckValue(l["value"], TBool(expected), name); return l; } @@ -367,24 +367,24 @@ internal void CheckContentValue(JToken token, string value) Assert.Equal(value, val); } - internal JToken CheckValueType(JToken locals, string name, string class_name, string description=null) + internal async Task CheckValueType(JToken locals, string name, string class_name, string description=null) { var l = GetAndAssertObjectWithName(locals, name); - CheckValue(l["value"], TValueType(class_name, description: description), name).Wait(); + await CheckValue(l["value"], TValueType(class_name, description: description), name); return l; } - internal JToken CheckEnum(JToken locals, string name, string class_name, string descr) + internal async Task CheckEnum(JToken locals, string name, string class_name, string descr) { var l = GetAndAssertObjectWithName(locals, name); - CheckValue(l["value"], TEnum(class_name, descr), name).Wait(); + await CheckValue(l["value"], TEnum(class_name, descr), name); return l; } - internal void CheckArray(JToken locals, string name, string class_name, string description) - => CheckValue( - GetAndAssertObjectWithName(locals, name)["value"], - TArray(class_name, description), name).Wait(); + internal async Task CheckArray(JToken locals, string name, string class_name, string description) + => await CheckValue( + GetAndAssertObjectWithName(locals, name)["value"], + TArray(class_name, description), name); internal JToken GetAndAssertObjectWithName(JToken obj, string name, string label = "") { @@ -902,7 +902,7 @@ internal async Task GetProperties(string id, JToken fn_args = null, bool var locals = frame_props.Value["result"]; var locals_internal = frame_props.Value["internalProperties"]; var locals_private = frame_props.Value["privateProperties"]; - + // FIXME: Should be done when generating the list in dotnet.cjs.lib.js, but not sure yet // whether to remove it, and how to do it correctly. if (locals is JArray) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs index e1ed977ae52e96..46e3acc16dd941 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs @@ -41,7 +41,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception0.data"); var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "message", "not implemented caught"); + await CheckString(exception_members, "message", "not implemented caught"); pause_location = await WaitForManagedException(null); AssertEqual("run", pause_location["callFrames"]?[0]?["functionName"]?.Value(), "pause1"); @@ -58,7 +58,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception1.data"); exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "message", "not implemented uncaught"); + await CheckString(exception_members, "message", "not implemented uncaught"); } [Fact] @@ -79,7 +79,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception0.data"); var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "message", "exception caught"); + await CheckString(exception_members, "message", "exception caught"); pause_location = await SendCommandAndCheck(null, "Debugger.resume", null, 0, 0, "exception_uncaught_test"); @@ -93,7 +93,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception1.data"); exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "message", "exception uncaught"); + await CheckString(exception_members, "message", "exception uncaught"); } // FIXME? BUG? We seem to get the stack trace for Runtime.exceptionThrown at `call_method`, @@ -189,7 +189,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception.data"); var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "message", exception_message); + await CheckString(exception_members, "message", exception_message); } [Fact] @@ -229,7 +229,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception1.data"); var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "message", "not implemented uncaught"); + await CheckString(exception_members, "message", "not implemented uncaught"); } [Theory] @@ -278,7 +278,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception0.data"); var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "_message", "not implemented caught"); + await CheckString(exception_members, "_message", "not implemented caught"); pause_location = await WaitForManagedException(null); AssertEqual("run", pause_location["callFrames"]?[0]?["functionName"]?.Value(), "pause1"); @@ -296,7 +296,7 @@ await CheckValue(pause_location["data"], JObject.FromObject(new }), "exception1.data"); exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - CheckString(exception_members, "_message", "not implemented uncaught"); + await CheckString(exception_members, "_message", "not implemented uncaught"); } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/Inspector.cs b/src/mono/wasm/debugger/DebuggerTestSuite/Inspector.cs index 616349e3385317..c70f42f5d8449f 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/Inspector.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/Inspector.cs @@ -221,12 +221,12 @@ public async Task OpenSessionAsync(Func 0) { var cmd_tasks = init_cmds.Select(ct => ct.Item2); - Task t = await Task.WhenAny(cmd_tasks); + Task completedTask = await Task.WhenAny(cmd_tasks); - int cmdIdx = init_cmds.FindIndex(ct => ct.Item2 == t); + int cmdIdx = init_cmds.FindIndex(ct => ct.Item2 == completedTask); string cmd_name = init_cmds[cmdIdx].Item1; - if (t.IsCanceled) + if (completedTask.IsCanceled) { throw new TaskCanceledException( $"Command {cmd_name} timed out during init for the test." + @@ -234,13 +234,13 @@ public async Task OpenSessionAsync(Func { - CheckSymbol(locals, "c0", "8364 '€'"); - CheckSymbol(locals, "c1", "65 'A'"); + await CheckSymbol(locals, "c0", "8364 '€'"); + await CheckSymbol(locals, "c1", "65 'A'"); await Task.CompletedTask; } ); @@ -203,18 +203,18 @@ await CheckInspectLocalsAtBreakpointSite( use_cfo: use_cfo, test_fn: async (locals) => { - CheckObject(locals, "list", "System.Collections.Generic.Dictionary", description: "Count = 0"); - CheckObject(locals, "list_null", "System.Collections.Generic.Dictionary", is_null: true); + await CheckObject(locals, "list", "System.Collections.Generic.Dictionary", description: "Count = 0"); + await CheckObject(locals, "list_null", "System.Collections.Generic.Dictionary", is_null: true); - CheckArray(locals, "list_arr", "System.Collections.Generic.Dictionary[]", "System.Collections.Generic.Dictionary[1]"); - CheckObject(locals, "list_arr_null", "System.Collections.Generic.Dictionary[]", is_null: true); + await CheckArray(locals, "list_arr", "System.Collections.Generic.Dictionary[]", "System.Collections.Generic.Dictionary[1]"); + await CheckObject(locals, "list_arr_null", "System.Collections.Generic.Dictionary[]", is_null: true); // Unused locals - CheckObject(locals, "list_unused", "System.Collections.Generic.Dictionary", description: "Count = 0"); - CheckObject(locals, "list_null_unused", "System.Collections.Generic.Dictionary", is_null: true); + await CheckObject(locals, "list_unused", "System.Collections.Generic.Dictionary", description: "Count = 0"); + await CheckObject(locals, "list_null_unused", "System.Collections.Generic.Dictionary", is_null: true); - CheckArray(locals, "list_arr_unused", "System.Collections.Generic.Dictionary[]", "System.Collections.Generic.Dictionary[1]"); - CheckObject(locals, "list_arr_null_unused", "System.Collections.Generic.Dictionary[]", is_null: true); + await CheckArray(locals, "list_arr_unused", "System.Collections.Generic.Dictionary[]", "System.Collections.Generic.Dictionary[1]"); + await CheckObject(locals, "list_arr_null_unused", "System.Collections.Generic.Dictionary[]", is_null: true); await Task.CompletedTask; } ); @@ -275,11 +275,11 @@ public async Task InspectLocalsWithStructs(bool use_cfo) var vt_local_props = await GetObjectOnFrame(pause_location["callFrames"][0], "vt_local"); Assert.Equal(5, vt_local_props.Count()); - CheckString(vt_local_props, "StringField", "string#0"); - CheckValueType(vt_local_props, "SimpleStructField", "DebuggerTests.ValueTypesTest.SimpleStruct"); - CheckValueType(vt_local_props, "SimpleStructProperty", "DebuggerTests.ValueTypesTest.SimpleStruct"); + await CheckString(vt_local_props, "StringField", "string#0"); + await CheckValueType(vt_local_props, "SimpleStructField", "DebuggerTests.ValueTypesTest.SimpleStruct"); + await CheckValueType(vt_local_props, "SimpleStructProperty", "DebuggerTests.ValueTypesTest.SimpleStruct"); await CheckDateTime(vt_local_props, "DT", new DateTime(2020, 1, 2, 3, 4, 5)); - CheckEnum(vt_local_props, "RGB", "DebuggerTests.RGB", "Blue"); + await CheckEnum(vt_local_props, "RGB", "DebuggerTests.RGB", "Blue"); // Check ss_local's properties var ss_local_props = await GetObjectOnFrame(pause_location["callFrames"][0], "ss_local"); @@ -298,8 +298,8 @@ public async Task InspectLocalsWithStructs(bool use_cfo) // Check ss_local.gs var gs_props = await GetObjectOnLocals(ss_local_props, "gs"); - CheckString(gs_props, "StringField", "set in MethodWithLocalStructs#SimpleStruct#gs#StringField"); - CheckObject(gs_props, "List", "System.Collections.Generic.List", description: "Count = 1"); + await CheckString(gs_props, "StringField", "set in MethodWithLocalStructs#SimpleStruct#gs#StringField"); + await CheckObject(gs_props, "List", "System.Collections.Generic.List", description: "Count = 1"); } // Check gs_local's properties diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/SetVariableValueTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/SetVariableValueTests.cs index df0970f5ebf05b..6ff6966b77b5f4 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/SetVariableValueTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/SetVariableValueTests.cs @@ -261,8 +261,7 @@ public async Task SetLocalBoolTypeVariable(int offset, string variableName, bool "dotnet://debugger-test.dll/debugger-test.cs", 8+offset, 8, "IntAdd", locals_fn: async (locals) => { - CheckBool(locals, variableName, originalValue); - await Task.CompletedTask; + await CheckBool(locals, variableName, originalValue); } ); var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); @@ -272,8 +271,7 @@ public async Task SetLocalBoolTypeVariable(int offset, string variableName, bool await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 9+offset, 4, "IntAdd", locals_fn: async (locals) => { - CheckBool(locals, variableName, newValue); - await Task.CompletedTask; + await CheckBool(locals, variableName, newValue); } ); } @@ -300,7 +298,7 @@ public async Task TestSetValueOnObject(string prop_name, int prop_value, string var obj = GetAndAssertObjectWithName(locals, "complex"); Assert.Equal(4, props.Count()); CheckNumber(props, prop_name, prop_value); - CheckString(props, "B", "xx"); + await CheckString(props, "B", "xx"); await SetValueOnObject(obj, prop_name, prop_new_value, expect_ok: expect_ok); @@ -316,7 +314,7 @@ public async Task TestSetValueOnObject(string prop_name, int prop_value, string locals = await GetProperties(frame["callFrameId"].Value()); Assert.Equal(4, props.Count()); CheckNumber(props, prop_name, expect_ok ? Int32.Parse(prop_new_value) : prop_value); - CheckString(props, "B", "xx"); + await CheckString(props, "B", "xx"); } } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs index 4a54cac6e8c6aa..3feb6695eed152 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs @@ -106,16 +106,15 @@ public async Task InspectLocalsInPreviousFramesDuringSteppingIn2(bool use_cfo) locals_fn: async (locals) => { Assert.Single(locals); - CheckObject(locals, "this", "Simple.Complex"); - await Task.CompletedTask; + await CheckObject(locals, "this", "Simple.Complex"); } ); var props = await GetObjectOnFrame(pause_location["callFrames"][0], "this"); Assert.Equal(4, props.Count()); CheckNumber(props, "A", 10); - CheckString(props, "B", "xx"); - CheckString(props, "c", "20_xx"); + await CheckString(props, "B", "xx"); + await CheckString(props, "c", "20_xx"); // Check UseComplex frame var locals_m1 = await GetLocalsForFrame(pause_location["callFrames"][3], debugger_test_loc, 23, 8, "UseComplex"); @@ -123,7 +122,7 @@ public async Task InspectLocalsInPreviousFramesDuringSteppingIn2(bool use_cfo) CheckNumber(locals_m1, "a", 10); CheckNumber(locals_m1, "b", 20); - CheckObject(locals_m1, "complex", "Simple.Complex"); + await CheckObject(locals_m1, "complex", "Simple.Complex"); CheckNumber(locals_m1, "c", 30); CheckNumber(locals_m1, "d", 50); CheckNumber(locals_m1, "e", 60); @@ -132,8 +131,8 @@ public async Task InspectLocalsInPreviousFramesDuringSteppingIn2(bool use_cfo) props = await GetObjectOnFrame(pause_location["callFrames"][3], "complex"); Assert.Equal(4, props.Count()); CheckNumber(props, "A", 10); - CheckString(props, "B", "xx"); - CheckString(props, "c", "20_xx"); + await CheckString(props, "B", "xx"); + await CheckString(props, "c", "20_xx"); pause_location = await StepAndCheck(StepKind.Over, dep_cs_loc, 25, 8, "DoStuff", times: 2); // Check UseComplex frame again @@ -142,7 +141,7 @@ public async Task InspectLocalsInPreviousFramesDuringSteppingIn2(bool use_cfo) CheckNumber(locals_m1, "a", 10); CheckNumber(locals_m1, "b", 20); - CheckObject(locals_m1, "complex", "Simple.Complex"); + await CheckObject(locals_m1, "complex", "Simple.Complex"); CheckNumber(locals_m1, "c", 30); CheckNumber(locals_m1, "d", 50); CheckNumber(locals_m1, "e", 60); @@ -151,8 +150,8 @@ public async Task InspectLocalsInPreviousFramesDuringSteppingIn2(bool use_cfo) props = await GetObjectOnFrame(pause_location["callFrames"][1], "complex"); Assert.Equal(4, props.Count()); CheckNumber(props, "A", 10); - CheckString(props, "B", "xx"); - CheckString(props, "c", "20_xx"); + await CheckString(props, "B", "xx"); + await CheckString(props, "c", "20_xx"); } [Theory] @@ -174,16 +173,16 @@ public async Task InspectLocalsInPreviousFramesDuringSteppingIn(bool use_cfo) Assert.Equal(4, locals.Count()); CheckNumber(locals, "i", 5); CheckNumber(locals, "j", 24); - CheckString(locals, "foo_str", "foo"); - CheckObject(locals, "this", "Math.NestedInMath"); + await CheckString(locals, "foo_str", "foo"); + await CheckObject(locals, "this", "Math.NestedInMath"); await Task.CompletedTask; } ); var this_props = await GetObjectOnFrame(wait_res["callFrames"][0], "this"); Assert.Equal(2, this_props.Count()); - CheckObject(this_props, "m", "Math"); - CheckValueType(this_props, "SimpleStructProperty", "Math.SimpleStruct"); + await CheckObject(this_props, "m", "Math"); + await CheckValueType(this_props, "SimpleStructProperty", "Math.SimpleStruct"); var ss_props = await GetObjectOnLocals(this_props, "SimpleStructProperty"); var dt = new DateTime(2020, 1, 2, 3, 4, 5); @@ -200,7 +199,7 @@ public async Task InspectLocalsInPreviousFramesDuringSteppingIn(bool use_cfo) // FIXME: Failing test CheckString (locals_m1, "text", "Hello"); CheckNumber(locals_m1, "new_i", 0); CheckNumber(locals_m1, "k", 0); - CheckObject(locals_m1, "nim", "Math.NestedInMath"); + await CheckObject(locals_m1, "nim", "Math.NestedInMath"); // step back into OuterMethod await StepAndCheck(StepKind.Over, debugger_test_loc, 91, 8, "OuterMethod", times: 6, @@ -209,11 +208,10 @@ await StepAndCheck(StepKind.Over, debugger_test_loc, 91, 8, "OuterMethod", times Assert.Equal(5, locals.Count()); // FIXME: Failing test CheckNumber (locals_m1, "i", 5); - CheckString(locals, "text", "Hello"); + await CheckString(locals, "text", "Hello"); // FIXME: Failing test CheckNumber (locals, "new_i", 24); CheckNumber(locals, "k", 19); - CheckObject(locals, "nim", "Math.NestedInMath"); - await Task.CompletedTask; + await CheckObject(locals, "nim", "Math.NestedInMath"); } ); @@ -225,7 +223,7 @@ await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", { Assert.Equal(3, locals.Count()); - CheckString(locals, "s", "test string"); + await CheckString(locals, "s", "test string"); //out var: CheckNumber (locals, "k", 0); CheckNumber(locals, "i", 24); await Task.CompletedTask; @@ -237,7 +235,7 @@ await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", { Assert.Equal(3, locals.Count()); - CheckString(locals, "s", "test string"); + await CheckString(locals, "s", "test string"); // FIXME: Failing test CheckNumber (locals, "k", 34); CheckNumber(locals, "i", 24); await Task.CompletedTask; @@ -249,12 +247,11 @@ await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", { Assert.Equal(5, locals.Count()); - CheckString(locals, "text", "Hello"); + await CheckString(locals, "text", "Hello"); // FIXME: failing test CheckNumber (locals, "i", 5); CheckNumber(locals, "new_i", 22); CheckNumber(locals, "k", 34); - CheckObject(locals, "nim", "Math.NestedInMath"); - await Task.CompletedTask; + await CheckObject(locals, "nim", "Math.NestedInMath"); } ); } @@ -270,12 +267,11 @@ public async Task InspectLocalsDuringSteppingIn() { Assert.Equal(5, locals.Count()); - CheckObject(locals, "nim", "Math.NestedInMath"); + await CheckObject(locals, "nim", "Math.NestedInMath"); CheckNumber(locals, "i", 5); CheckNumber(locals, "k", 0); CheckNumber(locals, "new_i", 0); - CheckString(locals, "text", null); - await Task.CompletedTask; + await CheckString(locals, "text", null); } ); @@ -284,11 +280,11 @@ await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", { Assert.Equal(5, locals.Count()); - CheckObject(locals, "nim", "Math.NestedInMath"); + await CheckObject(locals, "nim", "Math.NestedInMath"); // FIXME: Failing test CheckNumber (locals, "i", 5); CheckNumber(locals, "k", 0); CheckNumber(locals, "new_i", 0); - CheckString(locals, "text", "Hello"); + await CheckString(locals, "text", "Hello"); await Task.CompletedTask; } ); @@ -302,8 +298,8 @@ await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", CheckNumber(locals, "i", 5); CheckNumber(locals, "j", 15); - CheckString(locals, "foo_str", "foo"); - CheckObject(locals, "this", "Math.NestedInMath"); + await CheckString(locals, "foo_str", "foo"); + await CheckObject(locals, "this", "Math.NestedInMath"); await Task.CompletedTask; } ); @@ -314,12 +310,11 @@ await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", { Assert.Equal(5, locals.Count()); - CheckObject(locals, "nim", "Math.NestedInMath"); + await CheckObject(locals, "nim", "Math.NestedInMath"); // FIXME: Failing test CheckNumber (locals, "i", 5); CheckNumber(locals, "k", 0); CheckNumber(locals, "new_i", 24); - CheckString(locals, "text", "Hello"); - await Task.CompletedTask; + await CheckString(locals, "text", "Hello"); } ); } @@ -342,11 +337,10 @@ public async Task InspectLocalsInAsyncMethods(bool use_cfo) locals_fn: async (locals) => { Assert.Equal(4, locals.Count()); - CheckString(locals, "s", "string from js"); + await CheckString(locals, "s", "string from js"); CheckNumber(locals, "i", 42); - CheckString(locals, "local0", "value0"); - CheckObject(locals, "this", "Math.NestedInMath"); - await Task.CompletedTask; + await CheckString(locals, "local0", "value0"); + await CheckObject(locals, "this", "Math.NestedInMath"); } ); Console.WriteLine(wait_res); @@ -354,7 +348,7 @@ public async Task InspectLocalsInAsyncMethods(bool use_cfo) #if false // Disabled for now, as we don't have proper async traces var locals = await GetProperties(wait_res["callFrames"][2]["callFrameId"].Value()); Assert.Equal(4, locals.Count()); - CheckString(locals, "ls", "string from jstest"); + await CheckString(locals, "ls", "string from jstest").ConfigureAwait(false); CheckNumber(locals, "li", 52); #endif @@ -364,11 +358,11 @@ public async Task InspectLocalsInAsyncMethods(bool use_cfo) locals_fn: async (locals) => { Assert.Equal(4, locals.Count()); - CheckString(locals, "str", "AsyncMethodNoReturn's local"); - CheckObject(locals, "this", "Math.NestedInMath"); + await CheckString(locals, "str", "AsyncMethodNoReturn's local"); + await CheckObject(locals, "this", "Math.NestedInMath"); //FIXME: check fields - CheckValueType(locals, "ss", "Math.SimpleStruct"); - CheckArray(locals, "ss_arr", "Math.SimpleStruct[]", "Math.SimpleStruct[0]"); + await CheckValueType(locals, "ss", "Math.SimpleStruct"); + await CheckArray(locals, "ss_arr", "Math.SimpleStruct[]", "Math.SimpleStruct[0]"); // TODO: struct fields await Task.CompletedTask; } @@ -376,8 +370,8 @@ public async Task InspectLocalsInAsyncMethods(bool use_cfo) var this_props = await GetObjectOnFrame(pause_loc["callFrames"][0], "this"); Assert.Equal(2, this_props.Count()); - CheckObject(this_props, "m", "Math"); - CheckValueType(this_props, "SimpleStructProperty", "Math.SimpleStruct"); + await CheckObject(this_props, "m", "Math"); + await CheckValueType(this_props, "SimpleStructProperty", "Math.SimpleStruct"); // TODO: Check `this` properties } @@ -398,8 +392,8 @@ public async Task InspectValueTypeMethodArgsWhileStepping(bool use_cfo) var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); { Assert.Equal(3, locals.Count()); - CheckString(locals, "label", "TestStructsAsMethodArgs#label"); - CheckValueType(locals, "ss_arg", "DebuggerTests.ValueTypesTest.SimpleStruct"); + await CheckString(locals, "label", "TestStructsAsMethodArgs#label"); + await CheckValueType(locals, "ss_arg", "DebuggerTests.ValueTypesTest.SimpleStruct"); CheckNumber(locals, "x", 3); } @@ -437,8 +431,8 @@ public async Task InspectValueTypeMethodArgsWhileStepping(bool use_cfo) { Assert.Equal(3, locals.Count()); - CheckString(locals, "label", "TestStructsAsMethodArgs#label"); - CheckValueType(locals, "ss_arg", "DebuggerTests.ValueTypesTest.SimpleStruct"); + await CheckString(locals, "label", "TestStructsAsMethodArgs#label"); + await CheckValueType(locals, "ss_arg", "DebuggerTests.ValueTypesTest.SimpleStruct"); CheckNumber(locals, "x", 3); } @@ -477,8 +471,8 @@ public async Task InspectValueTypeMethodArgsWhileStepping(bool use_cfo) // Check ss_local.gs var gs_props = await GetObjectOnLocals(ss_arg_props, "gs"); - CheckString(gs_props, "StringField", "ss_local#SimpleStruct#string#0#SimpleStruct#gs#StringField"); - CheckObject(gs_props, "List", "System.Collections.Generic.List", description: "Count = 1"); + await CheckString(gs_props, "StringField", "ss_local#SimpleStruct#string#0#SimpleStruct#gs#StringField"); + await CheckObject(gs_props, "List", "System.Collections.Generic.List", description: "Count = 1"); } // ----------- Step back to the caller --------- diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs index 3ed1f339bfb8ec..98b9cb00dc4015 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -794,7 +794,7 @@ public static void MethodToStep() public class MyIncrementer { - private Func todayFunc = () => DateTime.Now; + private Func todayFunc = () => new DateTime(2061, 1, 5); // Wednesday public int Increment(int count) {