dotnet / dotnet/diagnostics

SOS bpmd command on Main can stop twice

Open
#2,607 0 comments 0 reactions 1 assignee Claimed by @mikem8361 View on GitHub
sos
Dominant language
C++
Stars
1.3k
Forks
404
Avg merge
2d 5h
Merged PRs (30d)
35

Description

If bpmd breakpoint is set before the assembly is loaded (like on Main before the app is started) and another bpmd is set after hitting the first one, continuing will stop in Main again. The code generation JIT notification sets the first native BP on the very first instruction of the method but anytime another bpmd is set, all the pending bps are updated which sets a native BP after the method's prolog. We end up with a bp on the first instruction of the method and after the prolog.

SOS's ResolveMethodInstances method (called on all "pending" bpmd's and all bps always have a pending one even if is already instantiated) uses IXCLRDataMethodInstance::GetAddressRangesByILOffset() with ILOffset 0 which returns the instruction address after the prolog. Where the code generation JIT notification (OnCodeGenerated2) passes the address of the first instruction.

The desktop doesn't have this problem because we use the old OnCodeGenerated JIT notification which doesn't pass an address.

This is why there are an extra "continue" in the SOS tests OtherCommands.script and StackAndOtherTests.script.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.