Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e489e94
Description of DebuggerBrowsable behavior.
ilonatommy Nov 25, 2021
2423830
Added test for browse attributes.
ilonatommy Nov 25, 2021
f5ede4a
Corrected typos in the doc.
ilonatommy Nov 25, 2021
326ac82
Added Browse Never feature. Corrected Collapse test. ToDo: RootHidden.
ilonatommy Nov 29, 2021
abb60a5
Draft of RootHidden solution.
ilonatommy Dec 1, 2021
609161b
Added Array to test cases as it behaves differently than Collection.
ilonatommy Dec 1, 2021
5c82b46
Added name concatenation to make array/list elemetns in debug window …
ilonatommy Dec 1, 2021
890acbb
Merge branch 'main' into debugger-browse-attribute
ilonatommy Dec 1, 2021
973bd3a
Update docs/design/mono/debugger.md
ilonatommy Dec 2, 2021
0d37c77
Applied PR review suggestions.
ilonatommy Dec 2, 2021
8353e33
Added a reference to regular Browsable attribute behavior in .net.
ilonatommy Dec 2, 2021
8fbdff9
Applied most of review suggestions.
ilonatommy Dec 2, 2021
1a06a96
Stopping GetFieldsValue early.
ilonatommy Dec 2, 2021
3c9a02e
Remove unintentional change to the original code.
ilonatommy Dec 2, 2021
01d7e84
Merge branch 'main' into debugger-browse-attribute
ilonatommy Dec 2, 2021
8a322ab
Merge branch 'main' into debugger-browse-attribute
ilonatommy Dec 3, 2021
9ee0fe9
Do not skip fields that don't have browsable attributes.
ilonatommy Dec 3, 2021
1ec30f7
Changing the expected behavior to match Console Application. EventHan…
ilonatommy Dec 3, 2021
98c82bb
Changed the place of checking if objetc is an array.
ilonatommy Dec 3, 2021
00e58cb
Update src/mono/wasm/debugger/DebuggerTestSuite/EvaluateOnCallFrameTe…
ilonatommy Dec 6, 2021
8f954f4
Removed unused variables.
ilonatommy Dec 6, 2021
ef135fb
Merge branch 'debugger-browse-attribute' of https://github.com/ilonat…
ilonatommy Dec 6, 2021
314dac7
Removing space and unused import.
ilonatommy Dec 6, 2021
e068d0e
Merge with main.
ilonatommy Dec 9, 2021
4f4f703
Partially addressed @radical comments.
ilonatommy Dec 10, 2021
ab93329
Addressed the comment about extension instead of Union.
ilonatommy Dec 10, 2021
88682ab
Removed string cultural vunerability.
ilonatommy Dec 10, 2021
8629a99
Added Properties dictionary, the same as for fields.
ilonatommy Dec 10, 2021
53b525a
Fixed the bug I made by using dynamc.
ilonatommy Dec 10, 2021
458a78b
Applying @radical comments about refactoring.
ilonatommy Dec 10, 2021
feafa66
Corrected typo.
ilonatommy Dec 14, 2021
0ad80a4
Added tests for properties.
ilonatommy Dec 14, 2021
cd7f9da
Draft of changes for properties handling - never and root hidden fail…
ilonatommy Dec 14, 2021
b6902bd
Fix for RootHidden properties.
ilonatommy Dec 14, 2021
8945dbe
Added tests for static fields decorated with Browsable.
ilonatommy Dec 14, 2021
2c59af7
Correct a typo.
ilonatommy Dec 14, 2021
f6ad020
Merge with main.
ilonatommy Dec 17, 2021
bdf671b
Undo merge unintentional changes.
ilonatommy Dec 17, 2021
85928ed
Changing expected behavior for MulticastDelegateTest - in Console App…
ilonatommy Dec 17, 2021
b1acf8b
Removing not relevant changes created after merge with main.
ilonatommy Dec 17, 2021
153f41a
Remove file added in merge with main.
ilonatommy Dec 17, 2021
1276724
Revert "Removing not relevant changes created after merge with main."
ilonatommy Dec 17, 2021
f943552
Revert.
ilonatommy Dec 17, 2021
7c7c620
Revert revert.
ilonatommy Dec 17, 2021
e148b2d
One broken test for custom getter.
ilonatommy Dec 20, 2021
28ef9b0
Ugly fix to make all the tests work.
ilonatommy Dec 20, 2021
8cf81dc
Refactored JArray aggregation to Dictionary.
ilonatommy Dec 21, 2021
ae8ebb4
Better naming.
ilonatommy Dec 21, 2021
f7ee76b
Merge with main.
ilonatommy Dec 21, 2021
098e3f1
Remove not connected to PR file.
ilonatommy Jan 3, 2022
bb4cb8d
Applied @thaystg suggestions.
ilonatommy Jan 3, 2022
44145e4
Removed comments.
ilonatommy Jan 3, 2022
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
9 changes: 8 additions & 1 deletion docs/design/mono/debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ Web Assembly Debugger supports usage of following attributes:
- Stepping In/Over: results in an additional stepping need to proceed to the next line.<br><br>
- __System.Diagnostics.DebuggerDisplay__
- __System.Diagnostics.DebuggerTypeProxy__
- ...
- __System.Diagnostics.DebuggerBrowsable__ ([doc](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.debuggerbrowsableattribute?view=net-6.0))
- Collapsed - displayed normally.
- RootHidden:
- Simple type - not displayed in the debugger window.
- Collection / Array - the values of a collection are displayed in a flat view, using the naming convention: *rootName[idx]*.

- Never - not displayed in the debugger window.

70 changes: 66 additions & 4 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using System.IO.Compression;
using System.Reflection;
using System.Collections.Immutable;
using System.Diagnostics;
using Microsoft.VisualBasic;

namespace Microsoft.WebAssembly.Diagnostics
{
Expand Down Expand Up @@ -475,14 +477,19 @@ public VarInfo[] GetLiveVarsAt(int offset)

internal class TypeInfo
{
private readonly ILogger logger;
internal AssemblyInfo assembly;
private TypeDefinition type;
private List<MethodInfo> methods;
internal int Token { get; }
internal string Namespace { get; }

public TypeInfo(AssemblyInfo assembly, TypeDefinitionHandle typeHandle, TypeDefinition type)
public Dictionary<string, DebuggerBrowsableState?> DebuggerBrowsableFields = new();
public Dictionary<string, DebuggerBrowsableState?> DebuggerBrowsableProperties = new();

public TypeInfo(AssemblyInfo assembly, TypeDefinitionHandle typeHandle, TypeDefinition type, ILogger logger)
{
this.logger = logger;
this.assembly = assembly;
var metadataReader = assembly.asmMetadataReader;
Token = MetadataTokens.GetToken(metadataReader, typeHandle);
Expand All @@ -500,6 +507,63 @@ public TypeInfo(AssemblyInfo assembly, TypeDefinitionHandle typeHandle, TypeDefi
FullName = Namespace + "." + Name;
else
FullName = Name;

foreach (var field in type.GetFields())
{
try
{
var fieldDefinition = metadataReader.GetFieldDefinition(field);
var fieldName = metadataReader.GetString(fieldDefinition.Name);
AppendToBrowsable(DebuggerBrowsableFields, fieldDefinition.GetCustomAttributes(), fieldName);
}
catch (Exception ex)
{
logger.LogDebug($"Failed to read browsable attributes of a field. ({ex.Message})");
continue;
}
}

foreach (var prop in type.GetProperties())
{
try
{
var propDefinition = metadataReader.GetPropertyDefinition(prop);
var propName = metadataReader.GetString(propDefinition.Name);
AppendToBrowsable(DebuggerBrowsableProperties, propDefinition.GetCustomAttributes(), propName);
}
catch (Exception ex)
{
logger.LogDebug($"Failed to read browsable attributes of a property. ({ex.Message})");
continue;
}
}

void AppendToBrowsable(Dictionary<string, DebuggerBrowsableState?> dict, CustomAttributeHandleCollection customAttrs, string fieldName)
{
foreach (var cattr in customAttrs)
{
try
{
var ctorHandle = metadataReader.GetCustomAttribute(cattr).Constructor;
if (ctorHandle.Kind != HandleKind.MemberReference)
continue;
var container = metadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent;
var valueBytes = metadataReader.GetBlobBytes(metadataReader.GetCustomAttribute(cattr).Value);
var attributeName = metadataReader.GetString(metadataReader.GetTypeReference((TypeReferenceHandle)container).Name);
if (attributeName != "DebuggerBrowsableAttribute")
continue;
var state = (DebuggerBrowsableState)valueBytes[2];
if (!Enum.IsDefined(typeof(DebuggerBrowsableState), state))
continue;
dict.Add(fieldName, state);
break;
}
catch
{
continue;
}
}
}
}

public TypeInfo(AssemblyInfo assembly, string name)
Expand All @@ -515,7 +579,6 @@ public TypeInfo(AssemblyInfo assembly, string name)
public override string ToString() => "TypeInfo('" + FullName + "')";
}


internal class AssemblyInfo
{
private static int next_id;
Expand Down Expand Up @@ -652,7 +715,7 @@ SourceFile FindSource(DocumentHandle doc, int rowid, string documentName)
{
var typeDefinition = asmMetadataReader.GetTypeDefinition(type);

var typeInfo = new TypeInfo(this, type, typeDefinition);
var typeInfo = new TypeInfo(this, type, typeDefinition, logger);
TypesByName[typeInfo.FullName] = typeInfo;
TypesByToken[typeInfo.Token] = typeInfo;
if (pdbMetadataReader != null)
Expand Down Expand Up @@ -680,7 +743,6 @@ SourceFile FindSource(DocumentHandle doc, int rowid, string documentName)
}
}
}

}

private void ProcessSourceLink()
Expand Down
Loading