Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thaystg committed Aug 2, 2021
1 parent 222c613 commit e5340ad
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -8025,6 +8025,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
buffer_add_string (buf, f->name);
buffer_add_typeid (buf, domain, mono_class_from_mono_type_internal (f->type));
buffer_add_int (buf, f->type->attrs);
if (CHECK_PROTOCOL_VERSION(2, 61))
buffer_add_int(buf, mono_class_field_is_special_static(f));
i ++;
}
g_assert (i == nfields);
Expand Down
3 changes: 3 additions & 0 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,9 @@ public async Task<List<FieldTypeClass>> GetTypeFields(SessionId sessionId, int t
string fieldNameStr = retDebuggerCmdReader.ReadString();
int typeId = retDebuggerCmdReader.ReadInt32(); //typeId
retDebuggerCmdReader.ReadInt32(); //attrs
int isSpecialStatic = retDebuggerCmdReader.ReadInt32(); //is_special_static
if (isSpecialStatic == 1)
continue;
if (fieldNameStr.Contains("k__BackingField"))
{
fieldNameStr = fieldNameStr.Replace("k__BackingField", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public async Task BreakOnDebuggerBreak()
{
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);",
"dotnet://debugger-test.dll/debugger-test2.cs", 56, 4,
"dotnet://debugger-test.dll/debugger-test2.cs", 58, 4,
"BreakOnDebuggerBreakCommand");
}

Expand Down
20 changes: 19 additions & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task ExceptionThrownInJSOutOfBand()
[Fact]
public async Task InspectLocalsTypesAtBreakpointSite() =>
await CheckInspectLocalsAtBreakpointSite(
"dotnet://debugger-test.dll/debugger-test2.cs", 48, 8, "Types",
"dotnet://debugger-test.dll/debugger-test2.cs", 49, 8, "Types",
"window.setTimeout(function() { invoke_static_method (\"[debugger-test] Fancy:Types\")(); }, 1);",
use_cfo: false,
test_fn: (locals) =>
Expand Down Expand Up @@ -826,6 +826,24 @@ public async Task GetSourceUsingSourceLink()
Assert.True(source.IsOk);
}

[Fact]
public async Task InspectTaskAtLocals() => await CheckInspectLocalsAtBreakpointSite(
"InspectTask",
"RunInspectTask",
7,
"<RunInspectTask>b__0" ,
$"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] InspectTask:RunInspectTask'); }}, 1);",
wait_for_event_fn: async (pause_location) =>
{
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
var t_arr = await GetObjectOnLocals(locals, "t");
await CheckProps(t_arr, new
{
s_taskIdCounter = TNumber(0)
}, "t_arr", num_fields: 53);
});

//TODO add tests covering basic stepping behavior as step in/out/over
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<WasmExtraFilesToDeploy Include="debugger-driver.html" />
<WasmExtraFilesToDeploy Include="other.js" />
<WasmExtraFilesToDeploy Include="runtime-debugger.js" />
<WasmExtraFilesToDeploy Include="weather.json" />

<!-- We want to bundle these assemblies, so build them first -->
<ProjectReference Include="..\lazy-debugger-test\lazy-debugger-test.csproj" Private="true"/>
Expand Down
39 changes: 39 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System;
using System.Diagnostics;
using System.Net.Http.Json;

public class Misc
{ //Only append content to this class as the test suite depends on line info
public static int CreateObject(int foo, int bar)
Expand Down Expand Up @@ -56,3 +58,40 @@ public static void BreakOnDebuggerBreakCommand()
Debugger.Break();
}
}

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string Summary { get; set; }
}

public class InspectTask
{
public static async System.Threading.Tasks.Task RunInspectTask()
{
WeatherForecast[] forecasts = null;
var httpClient = new System.Net.Http.HttpClient();
var getJsonTask = httpClient.GetFromJsonAsync<WeatherForecast[]>("http://localhost:9400/weather.json");
try
{
await getJsonTask.ContinueWith(t =>
{
if (t.IsCompletedSuccessfully)
forecasts = t.Result;
if (t.IsFaulted)
throw t.Exception!;
});
}
catch (Exception ex)
{
Console.WriteLine($"error {ex}");
return;
}
}
}

0 comments on commit e5340ad

Please sign in to comment.