From 2e4a0c0e9b8e245ba1034d9fc6f9088b13de9ffa Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Thu, 10 Jun 2021 19:10:42 -0700 Subject: [PATCH] Remove the CLRMD dependency from Microsoft.Diagnostics.DebugServices (#2303) Remove the CLRMD dependency from Microsoft.Diagnostics.DebugServices Add VersionData and PdbFileInfo classes. Fixed module dwTransientFlags for ENC --- .../Module.cs | 20 ++-- .../ModuleService.cs | 23 ++-- .../ModuleServiceFromDataReader.cs | 8 +- .../RuntimeService.cs | 8 +- .../Utilities.cs | 26 ++++- .../IModule.cs | 15 ++- ...Microsoft.Diagnostics.DebugServices.csproj | 1 - .../PdbFileInfo.cs | 41 +++++++ .../RegisterInfo.cs | 2 +- .../VersionData.cs | 102 ++++++++++++++++++ .../ClrModulesCommand.cs | 6 +- .../Host/ModulesCommand.cs | 4 +- .../ModuleServiceFromDebuggerServices.cs | 6 +- src/SOS/SOS.Hosting/RuntimeWrapper.cs | 8 +- src/SOS/SOS.Hosting/SOSHost.cs | 8 +- src/SOS/Strike/strike.cpp | 46 ++++++-- 16 files changed, 258 insertions(+), 66 deletions(-) create mode 100644 src/Microsoft.Diagnostics.DebugServices/PdbFileInfo.cs create mode 100644 src/Microsoft.Diagnostics.DebugServices/VersionData.cs diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs index 88d418c0e..09f68ca5d 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs @@ -34,9 +34,9 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation private readonly IDisposable _onChangeEvent; private Flags _flags; - private PdbInfo _pdbInfo; + private PdbFileInfo _pdbFileInfo; private ImmutableArray _buildId; - private VersionInfo? _version; + private VersionData _versionData; private PEImage _peImage; public readonly ServiceProvider ServiceProvider; @@ -118,12 +118,12 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation } } - public PdbInfo PdbInfo + public PdbFileInfo PdbFileInfo { get { GetPEInfo(); - return _pdbInfo; + return _pdbFileInfo; } } @@ -147,10 +147,10 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation } } - public virtual VersionInfo? Version + public virtual VersionData VersionData { - get { return _version; } - set { _version = value; } + get { return _versionData; } + set { _versionData = value; } } public abstract string VersionString { get; } @@ -162,7 +162,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation GetPEInfo(); // If we can't get the version from the PE, search for version string embedded in the module data - if (!_version.HasValue && !IsPEImage) + if (_versionData is null && !IsPEImage) { string versionString = VersionString; if (versionString != null) @@ -178,7 +178,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation try { Version version = System.Version.Parse(versionToParse); - _version = new VersionInfo(version.Major, version.Minor, version.Build, version.Revision); + _versionData = new VersionData(version.Major, version.Minor, version.Build, version.Revision); } catch (ArgumentException ex) { @@ -192,7 +192,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation protected PEImage GetPEInfo() { if (InitializeValue(Flags.InitializePEInfo)) { - _peImage = ModuleService.GetPEInfo(ImageBase, ImageSize, ref _pdbInfo, ref _version, ref _flags); + _peImage = ModuleService.GetPEInfo(ImageBase, ImageSize, ref _pdbFileInfo, ref _versionData, ref _flags); } return _peImage; } diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs index 8dc1c0be0..65772fc80 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime; using Microsoft.Diagnostics.Runtime.Utilities; using Microsoft.FileFormats; using Microsoft.FileFormats.ELF; @@ -203,11 +202,11 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation /// /// module base address /// module size - /// the pdb record or null - /// the PE version or null + /// the pdb record or null + /// the PE version or null /// module flags /// PEImage instance or null - internal PEImage GetPEInfo(ulong address, ulong size, ref PdbInfo pdbInfo, ref VersionInfo? version, ref Module.Flags flags) + internal PEImage GetPEInfo(ulong address, ulong size, ref PdbFileInfo pdbFileInfo, ref VersionData versionData, ref Module.Flags flags) { PEImage peImage = null; @@ -215,13 +214,13 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation if (Target.Host.HostType != HostType.Lldb) { // First try getting the PE info as load layout (native Windows DLLs and most managed PEs on Linux/MacOS). - peImage = GetPEInfo(isVirtual: true, address, size, ref pdbInfo, ref version, ref flags); + peImage = GetPEInfo(isVirtual: true, address, size, ref pdbFileInfo, ref versionData, ref flags); if (peImage == null) { if (Target.OperatingSystem != OSPlatform.Windows) { // Then try getting the PE info as file layout (some managed PEs on Linux/MacOS). - peImage = GetPEInfo(isVirtual: false, address, size, ref pdbInfo, ref version, ref flags); + peImage = GetPEInfo(isVirtual: false, address, size, ref pdbFileInfo, ref versionData, ref flags); } } } @@ -234,11 +233,11 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation /// the memory layout of the module /// module base address /// module size - /// the pdb record or null - /// the PE version or null + /// the pdb record or null + /// the PE version or null /// module flags /// PEImage instance or null - private PEImage GetPEInfo(bool isVirtual, ulong address, ulong size, ref PdbInfo pdbInfo, ref VersionInfo? version, ref Module.Flags flags) + private PEImage GetPEInfo(bool isVirtual, ulong address, ulong size, ref PdbFileInfo pdbFileInfo, ref VersionData versionData, ref Module.Flags flags) { Stream stream = MemoryService.CreateMemoryStream(address, size); try @@ -249,13 +248,13 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation { flags |= Module.Flags.IsPEImage; flags |= peImage.IsManaged ? Module.Flags.IsManaged : Module.Flags.None; - pdbInfo = peImage.DefaultPdb; - if (!version.HasValue) + pdbFileInfo = peImage.DefaultPdb.ToPdbFileInfo(); + if (versionData is null) { FileVersionInfo fileVersionInfo = peImage.GetFileVersionInfo(); if (fileVersionInfo != null) { - version = fileVersionInfo.VersionInfo; + versionData = fileVersionInfo.VersionInfo.ToVersionData(); } } flags &= ~(Module.Flags.IsLoadedLayout | Module.Flags.IsFileLayout); diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs index de0d8b27f..1ee7ae131 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs @@ -22,7 +22,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation // This is what clrmd returns for non-PE modules that don't have a timestamp private const uint InvalidTimeStamp = 0; - private static readonly VersionInfo EmptyVersionInfo = new VersionInfo(0, 0, 0, 0); + private static readonly Microsoft.Diagnostics.Runtime.VersionInfo EmptyVersionInfo = new (0, 0, 0, 0); private readonly ModuleServiceFromDataReader _moduleService; private readonly IExportReader _exportReader; private readonly ModuleInfo _moduleInfo; @@ -57,7 +57,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation public override uint? IndexTimeStamp => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : (uint)_moduleInfo.IndexTimeStamp; - public override VersionInfo? Version + public override VersionData VersionData { get { @@ -65,7 +65,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation { if (_moduleInfo.Version != EmptyVersionInfo) { - base.Version = _moduleInfo.Version; + base.VersionData = _moduleInfo.Version.ToVersionData(); } else { @@ -75,7 +75,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation } } } - return base.Version; + return base.VersionData; } } diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs index c54516c91..b5283be68 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs @@ -134,14 +134,14 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation return ImmutableArray.Empty; } - bool IDataReader.GetVersionInfo(ulong baseAddress, out VersionInfo version) + bool IDataReader.GetVersionInfo(ulong baseAddress, out Microsoft.Diagnostics.Runtime.VersionInfo version) { try { - VersionInfo? v = ModuleService.GetModuleFromBaseAddress(baseAddress).Version; - if (v.HasValue) + VersionData versionData = ModuleService.GetModuleFromBaseAddress(baseAddress).VersionData; + if (versionData is not null) { - version = v.Value; + version = versionData.ToVersionInfo(); return true; } } diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs index c1cc2618c..9c0035cdb 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs @@ -4,7 +4,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation { - public class Utilities + public static class Utilities { /// /// Combines two hash codes into a single hash code, in an order-dependent manner. @@ -23,5 +23,29 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation return hashCode0 ^ (hashCode1 + (int) 0x9e3779b9 + (hashCode0 << 6) + (hashCode0 >> 2)); } } + + /// + /// Convert from CLRMD VersionInfo to DebugServices VersionData + /// + public static VersionData ToVersionData(this Microsoft.Diagnostics.Runtime.VersionInfo versionInfo) + { + return new VersionData(versionInfo.Major, versionInfo.Minor, versionInfo.Revision, versionInfo.Patch); + } + + /// + /// Convert from DebugServices VersionData to CLRMD VersionInfo + /// + public static Microsoft.Diagnostics.Runtime.VersionInfo ToVersionInfo(this VersionData versionData) + { + return new Microsoft.Diagnostics.Runtime.VersionInfo(versionData.Major, versionData.Minor, versionData.Revision, versionData.Patch); + } + + /// + /// Convert from CLRMD PdbInfo to DebugServices PdbFileInfo + /// + public static PdbFileInfo ToPdbFileInfo(this Microsoft.Diagnostics.Runtime.PdbInfo pdbInfo) + { + return new PdbFileInfo(pdbInfo.Path, pdbInfo.Guid, pdbInfo.Revision); + } } } diff --git a/src/Microsoft.Diagnostics.DebugServices/IModule.cs b/src/Microsoft.Diagnostics.DebugServices/IModule.cs index 3f346e4d2..da9ce58c9 100644 --- a/src/Microsoft.Diagnostics.DebugServices/IModule.cs +++ b/src/Microsoft.Diagnostics.DebugServices/IModule.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime; using System; using System.Collections.Immutable; @@ -39,7 +38,7 @@ namespace Microsoft.Diagnostics.DebugServices ulong ImageBase { get; } /// - /// Returns the image size of module in memory + /// Returns the image size of module in memory. /// ulong ImageSize { get; } @@ -59,29 +58,29 @@ namespace Microsoft.Diagnostics.DebugServices ImmutableArray BuildId { get; } /// - /// Returns true if Windows PE format image (native or IL) + /// Returns true if Windows PE format image (native or IL). /// bool IsPEImage { get; } /// - /// Returns true if managed or IL assembly + /// Returns true if managed or IL assembly. /// bool IsManaged { get; } /// - /// Returns true if the PE module is layout is file. False, layout is loaded image. Null, not a PE image. + /// Returns true if the PE module is layout is file. False, layout is loaded image. If null, not a PE image. /// bool? IsFileLayout { get; } /// - /// PDB information for Windows PE modules (managed or native + /// PDB information for Windows PE modules (managed or native). /// - PdbInfo PdbInfo { get; } + PdbFileInfo PdbFileInfo { get; } /// /// Version information for Window PE modules (managed or native). /// - VersionInfo? Version { get; } + VersionData VersionData { get; } /// /// This is the file version string containing the build version and commit id. diff --git a/src/Microsoft.Diagnostics.DebugServices/Microsoft.Diagnostics.DebugServices.csproj b/src/Microsoft.Diagnostics.DebugServices/Microsoft.Diagnostics.DebugServices.csproj index 3c0a83d0b..08b9efdb0 100644 --- a/src/Microsoft.Diagnostics.DebugServices/Microsoft.Diagnostics.DebugServices.csproj +++ b/src/Microsoft.Diagnostics.DebugServices/Microsoft.Diagnostics.DebugServices.csproj @@ -14,7 +14,6 @@ - diff --git a/src/Microsoft.Diagnostics.DebugServices/PdbFileInfo.cs b/src/Microsoft.Diagnostics.DebugServices/PdbFileInfo.cs new file mode 100644 index 000000000..f538e05c7 --- /dev/null +++ b/src/Microsoft.Diagnostics.DebugServices/PdbFileInfo.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Microsoft.Diagnostics.DebugServices +{ + /// + /// Information about a specific PDB instance obtained from a PE image. + /// + public sealed class PdbFileInfo + { + /// + /// Gets the Guid of the PDB. + /// + public Guid Guid { get; } + + /// + /// Gets the PDB revision. + /// + public int Revision { get; } + + /// + /// Gets the path to the PDB. + /// + public string Path { get; } + + /// + /// Creates an instance of the PdbInfo with the corresponding properties initialized. + /// + public PdbFileInfo(string path, Guid guid, int revision) + { + Path = path; + Guid = guid; + Revision = revision; + } + + public override string ToString() => $"{Guid} {Revision} {Path}"; + } +} diff --git a/src/Microsoft.Diagnostics.DebugServices/RegisterInfo.cs b/src/Microsoft.Diagnostics.DebugServices/RegisterInfo.cs index a97b92ccb..b815a613b 100644 --- a/src/Microsoft.Diagnostics.DebugServices/RegisterInfo.cs +++ b/src/Microsoft.Diagnostics.DebugServices/RegisterInfo.cs @@ -7,7 +7,7 @@ namespace Microsoft.Diagnostics.DebugServices /// /// Details about a register /// - public struct RegisterInfo + public readonly struct RegisterInfo { public readonly int RegisterIndex; public readonly int RegisterOffset; diff --git a/src/Microsoft.Diagnostics.DebugServices/VersionData.cs b/src/Microsoft.Diagnostics.DebugServices/VersionData.cs new file mode 100644 index 000000000..5a2625d26 --- /dev/null +++ b/src/Microsoft.Diagnostics.DebugServices/VersionData.cs @@ -0,0 +1,102 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Microsoft.Diagnostics.DebugServices +{ + /// + /// Represents the version of a module + /// + public sealed class VersionData : IEquatable, IComparable + { + /// + /// In a version 'A.B.C.D', this field represents 'A'. + /// + public int Major { get; } + + /// + /// In a version 'A.B.C.D', this field represents 'B'. + /// + public int Minor { get; } + + /// + /// In a version 'A.B.C.D', this field represents 'C'. + /// + public int Revision { get; } + + /// + /// In a version 'A.B.C.D', this field represents 'D'. + /// + public int Patch { get; } + + public VersionData(int major, int minor, int revision, int patch) + { + if (major < 0) + throw new ArgumentOutOfRangeException(nameof(major)); + + if (minor < 0) + throw new ArgumentOutOfRangeException(nameof(minor)); + + if (revision < 0) + throw new ArgumentOutOfRangeException(nameof(revision)); + + if (patch < 0) + throw new ArgumentOutOfRangeException(nameof(patch)); + + Major = major; + Minor = minor; + Revision = revision; + Patch = patch; + } + + /// + public bool Equals(VersionData other) => Major == other.Major && Minor == other.Minor && Revision == other.Revision && Patch == other.Patch; + + /// + public override bool Equals(object obj) => obj is VersionData other && Equals(other); + + /// + public override int GetHashCode() + { + unchecked + { + int hashCode = Major; + hashCode = (hashCode * 397) ^ Minor; + hashCode = (hashCode * 397) ^ Revision; + hashCode = (hashCode * 397) ^ Patch; + return hashCode; + } + } + + /// + public int CompareTo(VersionData other) + { + if (Major != other.Major) + return Major.CompareTo(other.Major); + + if (Minor != other.Minor) + return Minor.CompareTo(other.Minor); + + if (Revision != other.Revision) + return Revision.CompareTo(other.Revision); + + return Patch.CompareTo(other.Patch); + } + + public override string ToString() => $"{Major}.{Minor}.{Revision}.{Patch}"; + + public static bool operator ==(VersionData left, VersionData right) => left.Equals(right); + + public static bool operator !=(VersionData left, VersionData right) => !(left == right); + + public static bool operator <(VersionData left, VersionData right) => left.CompareTo(right) < 0; + + public static bool operator <=(VersionData left, VersionData right) => left.CompareTo(right) <= 0; + + public static bool operator >(VersionData left, VersionData right) => right < left; + + public static bool operator >=(VersionData left, VersionData right) => right <= left; + } +} \ No newline at end of file diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs index 20c7dc879..ed5547f60 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs @@ -4,8 +4,6 @@ using Microsoft.Diagnostics.DebugServices; using Microsoft.Diagnostics.Runtime; -using System; -using System.Linq; namespace Microsoft.Diagnostics.ExtensionCommands { @@ -40,10 +38,10 @@ namespace Microsoft.Diagnostics.ExtensionCommands WriteLine(" MetadataAddress: {0:X16}", module.MetadataAddress); WriteLine(" MetadataSize: {0:X16}", module.MetadataLength); WriteLine(" PdbInfo: {0}", module.Pdb?.ToString() ?? ""); - VersionInfo? version = null; + VersionData version = null; try { - version = ModuleService.GetModuleFromBaseAddress(module.ImageBase).Version; + version = ModuleService.GetModuleFromBaseAddress(module.ImageBase).VersionData; } catch (DiagnosticsException) { diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs index 3b1473673..87c39f69d 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs @@ -32,12 +32,12 @@ namespace Microsoft.Diagnostics.ExtensionCommands WriteLine(" IsFileLayout: {0}", module.IsFileLayout?.ToString() ?? ""); WriteLine(" IndexFileSize: {0}", module.IndexFileSize?.ToString("X8") ?? ""); WriteLine(" IndexTimeStamp: {0}", module.IndexTimeStamp?.ToString("X8") ?? ""); - WriteLine(" Version: {0}", module.Version?.ToString() ?? ""); + WriteLine(" Version: {0}", module.VersionData?.ToString() ?? ""); string versionString = module.VersionString; if (!string.IsNullOrEmpty(versionString)) { WriteLine(" {0}", versionString); } - WriteLine(" PdbInfo: {0}", module.PdbInfo?.ToString() ?? ""); + WriteLine(" PdbInfo: {0}", module.PdbFileInfo?.ToString() ?? ""); WriteLine(" BuildId: {0}", !module.BuildId.IsDefaultOrEmpty ? string.Concat(module.BuildId.Select((b) => b.ToString("x2"))) : ""); } else diff --git a/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs b/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs index ef9109400..f3bc44177 100644 --- a/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs +++ b/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs @@ -64,7 +64,7 @@ namespace SOS.Extensions public override uint? IndexTimeStamp { get; } - public override VersionInfo? Version + public override VersionData VersionData { get { @@ -77,7 +77,7 @@ namespace SOS.Extensions int minor = (int)fileInfo.dwFileVersionMS & 0xffff; int revision = (int)fileInfo.dwFileVersionLS >> 16; int patch = (int)fileInfo.dwFileVersionLS & 0xffff; - base.Version = new VersionInfo(major, minor, revision, patch); + base.VersionData = new VersionData(major, minor, revision, patch); } else { @@ -87,7 +87,7 @@ namespace SOS.Extensions } } } - return base.Version; + return base.VersionData; } } diff --git a/src/SOS/SOS.Hosting/RuntimeWrapper.cs b/src/SOS/SOS.Hosting/RuntimeWrapper.cs index 87f9b31d2..76d1ee956 100644 --- a/src/SOS/SOS.Hosting/RuntimeWrapper.cs +++ b/src/SOS/SOS.Hosting/RuntimeWrapper.cs @@ -252,7 +252,7 @@ namespace SOS.Hosting { return HResult.E_FAIL; } - if (!module.Version.HasValue) + if (module.VersionData is null) { return HResult.E_FAIL; } @@ -261,9 +261,9 @@ namespace SOS.Hosting pFileInfo->dwFileFlagsMask = 0; pFileInfo->dwFileFlags = 0; - VersionInfo versionInfo = module.Version.Value; - pFileInfo->dwFileVersionMS = (uint)versionInfo.Minor | (uint)versionInfo.Major << 16; - pFileInfo->dwFileVersionLS = (uint)versionInfo.Patch | (uint)versionInfo.Revision << 16; + VersionData versionData = module.VersionData; + pFileInfo->dwFileVersionMS = (uint)versionData.Minor | (uint)versionData.Major << 16; + pFileInfo->dwFileVersionLS = (uint)versionData.Patch | (uint)versionData.Revision << 16; // Attempt to get the FileVersion string that contains version and the "built by" and commit id info if (fileVersionBuffer != null) diff --git a/src/SOS/SOS.Hosting/SOSHost.cs b/src/SOS/SOS.Hosting/SOSHost.cs index 5189d5858..be78691cd 100644 --- a/src/SOS/SOS.Hosting/SOSHost.cs +++ b/src/SOS/SOS.Hosting/SOSHost.cs @@ -479,7 +479,7 @@ namespace SOS.Hosting { return HResult.E_INVALIDARG; } - if (!module.Version.HasValue) + if (module.VersionData is null) { return HResult.E_FAIL; } @@ -489,9 +489,9 @@ namespace SOS.Hosting fileInfo->dwFileFlagsMask = 0; fileInfo->dwFileFlags = 0; - VersionInfo versionInfo = module.Version.Value; - fileInfo->dwFileVersionMS = (uint)versionInfo.Minor | (uint)versionInfo.Major << 16; - fileInfo->dwFileVersionLS = (uint)versionInfo.Patch | (uint)versionInfo.Revision << 16; + VersionData versionData = module.VersionData; + fileInfo->dwFileVersionMS = (uint)versionData.Minor | (uint)versionData.Major << 16; + fileInfo->dwFileVersionLS = (uint)versionData.Patch | (uint)versionData.Revision << 16; } else if (item == "\\StringFileInfo\\040904B0\\FileVersion") { diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index 3ccf76e03..65f3a980a 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -6169,13 +6169,40 @@ enum { // These are the values set in m_dwTransientFlags. // Note that none of these flags survive a prejit save/restore. - M_CRST_NOTINITIALIZED = 0x00000001, // Used to prevent destruction of garbage m_crst - M_LOOKUPCRST_NOTINITIALIZED = 0x00000002, + MODULE_IS_TENURED = 0x00000001, // Set once we know for sure the Module will not be freed until the appdomain itself exits + // unused = 0x00000002, + CLASSES_FREED = 0x00000004, + IS_EDIT_AND_CONTINUE = 0x00000008, // is EnC Enabled for this module - SUPPORTS_UPDATEABLE_METHODS = 0x00000020, - CLASSES_FREED = 0x00000040, - HAS_PHONY_IL_RVAS = 0x00000080, - IS_EDIT_AND_CONTINUE = 0x00000200, + IS_PROFILER_NOTIFIED = 0x00000010, + IS_ETW_NOTIFIED = 0x00000020, + + // + // Note: the order of these must match the order defined in + // cordbpriv.h for DebuggerAssemblyControlFlags. The three + // values below should match the values defined in + // DebuggerAssemblyControlFlags when shifted right + // DEBUGGER_INFO_SHIFT bits. + // + DEBUGGER_USER_OVERRIDE_PRIV = 0x00000400, + DEBUGGER_ALLOW_JIT_OPTS_PRIV= 0x00000800, + DEBUGGER_TRACK_JIT_INFO_PRIV= 0x00001000, + DEBUGGER_ENC_ENABLED_PRIV = 0x00002000, // this is what was attempted to be set. IS_EDIT_AND_CONTINUE is actual result. + DEBUGGER_PDBS_COPIED = 0x00004000, + DEBUGGER_IGNORE_PDBS = 0x00008000, + DEBUGGER_INFO_MASK_PRIV = 0x0000Fc00, + DEBUGGER_INFO_SHIFT_PRIV = 10, + + // Used to indicate that this module has had it's IJW fixups properly installed. + IS_IJW_FIXED_UP = 0x00080000, + IS_BEING_UNLOADED = 0x00100000, + + // Used to indicate that the module is loaded sufficiently for generic candidate instantiations to work + MODULE_READY_FOR_TYPELOAD = 0x00200000, + + // Used during NGen only + TYPESPECS_TRIAGED = 0x40000000, + MODULE_SAVED = 0x80000000, }; void ModuleMapTraverse(UINT index, CLRDATA_ADDRESS methodTable, LPVOID token) @@ -6245,8 +6272,6 @@ DECLARE_API(DumpModule) ExtOut("PEFile "); if (module.bIsReflection) ExtOut("Reflection "); - if (module.dwTransientFlags & SUPPORTS_UPDATEABLE_METHODS) - ExtOut("SupportsUpdateableMethods "); ToRelease dataModule; if (SUCCEEDED(g_sos->GetModule(TO_CDADDR(p_ModuleAddr), &dataModule))) @@ -6264,6 +6289,11 @@ DECLARE_API(DumpModule) } ExtOut("\n"); + ExtOut("TransientFlags: %08x ", module.dwTransientFlags); + if (module.dwTransientFlags & IS_EDIT_AND_CONTINUE) + ExtOut("IS_EDIT_AND_CONTINUE"); + ExtOut("\n"); + DMLOut("Assembly: %s\n", DMLAssembly(module.Assembly)); ExtOut("BaseAddress: %p\n", SOS_PTR(module.ilBase)); -- 2.34.1