Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ internal class MethodInfo
internal LocalScopeHandleCollection localScopes;
public bool IsStatic() => (methodDef.Attributes & MethodAttributes.Static) != 0;
public int IsAsync { get; set; }
public bool IsHiddenFromDebugger { get; }
public MethodInfo(AssemblyInfo assembly, MethodDefinitionHandle methodDefHandle, int token, SourceFile source, TypeInfo type, MetadataReader asmMetadataReader, MetadataReader pdbMetadataReader)
{
this.IsAsync = -1;
Expand Down Expand Up @@ -363,6 +364,18 @@ public MethodInfo(AssemblyInfo assembly, MethodDefinitionHandle methodDefHandle,

StartLocation = new SourceLocation(this, start);
EndLocation = new SourceLocation(this, end);

foreach (var cattr in methodDef.GetCustomAttributes())
{
var ctorHandle = asmMetadataReader.GetCustomAttribute(cattr).Constructor;
if (ctorHandle.Kind == HandleKind.MemberReference)
{
var container = asmMetadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent;
var name = asmMetadataReader.GetString(asmMetadataReader.GetTypeReference((TypeReferenceHandle)container).Name);
if (name == "DebuggerHiddenAttribute")
this.IsHiddenFromDebugger = true;
}
}
}
localScopes = pdbMetadataReader.GetLocalScopes(methodDefHandle);
}
Expand Down
3 changes: 3 additions & 0 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,9 @@ private async Task SetBreakpoint(SessionId sessionId, DebugStore store, Breakpoi
{
SourceLocation loc = sourceId.First();
req.Method = loc.CliLocation.Method;
if (req.Method.IsHiddenFromDebugger)
continue;

Breakpoint bp = await SetMonoBreakpoint(sessionId, req.Id, loc, req.Condition, token);

// If we didn't successfully enable the breakpoint
Expand Down
16 changes: 16 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,5 +642,21 @@ await EvaluateAndCheck(
}
);
}


[Fact]
public async Task DebuggerAttributeNoStopInDebuggerHidden()
{
var bp_hidden = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", "HiddenMethod", 1);
var bp_visible = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", "VisibleMethod", 1);
Assert.Empty(bp_hidden.Value["locations"]);
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerAttribute:VisibleMethod'); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs",
bp_visible.Value["locations"][0]["lineNumber"].Value<int>(),
bp_visible.Value["locations"][0]["columnNumber"].Value<int>(),
"VisibleMethod"
);
}
}
}
22 changes: 22 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 @@ -807,3 +807,25 @@ public int Increment(int count)
return count + 1;
}
}

public class DebuggerAttribute
{
static int currentCount = 0;

[System.Diagnostics.DebuggerHidden]
public static void HiddenMethod()
{
currentCount++;
}

public static void VisibleMethod()
{
currentCount++;
}

public static void Run()
{
HiddenMethod();
VisibleMethod();
}
}