// Create a DebugLocInfo which is a table from native offset to sourece line. // using native to il offset (pMap) and il to source line (_sequencePoints). private void setBoundaries(IntPtr _this, CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping* pMap) { Debug.Assert(_debugLocInfos == null); // No interest if sequencePoints is not populated before. if (_sequencePoints == null) { return; } List<DebugLocInfo> debugLocInfos = new List<DebugLocInfo>(); for (int i = 0; i < cMap; i++) { SequencePoint s; if (_sequencePoints.TryGetValue((int)pMap[i].ilOffset, out s)) { Debug.Assert(!string.IsNullOrEmpty(s.Document)); int nativeOffset = (int)pMap[i].nativeOffset; DebugLocInfo loc = new DebugLocInfo(nativeOffset, s.Document, s.LineNumber); // https://github.com/dotnet/corert/issues/270 // We often miss line number at 0 offset, which prevents debugger from // stepping into callee. // Synthesize a location info at 0 offset assuming line number is minus one // from the first entry. if (debugLocInfos.Count == 0 && nativeOffset != 0) { DebugLocInfo firstLoc = loc; firstLoc.NativeOffset = 0; firstLoc.LineNumber--; debugLocInfos.Add(firstLoc); } debugLocInfos.Add(loc); } } if (debugLocInfos.Count > 0) { _debugLocInfos = debugLocInfos.ToArray(); } }
// Create a DebugLocInfo which is a table from native offset to source line. // using native to il offset (pMap) and il to source line (_sequencePoints). private void setBoundaries(CORINFO_METHOD_STRUCT_* ftn, uint cMap, OffsetMapping* pMap) { Debug.Assert(_debugLocInfos == null); // No interest if sequencePoints is not populated before. if (_sequencePoints == null) { return; } int largestILOffset = 0; // All epiloges point to the largest IL offset. for (int i = 0; i < cMap; i++) { OffsetMapping nativeToILInfo = pMap[i]; int currectILOffset = (int)nativeToILInfo.ilOffset; if (currectILOffset > largestILOffset) // Special offsets are negative. { largestILOffset = currectILOffset; } } int previousNativeOffset = -1; List<DebugLocInfo> debugLocInfos = new List<DebugLocInfo>(); for (int i = 0; i < cMap; i++) { OffsetMapping nativeToILInfo = pMap[i]; int ilOffset = (int)nativeToILInfo.ilOffset; int nativeOffset = (int)pMap[i].nativeOffset; if (nativeOffset == previousNativeOffset) { // Save the first one, skip others. continue; } switch (ilOffset) { case (int)MappingTypes.PROLOG: ilOffset = 0; break; case (int)MappingTypes.EPILOG: ilOffset = largestILOffset; break; case (int)MappingTypes.NO_MAPPING: continue; } SequencePoint s; if (_sequencePoints.TryGetValue((int)ilOffset, out s)) { Debug.Assert(!string.IsNullOrEmpty(s.Document)); DebugLocInfo loc = new DebugLocInfo(nativeOffset, s.Document, s.LineNumber); debugLocInfos.Add(loc); previousNativeOffset = nativeOffset; } } if (debugLocInfos.Count > 0) { _debugLocInfos = debugLocInfos.ToArray(); } }