diff options
Diffstat (limited to 'sdks/wasm')
-rw-r--r-- | sdks/wasm/DebuggerTestSuite/Tests.cs | 133 | ||||
-rw-r--r-- | sdks/wasm/Mono.WebAssembly.DebuggerProxy/DevToolsHelper.cs | 3 | ||||
-rw-r--r-- | sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs | 11 | ||||
-rw-r--r-- | sdks/wasm/debugger-valuetypes-test.cs | 31 | ||||
-rw-r--r-- | sdks/wasm/src/library_mono.js | 15 |
5 files changed, 186 insertions, 7 deletions
diff --git a/sdks/wasm/DebuggerTestSuite/Tests.cs b/sdks/wasm/DebuggerTestSuite/Tests.cs index 74c874566f4..fdd97c017db 100644 --- a/sdks/wasm/DebuggerTestSuite/Tests.cs +++ b/sdks/wasm/DebuggerTestSuite/Tests.cs @@ -1001,6 +1001,139 @@ namespace DebuggerTests }); } + [Fact] + public async Task CheckUpdatedValueTypeFieldsOnResume () + { + var insp = new Inspector (); + //Collect events + var scripts = SubscribeToScripts(insp); + + await Ready(); + await insp.Ready (async (cli, token) => { + ctx = new DebugTestContext (cli, insp, token, scripts); + var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; + + var lines = new [] {186, 189}; + await SetBreakpoint (debugger_test_loc, lines [0], 3); + await SetBreakpoint (debugger_test_loc, lines [1], 3); + + var pause_location = await EvaluateAndCheck ( + "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ValueTypesTest:MethodUpdatingValueTypeMembers'); }, 1);", + debugger_test_loc, lines [0], 3, "MethodUpdatingValueTypeMembers"); + + var dt = new DateTime (1, 2, 3, 4, 5, 6); + await CheckLocals (pause_location, dt); + + // Resume + dt = new DateTime (9, 8, 7, 6, 5, 4); + pause_location = await SendCommandAndCheck (JObject.FromObject (new{}), "Debugger.resume", debugger_test_loc, lines[1], 3, "MethodUpdatingValueTypeMembers"); + await CheckLocals (pause_location, dt); + }); + + async Task CheckLocals (JToken pause_location, DateTime dt) + { + var locals = await GetProperties (pause_location ["callFrames"][0]["callFrameId"].Value<string> ()); + await CheckProps (locals, new { + obj = TObject ("DebuggerTests.ClassForToStringTests"), + vt = TObject ("DebuggerTests.StructForToStringTests") + }, "locals"); + + var obj_props = await GetObjectOnLocals (locals, "obj"); + { + await CheckProps (obj_props, new { + DT = TValueType ("System.DateTime", dt.ToString ()) + }, "locals#obj.DT", num_fields: 5); + + await CheckDateTime (obj_props, "DT", dt); + } + + var vt_props = await GetObjectOnLocals (locals, "obj"); + { + await CheckProps (vt_props, new { + DT = TValueType ("System.DateTime", dt.ToString ()) + }, "locals#obj.DT", num_fields: 5); + + await CheckDateTime (vt_props, "DT", dt); + } + } + } + + [Fact] + public async Task CheckUpdatedValueTypeLocalsOnResumeAsync () + { + var insp = new Inspector (); + //Collect events + var scripts = SubscribeToScripts(insp); + + await Ready(); + await insp.Ready (async (cli, token) => { + ctx = new DebugTestContext (cli, insp, token, scripts); + var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; + + var lines = new [] { 195, 197 }; + await SetBreakpoint (debugger_test_loc, lines [0], 3); + await SetBreakpoint (debugger_test_loc, lines [1], 3); + + var pause_location = await EvaluateAndCheck ( + "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ValueTypesTest:MethodUpdatingValueTypeLocalsAsync'); }, 1);", + debugger_test_loc, lines [0], 3, "MoveNext"); + + var dt = new DateTime (1, 2, 3, 4, 5, 6); + var locals = await GetProperties (pause_location ["callFrames"][0]["callFrameId"].Value<string> ()); + await CheckDateTime (locals, "dt", dt); + + // Resume + dt = new DateTime (9, 8, 7, 6, 5, 4); + pause_location = await SendCommandAndCheck (JObject.FromObject (new{}), "Debugger.resume", debugger_test_loc, lines[1], 3, "MoveNext"); + locals = await GetProperties (pause_location ["callFrames"][0]["callFrameId"].Value<string> ()); + await CheckDateTime (locals, "dt", dt); + }); + } + + [Fact] + public async Task CheckUpdatedVTArrayMembersOnResume () + { + var insp = new Inspector (); + //Collect events + var scripts = SubscribeToScripts(insp); + + await Ready(); + await insp.Ready (async (cli, token) => { + ctx = new DebugTestContext (cli, insp, token, scripts); + var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; + + var lines = new [] { 205, 207 }; + await SetBreakpoint (debugger_test_loc, lines [0], 3); + await SetBreakpoint (debugger_test_loc, lines [1], 3); + + var dt = new DateTime (1, 2, 3, 4, 5, 6); + var pause_location = await EvaluateAndCheck ( + "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ValueTypesTest:MethodUpdatingVTArrayMembers'); }, 1);", + debugger_test_loc, lines [0], 3, "MethodUpdatingVTArrayMembers"); + await CheckArrayElements (pause_location, dt); + + // Resume + dt = new DateTime (9, 8, 7, 6, 5, 4); + pause_location = await SendCommandAndCheck (JObject.FromObject (new{}), "Debugger.resume", debugger_test_loc, lines[1], 3, "MethodUpdatingVTArrayMembers"); + await CheckArrayElements (pause_location, dt); + }); + + async Task CheckArrayElements (JToken pause_location, DateTime dt) + { + var locals = await GetProperties (pause_location ["callFrames"][0]["callFrameId"].Value<string> ()); + await CheckProps (locals, new { + ssta = TArray ("DebuggerTests.StructForToStringTests[]", 1) + }, "locals"); + + var ssta = await GetObjectOnLocals (locals, "ssta"); + var sst0 = await GetObjectOnLocals (ssta, "0"); + await CheckProps (sst0, new { + DT = TValueType ("System.DateTime", dt.ToString ()) + }, "dta [0]", num_fields: 5); + + await CheckDateTime (sst0, "DT", dt); + } + } [Theory] [InlineData (false)] [InlineData (true)] diff --git a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/DevToolsHelper.cs b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/DevToolsHelper.cs index 4a360911db2..08cebf1b1b7 100644 --- a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/DevToolsHelper.cs +++ b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/DevToolsHelper.cs @@ -204,6 +204,9 @@ namespace WebAssembly.Net.Debugging { public static MonoCommands CallFunctionOn (JToken args) => new MonoCommands ($"MONO.mono_wasm_call_function_on ({args.ToString ()})"); + + public static MonoCommands Resume () + => new MonoCommands ($"MONO.mono_wasm_debugger_resume ()"); } internal enum MonoErrorCodes { diff --git a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs index 03042360217..a5ef0b63e96 100644 --- a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs +++ b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/MonoProxy.cs @@ -523,11 +523,16 @@ namespace WebAssembly.Net.Debugging { await RuntimeReady (sessionId, token); } - async Task OnResume (MessageId msd_id, CancellationToken token) + async Task OnResume (MessageId msg_id, CancellationToken token) { + var ctx = GetContext (msg_id); + if (ctx.CallStack != null) { + // Stopped on managed code + await SendMonoCommand (msg_id, MonoCommands.Resume (), token); + } + //discard managed frames - GetContext (msd_id).ClearState (); - await Task.CompletedTask; + GetContext (msg_id).ClearState (); } async Task<bool> Step (MessageId msg_id, StepKind kind, CancellationToken token) diff --git a/sdks/wasm/debugger-valuetypes-test.cs b/sdks/wasm/debugger-valuetypes-test.cs index 9d1ee58d0f8..cbeea53e267 100644 --- a/sdks/wasm/debugger-valuetypes-test.cs +++ b/sdks/wasm/debugger-valuetypes-test.cs @@ -176,6 +176,37 @@ namespace DebuggerTests { Console.WriteLine ($"MethodWithArgumentsForToStringTest: {dt0}, {dt1}, {ts}, {dec}, {guid}, {dts[0]}, {obj.DT}, {sst.DT}"); } + public static void MethodUpdatingValueTypeMembers () + { + var obj = new ClassForToStringTests { + DT = new DateTime (1, 2, 3, 4, 5, 6) + }; + var vt = new StructForToStringTests { + DT = new DateTime (4, 5, 6, 7, 8, 9) + }; + Console.WriteLine ($"#1"); + obj.DT = new DateTime (9, 8, 7, 6, 5, 4); + vt.DT = new DateTime (5, 1, 3, 7, 9, 10); + Console.WriteLine ($"#2"); + } + + public static async Task MethodUpdatingValueTypeLocalsAsync () + { + var dt = new DateTime (1, 2, 3, 4, 5, 6); + Console.WriteLine ($"#1"); + dt = new DateTime (9, 8, 7, 6, 5, 4); + Console.WriteLine ($"#2"); + } + + public static void MethodUpdatingVTArrayMembers () + { + var ssta = new [] { + new StructForToStringTests { DT = new DateTime (1, 2, 3, 4, 5, 6) } + }; + Console.WriteLine ($"#1"); + ssta [0].DT = new DateTime (9, 8, 7, 6, 5, 4); + Console.WriteLine ($"#2"); + } } class ClassForToStringTests diff --git a/sdks/wasm/src/library_mono.js b/sdks/wasm/src/library_mono.js index 81639273224..e7bfa3c0daa 100644 --- a/sdks/wasm/src/library_mono.js +++ b/sdks/wasm/src/library_mono.js @@ -439,13 +439,21 @@ var MonoSupportLib = { } }, + _clear_per_step_state: function () { + this._next_value_type_id_var = 0; + this._value_types_cache = {}; + }, + + mono_wasm_debugger_resume: function () { + this._clear_per_step_state (); + }, + mono_wasm_start_single_stepping: function (kind) { console.log (">> mono_wasm_start_single_stepping " + kind); if (!this.mono_wasm_setup_single_step) this.mono_wasm_setup_single_step = Module.cwrap ("mono_wasm_setup_single_step", 'number', [ 'number']); - this._next_value_type_id_var = 0; - this._value_types_cache = {}; + this._clear_per_step_state (); return this.mono_wasm_setup_single_step (kind); }, @@ -455,8 +463,7 @@ var MonoSupportLib = { // DO NOT REMOVE - magic debugger init function console.debug ("mono_wasm_runtime_ready", "fe00e07a-5519-4dfe-b35a-f867dbaf2e28", JSON.stringify (this.loaded_files)); - this._next_value_type_id_var = 0; - this._value_types_cache = {}; + this._clear_per_step_state (); // FIXME: where should this go? this._next_call_function_res_id = 0; |