diff options
author | Ankit Jain <radical@gmail.com> | 2020-02-25 21:18:27 +0300 |
---|---|---|
committer | Ankit Jain <radical@gmail.com> | 2020-02-25 21:36:38 +0300 |
commit | 5c0b1e1c8367db37a37d7063ddc8e8ff1b574a6b (patch) | |
tree | 992995e963d01387fa1fde6b3d168ecd391cf58f /sdks | |
parent | f6bef135d5188d1dfedac5722b93ef81bbd428cf (diff) |
[wasm][debugger] Fix getting async method locals, and `this`
- async local field names don't start with `<`, surface those
- `this` for the actual async method is in a field named like
`<>4__this`, surface it as the `this` object
Diffstat (limited to 'sdks')
-rw-r--r-- | sdks/wasm/DebuggerTestSuite/Tests.cs | 40 | ||||
-rw-r--r-- | sdks/wasm/debugger-driver.html | 4 | ||||
-rw-r--r-- | sdks/wasm/debugger-test.cs | 25 |
3 files changed, 69 insertions, 0 deletions
diff --git a/sdks/wasm/DebuggerTestSuite/Tests.cs b/sdks/wasm/DebuggerTestSuite/Tests.cs index 5954ab03e4f..d64b66f0a8c 100644 --- a/sdks/wasm/DebuggerTestSuite/Tests.cs +++ b/sdks/wasm/DebuggerTestSuite/Tests.cs @@ -704,6 +704,46 @@ namespace DebuggerTests }); } + [Fact] + public async Task InspectLocalsInAsyncMethods () { + var insp = new Inspector (); + //Collect events + var scripts = SubscribeToScripts(insp); + + await Ready(); + await insp.Ready (async (cli, token) => { + var ctx = new DebugTestContext (cli, insp, token, scripts); + var debugger_test_loc = "dotnet://debugger-test.dll/debugger-test.cs"; + + await SetBreakpoint (debugger_test_loc, 108, 3, ctx); + await SetBreakpoint (debugger_test_loc, 118, 3, ctx); + + // Will stop in Asyncmethod0 + var wait_res = await EvaluateAndCheck ( + "window.setTimeout(function() { invoke_async_method_with_await(); }, 1);", + debugger_test_loc, 108, 3, "MoveNext", ctx, //FIXME: + locals_fn: (locals) => { + Assert.Equal (4, locals.Count()); + CheckString (locals, "s", "string from js"); + CheckNumber (locals, "i", 42); + CheckString (locals, "local0", "value0"); + CheckObject (locals, "this", "Math.NestedInMath"); + } + ); + + // TODO: previous frames have async machinery details, so no point checking that right now + + await SendCommandAndCheck (null, "Debugger.resume", debugger_test_loc, 118, 3, "AsyncMethodNoReturn", ctx, + locals_fn: (locals) => { + Assert.Equal (2, locals.Count()); + CheckString (locals, "str", "AsyncMethodNoReturn's local"); + CheckObject (locals, "this", "Math.NestedInMath"); + } + ); + // TODO: Check `this` properties + }); + } + async Task<JObject> StepAndCheck (StepKind kind, string script_loc, int line, int column, string function_name, DebugTestContext ctx, Func<JObject, Task> wait_for_event_fn = null, Action<JToken> locals_fn = null, int times=1) { diff --git a/sdks/wasm/debugger-driver.html b/sdks/wasm/debugger-driver.html index 42934a154d5..d05034bf976 100644 --- a/sdks/wasm/debugger-driver.html +++ b/sdks/wasm/debugger-driver.html @@ -11,6 +11,7 @@ this.delegates_test = Module.mono_bind_static_method ("[debugger-test] Math:DelegatesTest"); this.generic_types_test = Module.mono_bind_static_method ("[debugger-test] Math:GenericTypesTest"); this.outer_method = Module.mono_bind_static_method ("[debugger-test] Math:OuterMethod"); + this.async_method = Module.mono_bind_static_method ("[debugger-test] Math/NestedInMath:AsyncTest"); console.log ("ready"); }, }; @@ -35,6 +36,9 @@ console.log('invoke_outer_method called'); return App.outer_method (); } + async function invoke_async_method_with_await () { + return await App.async_method ("string from js", 42); + } </script> <script type="text/javascript" src="mono-config.js"></script> <script type="text/javascript" src="runtime.js"></script> diff --git a/sdks/wasm/debugger-test.cs b/sdks/wasm/debugger-test.cs index 18fba8e5b97..094f5152ce6 100644 --- a/sdks/wasm/debugger-test.cs +++ b/sdks/wasm/debugger-test.cs @@ -100,5 +100,30 @@ public class Math { //Only append content to this class as the test suite depend Console.WriteLine ($"i: {i} and j: {j}"); return j; } + + Math m = new Math (); + public async System.Threading.Tasks.Task<bool> AsyncMethod0 (string s, int i) + { + string local0 = "value0"; + await System.Threading.Tasks.Task.Delay (1); + Console.WriteLine ($"* time for the second await, local0: {local0}"); + await AsyncMethodNoReturn (); + return true; + } + + public async System.Threading.Tasks.Task AsyncMethodNoReturn () + { + string str = "AsyncMethodNoReturn's local"; + Console.WriteLine ($"* field m: {m}"); + await System.Threading.Tasks.Task.Delay (1); + Console.WriteLine ($"str: {str}"); + } + + public static async System.Threading.Tasks.Task<bool> AsyncTest (string s, int i) + { + return await new NestedInMath().AsyncMethod0 (s, i); + } + } + } |