public int FindClosestLine(int line) { int closestLine = 0; m_unmanagedDocument.FindClosestLine(line, out closestLine); return(closestLine); }
public int FindClosestLine(int line) { uint result; document.FindClosestLine((uint)line, out result); return((int)result); }
public int FindClosestLine(int line) { int value; HRESULT.ThrowOnFailure(_unmanaged.FindClosestLine(line, out value)); return(value); }
public static int[] FindClosestLineForEachLine(ISymUnmanagedDocument document, int minLine, int maxLine) { Assert.True(minLine >= 1); Assert.True(maxLine >= minLine); var result = new List <int>(); for (int line = minLine; line <= maxLine; line++) { int closestLine; int hr = document.FindClosestLine(line, out closestLine); if (hr != HResult.S_OK) { Assert.Equal(HResult.E_FAIL, hr); closestLine = 0; } result.Add(closestLine); } return(result.ToArray()); }
public static int[] FindClosestLineForEachLine(ISymUnmanagedDocument document, int minLine, int maxLine) { Assert.True(minLine >= 1); Assert.True(maxLine >= minLine); var result = new List<int>(); for (int line = minLine; line <= maxLine; line++) { int closestLine; int hr = document.FindClosestLine(line, out closestLine); if (hr != HResult.S_OK) { Assert.Equal(HResult.E_FAIL, hr); closestLine = 0; } result.Add(closestLine); } return result.ToArray(); }
public static SourcecodeSegment Resolve(Module module, string fileName, byte[] checkSum, int line, int column) { // Do not use ISymUnmanagedReader.GetDocument! It is broken if two files have the same name // Do not use ISymUnmanagedMethod.GetOffset! It sometimes returns negative offset ISymUnmanagedReader symReader = module.SymReader; if (symReader == null) { return(null); // No symbols } ISymUnmanagedDocument symDoc = GetSymDocumentFromFilename(module, fileName, checkSum); if (symDoc == null) { return(null); // Document not found } ISymUnmanagedMethod symMethod; try { uint validLine = symDoc.FindClosestLine((uint)line); symMethod = symReader.GetMethodFromDocumentPosition(symDoc, (uint)validLine, (uint)column); } catch { return(null); //Not found } SequencePoint[] seqPoints = symMethod.GetSequencePoints(); Array.Sort(seqPoints); if (seqPoints.Length == 0) { return(null); } if (line < seqPoints[0].Line) { return(null); } foreach (SequencePoint sqPoint in seqPoints) { if (sqPoint.Line == 0xFEEFEE) { continue; } // If the desired breakpoint position is before the end of the sequence point if (line < sqPoint.EndLine || (line == sqPoint.EndLine && column < sqPoint.EndColumn)) { SourcecodeSegment segment = new SourcecodeSegment(); segment.module = module; segment.filename = symDoc.GetURL(); segment.checkSum = symDoc.GetCheckSum(); segment.startLine = (int)sqPoint.Line; segment.startColumn = (int)sqPoint.Column; segment.endLine = (int)sqPoint.EndLine; segment.endColumn = (int)sqPoint.EndColumn; segment.corFunction = module.CorModule.GetFunctionFromToken(symMethod.GetToken()); segment.ilStart = (int)sqPoint.Offset; segment.ilEnd = (int)sqPoint.Offset; segment.stepRanges = null; return(segment); } } return(null); }
// Returns true if found internal bool GetFunctionAndOffset(Module module, bool normailize, out ICorDebugFunction function, out int ilOffset) { function = null; ilOffset = 0; ISymUnmanagedReader symReader = module.SymReader; if (symReader == null) { return(false); // No symbols } ISymUnmanagedDocument symDoc = null; symDoc = symReader.GetDocument(SourceFullFilename, Guid.Empty, Guid.Empty, Guid.Empty); if (symDoc == null) { return(false); // Does not use source file } uint validLine; try { validLine = symDoc.FindClosestLine((uint)StartLine); } catch { return(false); // Not on a vaild point } if (validLine != StartLine && normailize) { StartLine = (int)validLine; EndLine = (int)validLine; StartColumn = 0; EndColumn = 0; } ISymUnmanagedMethod symMethod; try { symMethod = symReader.GetMethodFromDocumentPosition(symDoc, validLine, 0); } catch { return(false); //Not found } // Check that StartLine is within the method uint start = uint.MaxValue; uint end = uint.MinValue; foreach (SequencePoint sqPoint in symMethod.SequencePoints) { if (sqPoint.Line == 0xFEEFEE) { continue; } start = Math.Min(start, sqPoint.Line); end = Math.Max(end, sqPoint.EndLine); } if (StartLine < start || StartLine > end) { return(false); } function = module.CorModule.GetFunctionFromToken(symMethod.Token); ilOffset = (int)symMethod.GetOffset(symDoc, validLine, 0); return(true); }