Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressing @radical comments.
  • Loading branch information
thaystg authored and github-actions committed Aug 16, 2022
commit 56388e56d838a339bb1b00caccc8e53f79d456c7
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ public static async Task<JArray> ExpandFieldValues(
if (getCommandOptions.HasFlag(GetObjectCommandOptions.ForDebuggerProxyAttribute))
fields = fields.Where(field => field.IsNotPrivate).ToList();

var typeInfo = await sdbHelper.GetTypeInfo(containerTypeId, token);
if (typeInfo.Info.IsNonUserCode && getCommandOptions.HasFlag(GetObjectCommandOptions.JustMyCode))
return fieldValues;

using var commandParamsWriter = new MonoBinaryWriter();
commandParamsWriter.Write(id.Value);
commandParamsWriter.Write(fields.Count);
Expand All @@ -230,6 +226,8 @@ public static async Task<JArray> ExpandFieldValues(
? await sdbHelper.SendDebuggerAgentCommand(CmdType.GetValues, commandParamsWriter, token) :
await sdbHelper.SendDebuggerAgentCommand(CmdObject.RefGetValues, commandParamsWriter, token);

var typeInfo = await sdbHelper.GetTypeInfo(containerTypeId, token);

int numFieldsRead = 0;
foreach (FieldTypeClass field in fields)
{
Expand Down Expand Up @@ -574,9 +572,15 @@ public static async Task<GetMembersResult> GetObjectMemberValues(
string typeName = await sdbHelper.GetTypeName(typeId, token);
// 0th id is for the object itself, and then its ancestors
bool isOwn = i == 0;
var typeInfo = await sdbHelper.GetTypeInfo(typeId, token);

if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode))
break;

IReadOnlyList<FieldTypeClass> thisTypeFields = await sdbHelper.GetTypeFields(typeId, token);
if (!includeStatic)
thisTypeFields = thisTypeFields.Where(f => !f.Attributes.HasFlag(FieldAttributes.Static)).ToList();

if (thisTypeFields.Count > 0)
{
var allFields = await ExpandFieldValues(
Expand All @@ -594,11 +598,6 @@ public static async Task<GetMembersResult> GetObjectMemberValues(
if (!getCommandType.HasFlag(GetObjectCommandOptions.WithProperties))
return GetMembersResult.FromValues(allMembers.Values, sortByAccessLevel);

var typeInfo = await sdbHelper.GetTypeInfo(typeId, token);

if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode))
break;

allMembers = await ExpandPropertyValues(
sdbHelper,
typeId,
Expand Down
38 changes: 30 additions & 8 deletions src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,23 +1041,45 @@ await EvaluateAndCheck(
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public async Task InspectThisThatInheritsFromClassNonUserCode(bool jmc)
[InlineData("ClassInheritsFromClassWithoutDebugSymbols", 1287, true)]
[InlineData("ClassInheritsFromClassWithoutDebugSymbols", 1287, false)]
[InlineData("ClassInheritsFromNonUserCodeClass", 1335, true)]
[InlineData("ClassInheritsFromNonUserCodeClass", 1335, false)]
public async Task InspectThisThatInheritsFromClassNonUserCode(string class_name, int line, bool jmc)
{
await SetJustMyCode(jmc);
var expression = $"{{ invoke_static_method('[debugger-test] ClassInheritsFromClassWithoutDebugSymbols:Run'); }}";
var expression = "{{ invoke_static_method('[debugger-test] " + class_name + ":Run'); }}";

await EvaluateAndCheck(
"window.setTimeout(function() {" + expression + "; }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs", 1287, 8,
$"ClassInheritsFromClassWithoutDebugSymbols.CallMethod",
"dotnet://debugger-test.dll/debugger-test.cs", line, 8,
$"{class_name}.CallMethod",
locals_fn: async (locals) =>
{
var this_props = await GetObjectOnLocals(locals, "this");
await CheckProps(this_props, new
if (jmc)
{
}, "this_props", num_fields: jmc ? 1 : 7);
await CheckProps(this_props, new
{
myField = TNumber(0),
}, "this_props", num_fields: 1);
}
else
{
Console.WriteLine(this_props);
await CheckProps(this_props, new
{
propA = TNumber(10),
propB = TNumber(20),
propC = TNumber(30),
d = TNumber(40),
e = TNumber(50),
f = TNumber(60),
G = TGetter("G"),
H = TGetter("H"),
myField = TNumber(0),
}, "this_props", num_fields: 9);
}
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ public class ClassWithoutDebugSymbolsToInherit
private int d;
public int e;
protected int f;
public int G
{
get {return f + 1;}
}
public int H => f;

public ClassWithoutDebugSymbolsToInherit()
{
propA = 10;
Expand Down
48 changes: 48 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,5 +1288,53 @@ public void CallMethod()
System.Diagnostics.Debugger.Break();
}

public int myField;
}

[System.Diagnostics.DebuggerNonUserCode]
public class ClassNonUserCodeToInherit
{
private int propA {get;}
public int propB {get;}
protected int propC {get;}
private int d;
public int e;
protected int f;
public int G
{
get {return f + 1;}
}
public int H => f;

public ClassNonUserCodeToInherit()
{
propA = 10;
propB = 20;
propC = 30;
d = 40;
e = 50;
f = 60;
Console.WriteLine(propA);
Console.WriteLine(propB);
Console.WriteLine(propC);
Console.WriteLine(d);
Console.WriteLine(e);
Console.WriteLine(f);
}
}

public class ClassInheritsFromNonUserCodeClass : ClassNonUserCodeToInherit
{
public static void Run()
{
var myVar = new ClassInheritsFromNonUserCodeClass();
myVar.CallMethod();
}

public void CallMethod()
{
System.Diagnostics.Debugger.Break();
}

public int myField;
}