Skip to content

Commit e818708

Browse files
authored
fix behavior of JMC (#75783)
1 parent 774324e commit e818708

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ public static async Task<JArray> ExpandFieldValues(
238238
JObject fieldValue = await ReadFieldValue(sdbHelper, retDebuggerCmdReader, field, id.Value, typeInfo, valtype, isOwn, parentTypeId, getCommandOptions, token);
239239
numFieldsRead++;
240240

241+
if (typeInfo.Info.IsNonUserCode && getCommandOptions.HasFlag(GetObjectCommandOptions.JustMyCode) && field.Attributes.HasFlag(FieldAttributes.Private))
242+
continue;
243+
241244
if (!Enum.TryParse(fieldValue["__state"].Value<string>(), out DebuggerBrowsableState fieldState)
242245
|| fieldState == DebuggerBrowsableState.Collapsed)
243246
{
@@ -311,7 +314,7 @@ public static async Task<Dictionary<string, JObject>> ExpandPropertyValues(
311314
int typeId,
312315
string typeName,
313316
ArraySegment<byte> getterParamsBuffer,
314-
bool isAutoExpandable,
317+
GetObjectCommandOptions getCommandOptions,
315318
DotnetObjectId objectId,
316319
bool isValueType,
317320
bool isOwn,
@@ -347,6 +350,10 @@ public static async Task<Dictionary<string, JObject>> ExpandPropertyValues(
347350
MethodAttributes getterAttrs = getterInfo.Info.Attributes;
348351
MethodAttributes getterMemberAccessAttrs = getterAttrs & MethodAttributes.MemberAccessMask;
349352
MethodAttributes vtableLayout = getterAttrs & MethodAttributes.VtableLayoutMask;
353+
354+
if (typeInfo.Info.IsNonUserCode && getCommandOptions.HasFlag(GetObjectCommandOptions.JustMyCode) && getterMemberAccessAttrs == MethodAttributes.Private)
355+
continue;
356+
350357
bool isNewSlot = (vtableLayout & MethodAttributes.NewSlot) == MethodAttributes.NewSlot;
351358

352359
typePropertiesBrowsableInfo.TryGetValue(propName, out DebuggerBrowsableState? state);
@@ -454,7 +461,7 @@ async Task AddProperty(
454461
{
455462
string returnTypeName = await sdbHelper.GetReturnType(getMethodId, token);
456463
JObject propRet = null;
457-
if (isAutoExpandable || (state is DebuggerBrowsableState.RootHidden && IsACollectionType(returnTypeName)))
464+
if (getCommandOptions.HasFlag(GetObjectCommandOptions.AutoExpandable) || getCommandOptions.HasFlag(GetObjectCommandOptions.ForDebuggerProxyAttribute) || (state is DebuggerBrowsableState.RootHidden && IsACollectionType(returnTypeName)))
458465
{
459466
try
460467
{
@@ -568,10 +575,6 @@ public static async Task<GetMembersResult> GetObjectMemberValues(
568575
for (int i = 0; i < typeIdsCnt; i++)
569576
{
570577
int typeId = typeIdsIncludingParents[i];
571-
var typeInfo = await sdbHelper.GetTypeInfo(typeId, token);
572-
573-
if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode))
574-
continue;
575578

576579
int parentTypeId = i + 1 < typeIdsCnt ? typeIdsIncludingParents[i + 1] : -1;
577580
string typeName = await sdbHelper.GetTypeName(typeId, token);
@@ -604,7 +607,7 @@ public static async Task<GetMembersResult> GetObjectMemberValues(
604607
typeId,
605608
typeName,
606609
getPropertiesParamBuffer,
607-
getCommandType.HasFlag(GetObjectCommandOptions.ForDebuggerProxyAttribute),
610+
getCommandType,
608611
id,
609612
isValueType: false,
610613
isOwn,

src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ internal enum GetObjectCommandOptions
6060
ForDebuggerProxyAttribute = 8,
6161
ForDebuggerDisplayAttribute = 16,
6262
WithProperties = 32,
63-
JustMyCode = 64
63+
JustMyCode = 64,
64+
AutoExpandable = 128
6465
}
6566

6667
internal enum CommandSet {

src/mono/wasm/debugger/BrowserDebugProxy/ValueTypeClass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public async Task ExpandPropertyValues(MonoSDBHelper sdbHelper, bool splitMember
290290
typeId,
291291
className,
292292
Buffer,
293-
autoExpand,
293+
autoExpand ? GetObjectCommandOptions.AutoExpandable : GetObjectCommandOptions.None,
294294
Id,
295295
isValueType: true,
296296
isOwn: i == 0,

src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,11 @@ await EvaluateAndCheck(
10671067
{
10681068
myField = TNumber(0),
10691069
myField2 = TNumber(0),
1070-
}, "this_props", num_fields: 2);
1070+
propB = TGetter("propB"),
1071+
propC = TGetter("propC"),
1072+
e = TNumber(50),
1073+
f = TNumber(60),
1074+
}, "this_props", num_fields: 6);
10711075
}
10721076
else
10731077
{

src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/test.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public class ClassNonUserCodeToInheritThatInheritsFromNormalClass : NormalClass
1616
private int d;
1717
public int e;
1818
protected int f;
19-
public int G
19+
private int G
2020
{
2121
get {return f + 1;}
2222
}
23-
public int H => f;
23+
private int H => f;
2424

2525
public ClassNonUserCodeToInheritThatInheritsFromNormalClass()
2626
{

src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public class ClassWithoutDebugSymbolsToInherit
1010
private int d;
1111
public int e;
1212
protected int f;
13-
public int G
13+
private int G
1414
{
1515
get {return f + 1;}
1616
}
17-
public int H => f;
17+
private int H => f;
1818

1919
public ClassWithoutDebugSymbolsToInherit()
2020
{

src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,11 +1300,11 @@ public class ClassNonUserCodeToInherit
13001300
private int d;
13011301
public int e;
13021302
protected int f;
1303-
public int G
1303+
private int G
13041304
{
13051305
get {return f + 1;}
13061306
}
1307-
public int H => f;
1307+
private int H => f;
13081308

13091309
public ClassNonUserCodeToInherit()
13101310
{

0 commit comments

Comments
 (0)