-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wasm][debugger] Fixing async locals in nested ContinueWith blocks (#…
…56911) * Adding test for #41984 * Adding old @radical tests and fixing it. * Fixing tests. * Update src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update src/mono/wasm/debugger/tests/debugger-test/debugger-async-test.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Addressing @radical comments. * Addressing @radical comments. * Addressing @radical comments. Co-authored-by: Ankit Jain <radical@gmail.com>
- Loading branch information
Showing
7 changed files
with
263 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.WebAssembly.Diagnostics; | ||
using Newtonsoft.Json.Linq; | ||
using Xunit; | ||
|
||
namespace DebuggerTests | ||
{ | ||
public class AsyncTests : DebuggerTestBase | ||
{ | ||
|
||
// FIXME: method with multiple async blocks - so that we have two separate classes for that method! | ||
// FIXME: nested blocks | ||
// FIXME: Confirm the actual bp location | ||
// FIXME: check object properties.. | ||
|
||
//FIXME: function name | ||
[Theory] | ||
[InlineData("ContinueWithStaticAsync", "<ContinueWithStaticAsync>b__3_0")] | ||
[InlineData("ContinueWithInstanceAsync", "<ContinueWithInstanceAsync>b__5_0")] | ||
public async Task AsyncLocalsInContinueWith(string method_name, string expected_method_name) => await CheckInspectLocalsAtBreakpointSite( | ||
"DebuggerTests.AsyncTests.ContinueWithTests", method_name, 5, expected_method_name, | ||
"window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", | ||
wait_for_event_fn: async (pause_location) => | ||
{ | ||
var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>()); | ||
await CheckProps(frame_locals, new | ||
{ | ||
t = TObject("System.Threading.Tasks.Task.DelayPromise"), | ||
code = TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), | ||
@this = TObject("DebuggerTests.AsyncTests.ContinueWithTests.<>c"), | ||
dt = TDateTime(new DateTime(4513, 4, 5, 6, 7, 8)) | ||
}, "locals"); | ||
|
||
var res = await InvokeGetter(GetAndAssertObjectWithName(frame_locals, "t"), "Status"); | ||
await CheckValue(res.Value["result"], TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), "t.Status"); | ||
}); | ||
|
||
[Fact] | ||
public async Task AsyncLocalsInContinueWithInstanceUsingThisBlock() => await CheckInspectLocalsAtBreakpointSite( | ||
"DebuggerTests.AsyncTests.ContinueWithTests", "ContinueWithInstanceUsingThisAsync", 5, "<ContinueWithInstanceUsingThisAsync>b__6_0", | ||
"window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", | ||
wait_for_event_fn: async (pause_location) => | ||
{ | ||
var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>()); | ||
await CheckProps(frame_locals, new | ||
{ | ||
t = TObject("System.Threading.Tasks.Task.DelayPromise"), | ||
code = TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), | ||
dt = TDateTime(new DateTime(4513, 4, 5, 6, 7, 8)), | ||
@this = TObject("DebuggerTests.AsyncTests.ContinueWithTests") | ||
}, "locals"); | ||
|
||
var res = await InvokeGetter(GetAndAssertObjectWithName(frame_locals, "t"), "Status"); | ||
await CheckValue(res.Value["result"], TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), "t.Status"); | ||
|
||
res = await InvokeGetter(GetAndAssertObjectWithName(frame_locals, "this"), "Date"); | ||
await CheckValue(res.Value["result"], TDateTime(new DateTime(2510, 1, 2, 3, 4, 5)), "this.Date"); | ||
}); | ||
|
||
[Fact] // NestedContinueWith | ||
public async Task AsyncLocalsInNestedContinueWithStaticBlock() => await CheckInspectLocalsAtBreakpointSite( | ||
"DebuggerTests.AsyncTests.ContinueWithTests", "NestedContinueWithStaticAsync", 5, "MoveNext", | ||
"window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", | ||
wait_for_event_fn: async (pause_location) => | ||
{ | ||
var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>()); | ||
await CheckProps(frame_locals, new | ||
{ | ||
t = TObject("System.Threading.Tasks.Task.DelayPromise"), | ||
code = TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), | ||
str = TString("foobar"), | ||
@this = TObject("DebuggerTests.AsyncTests.ContinueWithTests.<>c__DisplayClass4_0"), | ||
ncs_dt0 = TDateTime(new DateTime(3412, 4, 6, 8, 0, 2)) | ||
}, "locals"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/mono/wasm/debugger/tests/debugger-test/debugger-async-test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace DebuggerTests.AsyncTests | ||
{ | ||
public class ContinueWithTests | ||
{ | ||
public DateTime Date => new DateTime(2510, 1, 2, 3, 4, 5); | ||
|
||
public static async Task RunAsync() | ||
{ | ||
await ContinueWithStaticAsync("foobar"); | ||
await new ContinueWithTests().ContinueWithInstanceAsync("foobar"); | ||
|
||
await NestedContinueWithStaticAsync("foobar"); | ||
await new ContinueWithTests().NestedContinueWithInstanceAsync("foobar"); | ||
await new ContinueWithTests().ContinueWithInstanceUsingThisAsync("foobar"); | ||
|
||
} | ||
|
||
public static async Task ContinueWithStaticAsync(string str) | ||
{ | ||
await Task.Delay(1000).ContinueWith(t => | ||
{ | ||
var code = t.Status; | ||
var dt = new DateTime(4513, 4, 5, 6, 7, 8); | ||
Console.WriteLine ($"First continueWith: {code}, {dt}"); //t, code, dt | ||
}); | ||
Console.WriteLine ($"done with this method"); | ||
} | ||
|
||
public static async Task NestedContinueWithStaticAsync(string str) | ||
{ | ||
await Task.Delay(500).ContinueWith(async t => | ||
{ | ||
var code = t.Status; | ||
var ncs_dt0 = new DateTime(3412, 4, 6, 8, 0, 2); | ||
Console.WriteLine ($"First continueWith: {code}, {ncs_dt0}"); // t, code, str, dt0 | ||
await Task.Delay(300).ContinueWith(t2 => | ||
{ | ||
var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); | ||
Console.WriteLine ($"t2: {t2.Status}, str: {str}, {ncs_dt1}, {ncs_dt0}");//t2, dt1, str, dt0 | ||
}); | ||
}); | ||
Console.WriteLine ($"done with this method"); | ||
} | ||
|
||
public async Task ContinueWithInstanceAsync(string str) | ||
{ | ||
await Task.Delay(1000).ContinueWith(t => | ||
{ | ||
var code = t.Status; | ||
var dt = new DateTime(4513, 4, 5, 6, 7, 8); | ||
Console.WriteLine ($"First continueWith: {code}, {dt}");// t, code, dt | ||
}); | ||
Console.WriteLine ($"done with this method"); | ||
} | ||
|
||
public async Task ContinueWithInstanceUsingThisAsync(string str) | ||
{ | ||
await Task.Delay(1000).ContinueWith(t => | ||
{ | ||
var code = t.Status; | ||
var dt = new DateTime(4513, 4, 5, 6, 7, 8); | ||
Console.WriteLine ($"First continueWith: {code}, {dt}, {this.Date}"); | ||
}); | ||
Console.WriteLine ($"done with this method"); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] | ||
public async Task NestedContinueWithInstanceAsync(string str) | ||
{ | ||
await Task.Delay(500).ContinueWith(async t => | ||
{ | ||
var code = t.Status; | ||
var dt0 = new DateTime(3412, 4, 6, 8, 0, 2); | ||
if (str == "oi") | ||
{ | ||
dt0 = new DateTime(3415, 4, 6, 8, 0, 2); | ||
} | ||
Console.WriteLine ($"First continueWith: {code}, {dt0}, {Date}");//this, t, code, str, dt0 | ||
await Task.Delay(300).ContinueWith(t2 => | ||
{ | ||
var dt1 = new DateTime(4513, 4, 5, 6, 7, 8); | ||
Console.WriteLine ($"t2: {t2.Status}, str: {str}, {dt1}, {dt0}");//this, t2, dt1, str, dt0 | ||
}); | ||
}); | ||
Console.WriteLine ($"done with this method"); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters