diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs index a58c0af969d3d4..2d4ca78b1f40fd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs @@ -103,14 +103,9 @@ static Vertex CreateLineNumbersBlob(NativeWriter writer, StackTraceDocumentsNode foreach (NativeSequencePoint sequencePoint in debugInfoNode.GetNativeSequencePoints()) { - if (currentLineNumber == sequencePoint.LineNumber && currentDocument == sequencePoint.FileName) - continue; - // Make sure a zero native offset delta is not possible because we use it below // to indicate an update to the current document. - if (currentDocument != null && currentNativeOffset == sequencePoint.NativeOffset) - continue; - + Debug.Assert(currentDocument == null || currentNativeOffset != sequencePoint.NativeOffset); if (currentDocument != sequencePoint.FileName) { // We start with currentDocument == null, so the reader knows the first byte of the output diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs index f2853124566b34..7681e8c062dc27 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs @@ -260,10 +260,9 @@ public IEnumerable 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 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++) { 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 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) { if (nativeMapping.NativeOffset == previousNativeOffset) continue; - if (nativeMapping.ILOffset < sequencePoints.Length) + var sequencePoint = sequencePoints[Math.Min(nativeMapping.ILOffset, sequencePoints.Length - 1)]; + // 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; } } } diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index c64ff0f1b49699..c021c96173dffb 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -1048,6 +1048,9 @@ private void setBoundaries(CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping case (int)MappingTypes.NO_MAPPING: continue; } + // Ignore these; see WalkILOffsetsCallback in src/coreclr/vm/debugdebugger.cpp. + if (nativeToILInfo->source == SourceTypes.CALL_INSTRUCTION) + continue; debugLocInfos.Add(new DebugLocInfo((int)nativeToILInfo->nativeOffset, ilOffset)); }