Пример #1
0
 private static void AssertModuleDoesntContainDomains(Module module, params AppDomain[] domainList)
 {
     foreach (AppDomain domain in domainList)
         Assert.IsFalse(domain.Modules.Contains(module));
 }
Пример #2
0
        /// <summary>
        /// Reads the CLR source file name, line number and displacement.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="method">The method.</param>
        /// <param name="address">The address.</param>
        internal static Tuple<string, uint, ulong> ReadClrSourceFileNameAndLine(Module 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 = StackFrame.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);
        }
Пример #3
0
 private static void AssertModuleContainsDomains(Module module, params AppDomain[] domainList)
 {
     foreach (AppDomain domain in domainList)
         Assert.IsTrue(domain.Modules.Contains(module));
     Assert.AreEqual(domainList.Length, domainList[0].Runtime.AllAppDomains.Count(ad => ad.Modules.Contains(module)));
 }
Пример #4
0
        /// <summary>
        /// Reads the CLR function name and displacement.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="method">The method.</param>
        /// <param name="address">The address.</param>
        internal static Tuple<string, ulong> ReadClrFunctionNameAndDisplacement(Module module, Microsoft.Diagnostics.Runtime.ClrMethod method, ulong address)
        {
            string moduleName = module?.Name ?? "???";
            string functionName = moduleName + "!" + method;
            ulong displacement = address - method.NativeCode;

            return Tuple.Create(functionName, displacement);
        }