Skip to content

Commit

Permalink
add debugger test
Browse files Browse the repository at this point in the history
Co-Authored-By: Thays Grazia <thaystg@gmail.com>
  • Loading branch information
2 people authored and github-actions committed Nov 12, 2023
1 parent 9cdc361 commit 1d89ea4
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/HotReloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,68 @@ public async Task DebugHotReloadMethod_AddingNewClassUsingDebugAttribute()
await StepAndCheck(StepKind.Into, $"dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 119, 12, "ApplyUpdateReferencedAssembly.MethodBody10.StaticMethod1");
}

[ConditionalFact(nameof(RunningOnChrome))]
public async Task DebugHotReloadMethod_AddingNewMethodAndThrowException()
{
//await SetPauseOnException("all");
string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll");
string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb");
string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll");

var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 129, 12, use_regex: true);
var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 133, 12, use_regex: true);

var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges(
asm_file, pdb_file, "MethodBody11", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" });

CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 129, 12, scripts, pause_location["callFrames"]?[0]["location"]);
//apply first update
pause_location = await LoadAssemblyAndTestHotReloadUsingSDB(
asm_file_hot_reload, "MethodBody11", "NewMethodStaticWithThrow", 1);

JToken top_frame = pause_location["callFrames"]?[0];
AssertEqual("ApplyUpdateReferencedAssembly.MethodBody11.NewMethodStaticWithThrow", top_frame?["functionName"]?.Value<string>(), top_frame?.ToString());
CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 133, 12, scripts, top_frame["location"]);
await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 134, 12, "ApplyUpdateReferencedAssembly.MethodBody11.NewMethodStaticWithThrow",
locals_fn: async (locals) =>
{
CheckNumber(locals, "i", 20);
await Task.CompletedTask;
}
);

await SetPauseOnException("all");

pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null);

await CheckValue(pause_location["data"], JObject.FromObject(new
{
type = "object",
subtype = "error",
className = "System.Exception",
uncaught = false
}), "exception0.data");

pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null);
try
{
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null);
}
catch (System.Exception ae)
{
System.Console.WriteLine(ae);
var eo = JObject.Parse(ae.Message);

AssertEqual("Uncaught", eo["exceptionDetails"]?["text"]?.Value<string>(), "text");

await CheckValue(eo["exceptionDetails"]?["exception"], JObject.FromObject(new
{
type = "object",
subtype = "error",
className = "Error"
}), "exception");
}
}
// Enable this test when https://github.com/dotnet/hotreload-utils/pull/264 flows into dotnet/runtime repo
// [ConditionalFact(nameof(RunningOnChrome))]
// public async Task DebugHotReloadMethod_ChangeParameterName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,23 @@ public static void StaticMethod1 () {
// return M1(1, 2);
// }
// }













public class MethodBody11 {
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a line that will not be changed");
Console.WriteLine("original");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,18 @@ public static void StaticMethod2 () {
Console.WriteLine($"do not step into here");
}
}

public class MethodBody11 {
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a line that will not be changed");
Console.WriteLine("original");
}
public static void NewMethodStaticWithThrow () {
int i = 20;
Console.WriteLine($"add a breakpoint in the new static method, look at locals {i}");
throw new Exception("my exception");
/*var newvar = new MethodBody6();
newvar.NewMethodInstance (10);*/
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,18 @@ public static void StaticMethod2 () {
Console.WriteLine($"do not step into here");
}
}

public class MethodBody11 {
public static void StaticMethod1 () {
Console.WriteLine("breakpoint in a line that will not be changed");
Console.WriteLine("original");
}
public static void NewMethodStaticWithThrow () {
int i = 20;
Console.WriteLine($"add a breakpoint in the new static method, look at locals {i}");
throw new Exception("my exception");
/*var newvar = new MethodBody6();
newvar.NewMethodInstance (10);*/
}
}
}

0 comments on commit 1d89ea4

Please sign in to comment.