/// <summary> /// Reads the name of the source file, line and displacement of the specified code address. /// </summary> /// <param name="address">The code address</param> public Tuple <string, uint, ulong> ReadSourceFileNameAndLine(ulong address) { Microsoft.Diagnostics.Runtime.ClrMethod method = ClrRuntime.GetMethodByAddress(address); ClrMdModule clrModule = Provider.FromClrModule(method.Type.Module); return(ClrMdStackFrame.ReadSourceFileNameAndLine(clrModule, method, address)); }
/// <summary> /// Reads the name of the source file, line and displacement. /// </summary> /// <param name="module">The module.</param> /// <param name="method">The CLR method.</param> /// <param name="address">The address.</param> internal static Tuple <string, uint, ulong> ReadSourceFileNameAndLine(ClrMdModule module, Microsoft.Diagnostics.Runtime.ClrMethod method, ulong address) { IPdbFile pdbReader = module.ClrPdbReader; IPdbFunction function = pdbReader.GetFunctionFromToken((int)method.MetadataToken); uint ilOffset = FindIlOffset(method, address); ulong distance = ulong.MaxValue; string sourceFileName = ""; uint sourceFileLine = uint.MaxValue; foreach (IPdbSequencePoint point in function.SequencePoints) { if (point.Offset <= ilOffset) { ulong dist = (ulong)(ilOffset - point.Offset); if (dist < distance) { sourceFileName = point.Source.Name; sourceFileLine = (uint)point.StartLine; distance = dist; } } } return(Tuple.Create(sourceFileName, sourceFileLine, distance)); }