コード例 #1
0
        /// <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)
        {
            Microsoft.Diagnostics.Runtime.Utilities.Pdb.PdbReader   pdbReader = module.ClrPdbReader;
            Microsoft.Diagnostics.Runtime.Utilities.Pdb.PdbFunction function  = pdbReader.GetFunctionFromToken(method.MetadataToken);
            uint ilOffset = FindIlOffset(method, address);

            ulong  distance       = ulong.MaxValue;
            string sourceFileName = "";
            uint   sourceFileLine = uint.MaxValue;

            foreach (Microsoft.Diagnostics.Runtime.Utilities.Pdb.PdbSequencePointCollection sequenceCollection in function.SequencePoints)
            {
                foreach (Microsoft.Diagnostics.Runtime.Utilities.Pdb.PdbSequencePoint point in sequenceCollection.Lines)
                {
                    if (point.Offset <= ilOffset)
                    {
                        ulong dist = ilOffset - point.Offset;

                        if (dist < distance)
                        {
                            sourceFileName = sequenceCollection.File.Name;
                            sourceFileLine = point.LineBegin;
                            distance       = dist;
                        }
                    }
                }
            }

            return(Tuple.Create(sourceFileName, sourceFileLine, distance));
        }
コード例 #2
0
ファイル: ClrMdRuntime.cs プロジェクト: wy182000/PadAnalyzer
        /// <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));
        }