-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[NativeAOT] fix NAOT mappings (follow-up to https://github.com/dotnet/runtime/pull/123333) #123831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
82202e6
b1cc0fc
93769cc
0ea5363
d107008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -260,10 +260,9 @@ public IEnumerable<NativeSequencePoint> GetNativeSequencePoints() | |
| if (_debugLocInfos == null) | ||
| yield break; | ||
|
|
||
| var sequencePoints = new (string Document, int LineNumber, bool IsBackedSequencePoint)[_debugLocInfos.Length * 4 /* chosen empirically */]; | ||
| var sequencePoints = new (string Document, int LineNumber)[_debugLocInfos.Length * 4 /* chosen empirically */]; | ||
| try | ||
| { | ||
| int maxOffset = 0; | ||
| foreach (var sequencePoint in _debugInfo.GetSequencePoints()) | ||
| { | ||
| int offset = sequencePoint.Offset; | ||
|
|
@@ -272,16 +271,15 @@ public IEnumerable<NativeSequencePoint> GetNativeSequencePoints() | |
| int newLength = Math.Max(2 * sequencePoints.Length, sequencePoint.Offset + 1); | ||
| Array.Resize(ref sequencePoints, newLength); | ||
| } | ||
| sequencePoints[offset] = (sequencePoint.Document, sequencePoint.LineNumber, true); | ||
| maxOffset = Math.Max(maxOffset, offset); | ||
| sequencePoints[offset] = (sequencePoint.Document, sequencePoint.LineNumber); | ||
| } | ||
|
|
||
| // Propagate last known document/line number forward to enable correct mapping when IL offsets decrease at higher native offsets | ||
| for (int i = 1; i <= maxOffset; i++) | ||
| for (int i = 1; i < sequencePoints.Length; i++) | ||
rcj1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if (sequencePoints[i].Document == null && sequencePoints[i - 1].Document != null) | ||
| { | ||
| sequencePoints[i] = (sequencePoints[i - 1].Document, sequencePoints[i - 1].LineNumber, false); | ||
| sequencePoints[i] = (sequencePoints[i - 1].Document, sequencePoints[i - 1].LineNumber); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -294,28 +292,26 @@ public IEnumerable<NativeSequencePoint> GetNativeSequencePoints() | |
| } | ||
|
|
||
| int previousNativeOffset = -1; | ||
| int previousIlOffset = -1; | ||
| string previousDocument = null; | ||
| int previousLineNumber = -1; | ||
| // OffsetMapping is sorted in order of increasing native offset (but not necessarily by IL offset) | ||
| foreach (var nativeMapping in _debugLocInfos) | ||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
rcj1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if (nativeMapping.NativeOffset == previousNativeOffset) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like sequencePoints.Length was chosen to try to minimize the chances of this, but yes I think this would be a good failure behavior. |
||
| continue; | ||
|
|
||
| if (nativeMapping.ILOffset < sequencePoints.Length) | ||
| var sequencePoint = sequencePoints[Math.Min(nativeMapping.ILOffset, sequencePoints.Length - 1)]; | ||
rcj1 marked this conversation as resolved.
Show resolved
Hide resolved
rcj1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Emit sequence point if its line number or document differ from the previous one. | ||
| // See WalkILOffsetsCallback in src/coreclr/vm/debugdebugger.cpp for more details. | ||
| if (sequencePoint.Document != null && (sequencePoint.Document != previousDocument || sequencePoint.LineNumber != previousLineNumber)) | ||
| { | ||
| var sequencePoint = sequencePoints[nativeMapping.ILOffset]; | ||
| // Emit sequence point if we have it from _debugInfo or if ILOffset decreases. | ||
| // This handles the case of IL offsets decreasing at higher native offsets. | ||
| // See WalkILOffsetsCallback in src/coreclr/vm/debugdebugger.cpp for more details. | ||
| if ((sequencePoint.IsBackedSequencePoint || nativeMapping.ILOffset < previousIlOffset) && | ||
| sequencePoint.Document != null) | ||
| { | ||
| yield return new NativeSequencePoint( | ||
| nativeMapping.NativeOffset, | ||
| sequencePoint.Document, | ||
| sequencePoint.LineNumber); | ||
| previousNativeOffset = nativeMapping.NativeOffset; | ||
| previousIlOffset = nativeMapping.ILOffset; | ||
| } | ||
| yield return new NativeSequencePoint( | ||
| nativeMapping.NativeOffset, | ||
| sequencePoint.Document, | ||
| sequencePoint.LineNumber); | ||
| previousNativeOffset = nativeMapping.NativeOffset; | ||
| previousDocument = sequencePoint.Document; | ||
| previousLineNumber = sequencePoint.LineNumber; | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.