Esempio n. 1
0
        /// <summary>
        ///     Converts the specified module information.
        /// </summary>
        /// <param name="moduleInfo">The module information.</param>
        /// <returns>IModuleInfo.</returns>
        public IModuleInfo Convert(ClrMd.ModuleInfo moduleInfo)
        {
            if (moduleInfo == null)
            {
                return(null);
            }
            var item = new ModuleInfoAdapter(this, moduleInfo);

            return(Cache.GetOrAdd <IModuleInfo>(moduleInfo, () => item, () => item.Setup()));
        }
Esempio n. 2
0
        public IList<ModuleInfo> EnumerateModules()
        {
            if (m_modules != null)
                return m_modules;

            List<ModuleInfo> modules = new List<ModuleInfo>();

            foreach (var mod in m_dumpReader.EnumerateModules())
            {
                var raw = mod.Raw;

                ModuleInfo module = new ModuleInfo(this);
                module.FileName = mod.FullName;
                module.ImageBase = raw.BaseOfImage;
                module.FileSize = raw.SizeOfImage;
                module.TimeStamp = raw.TimeDateStamp;

                module.Version = GetVersionInfo(mod);
                modules.Add(module);
            }

            m_modules = modules;
            return modules;
        }
Esempio n. 3
0
#pragma warning disable 0618
        private ClrInfo[] InitVersions()
        {
            List <ClrInfo> versions = new List <ClrInfo>();

            foreach (ModuleInfo module in EnumerateModules())
            {
                string clrName = Path.GetFileNameWithoutExtension(module.FileName).ToLower();

                if (clrName != "clr" && clrName != "mscorwks" && clrName != "coreclr" && clrName != "mrt100_app" && clrName != "libcoreclr")
                {
                    continue;
                }

                ClrFlavor flavor;
                switch (clrName)
                {
                case "mrt100_app":
                    _native = module;
                    continue;

                case "libcoreclr":
                case "coreclr":
                    flavor = ClrFlavor.Core;
                    break;

                default:
                    flavor = ClrFlavor.Desktop;
                    break;
                }

                bool isLinux = clrName == "libcoreclr";

                const string LinuxDacFileName = "libmscordaccore.so";

                string dacLocation = Path.Combine(Path.GetDirectoryName(module.FileName), isLinux ? LinuxDacFileName : DacInfo.GetDacFileName(flavor, Architecture));

                if (isLinux)
                {
                    if (File.Exists(dacLocation))
                    {
                        // Works around issue https://github.com/dotnet/coreclr/issues/20205
                        int    processId     = Process.GetCurrentProcess().Id;
                        string tempDirectory = Path.Combine(Path.GetTempPath(), "clrmd" + processId.ToString());
                        Directory.CreateDirectory(tempDirectory);

                        string symlink = Path.Combine(tempDirectory, LinuxDacFileName);
                        if (LinuxFunctions.symlink(dacLocation, symlink) == 0)
                        {
                            dacLocation = symlink;
                        }
                    }
                    else
                    {
                        dacLocation = LinuxDacFileName;
                    }
                }
                else if (!File.Exists(dacLocation) || !PlatformFunctions.IsEqualFileVersion(dacLocation, module.Version))
                {
                    dacLocation = null;
                }

                VersionInfo version = module.Version;
                string      dacAgnosticName;
                string      dacFileName;
                if (isLinux)
                {
                    // Linux never has a "long" named DAC
                    dacAgnosticName = LinuxDacFileName;
                    dacFileName     = LinuxDacFileName;
                }
                else
                {
                    dacAgnosticName = DacInfo.GetDacRequestFileName(flavor, Architecture, Architecture, version);
                    dacFileName     = DacInfo.GetDacRequestFileName(flavor, IntPtr.Size == 4 ? Architecture.X86 : Architecture.Amd64, Architecture, version);
                }

                DacInfo dacInfo = new DacInfo(_dataReader, dacAgnosticName, Architecture)
                {
                    FileSize  = module.FileSize,
                    TimeStamp = module.TimeStamp,
                    FileName  = dacFileName,
                    Version   = module.Version
                };

                versions.Add(new ClrInfo(this, flavor, module, dacInfo, dacLocation));
            }

            ClrInfo[] result = versions.ToArray();
            Array.Sort(result);
            return(result);
        }
Esempio n. 4
0
#pragma warning disable 0618
        private ClrInfo[] InitVersions()
        {
            List <ClrInfo> versions = new List <ClrInfo>();

            foreach (ModuleInfo module in EnumerateModules())
            {
                string clrName = Path.GetFileNameWithoutExtension(module.FileName).ToLower();

                if (clrName != "clr" && clrName != "mscorwks" && clrName != "coreclr" && clrName != "mrt100_app" && clrName != "libcoreclr")
                {
                    continue;
                }

                ClrFlavor flavor;
                switch (clrName)
                {
                case "mrt100_app":
                    _native = module;
                    continue;

                case "libcoreclr":
                case "coreclr":
                    flavor = ClrFlavor.Core;
                    break;

                default:
                    flavor = ClrFlavor.Desktop;
                    break;
                }

                bool isLinux = clrName == "libcoreclr";

                string dacLocation = Path.Combine(Path.GetDirectoryName(module.FileName), DacInfo.GetDacFileName(flavor, Architecture));

                if (isLinux)
                {
                    dacLocation = Path.ChangeExtension(dacLocation, ".so");
                }

                if (isLinux)
                {
                    if (!File.Exists(dacLocation))
                    {
                        dacLocation = Path.GetFileName(dacLocation);
                    }
                }
                else if (!File.Exists(dacLocation) || !PlatformFunctions.IsEqualFileVersion(dacLocation, module.Version))
                {
                    dacLocation = null;
                }

                VersionInfo version         = module.Version;
                string      dacAgnosticName = DacInfo.GetDacRequestFileName(flavor, Architecture, Architecture, version);
                string      dacFileName     = DacInfo.GetDacRequestFileName(flavor, IntPtr.Size == 4 ? Architecture.X86 : Architecture.Amd64, Architecture, version);

                DacInfo dacInfo = new DacInfo(_dataReader, dacAgnosticName, Architecture)
                {
                    FileSize  = module.FileSize,
                    TimeStamp = module.TimeStamp,
                    FileName  = dacFileName,
                    Version   = module.Version
                };

                versions.Add(new ClrInfo(this, flavor, module, dacInfo, dacLocation));
            }

            var result = versions.ToArray();

            Array.Sort(result);
            return(result);
        }