private ClrRuntime ConstructRuntime(string dac) { if (IntPtr.Size != (int)_dataTarget.DataReader.GetPointerSize()) { throw new InvalidOperationException("Mismatched architecture between this process and the dac."); } DacLibrary lib = new DacLibrary(_dataTarget, dac); Desktop.DesktopVersion ver; if (Flavor == ClrFlavor.CoreCLR) { return(new Desktop.V45Runtime(this, _dataTarget, lib)); } else if (Flavor == ClrFlavor.Native) { return(new Native.NativeRuntime(this, _dataTarget, lib)); } else if (Version.Major == 2) { ver = Desktop.DesktopVersion.v2; } else if (Version.Major == 4 && Version.Minor == 0 && Version.Patch < 10000) { ver = Desktop.DesktopVersion.v4; } else { // Assume future versions will all work on the newest runtime version. return(new Desktop.V45Runtime(this, _dataTarget, lib)); } return(new Desktop.LegacyRuntime(this, _dataTarget, lib, ver, Version.Patch)); }
public RuntimeBase(ClrInfo info, DataTargetImpl dataTarget, DacLibrary lib) { Debug.Assert(lib != null); Debug.Assert(lib.DacInterface != null); ClrInfo = info; _dataTarget = dataTarget; _library = lib; _dacInterface = _library.DacInterface; InitApi(); _dacInterface.Flush(); IGCInfo data = GetGCInfo(); if (data == null) { throw new ClrDiagnosticsException("This runtime is not initialized and contains no data.", ClrDiagnosticsException.HR.RuntimeUninitialized); } ServerGC = data.ServerMode; HeapCount = data.HeapCount; CanWalkHeap = data.GCStructuresValid && !dataTarget.DataReader.IsMinidump; _dataReader = dataTarget.DataReader; }
#pragma warning disable 0618 private ClrRuntime ConstructRuntime(string dac) { if (IntPtr.Size != (int)_dataTarget.DataReader.GetPointerSize()) { throw new InvalidOperationException("Mismatched architecture between this process and the dac."); } if (_dataTarget.IsMinidump) { _dataTarget.SymbolLocator.PrefetchBinary(ModuleInfo.FileName, (int)ModuleInfo.TimeStamp, (int)ModuleInfo.FileSize); } DacLibrary lib = new DacLibrary(_dataTarget, dac); Desktop.DesktopVersion ver; if (Flavor == ClrFlavor.Core) { return(new Desktop.V45Runtime(this, _dataTarget, lib)); } else if (Version.Major == 2) { ver = Desktop.DesktopVersion.v2; } else if (Version.Major == 4 && Version.Minor == 0 && Version.Patch < 10000) { ver = Desktop.DesktopVersion.v4; } else { // Assume future versions will all work on the newest runtime version. return(new Desktop.V45Runtime(this, _dataTarget, lib)); } return(new Desktop.LegacyRuntime(this, _dataTarget, lib, ver, Version.Patch)); }
#pragma warning disable CA2000 // Dispose objects before losing scope private ClrRuntime ConstructRuntime(string dac) { if (IntPtr.Size != DataTarget.DataReader.PointerSize) { throw new InvalidOperationException("Mismatched architecture between this process and the dac."); } DacLibrary dacLibrary = new DacLibrary(DataTarget, dac); DacInterface.SOSDac?sos = dacLibrary.SOSDacInterface; if (sos is null) { throw new InvalidOperationException($"Could not create a ISOSDac pointer from this dac library: {dac}"); } var factory = new RuntimeBuilder(this, dacLibrary, sos); if (Flavor == ClrFlavor.Core) { return(factory.GetOrCreateRuntime()); } if (Version.Major < 4 || (Version.Major == 4 && Version.Minor == 5 && Version.Patch < 10000)) { throw new NotSupportedException($"CLR version '{Version}' is not supported by ClrMD. For Desktop CLR, only CLR 4.6 and beyond are supported."); } return(factory.GetOrCreateRuntime()); }
public override ClrRuntime CreateRuntime(string dacFilename) { if (IntPtr.Size != (int)_dataReader.GetPointerSize()) { throw new InvalidOperationException("Mismatched architecture between this process and the dac."); } if (string.IsNullOrEmpty(dacFilename)) { throw new ArgumentNullException("dacFilename"); } if (!File.Exists(dacFilename)) { throw new FileNotFoundException(dacFilename); } DacLibrary lib = new DacLibrary(this, dacFilename); // TODO: There has to be a better way to determine this is coreclr. string dacFileNoExt = Path.GetFileNameWithoutExtension(dacFilename).ToLower(); bool isCoreClr = dacFileNoExt.Contains("mscordaccore"); bool isNative = dacFileNoExt.Contains("mrt100dac"); int major, minor, revision, patch; bool res = NativeMethods.GetFileVersion(dacFilename, out major, out minor, out revision, out patch); DesktopVersion ver; if (isCoreClr) { return(new V45Runtime(this, lib)); } else if (isNative) { return(new Native.NativeRuntime(this, lib)); } else if (major == 2) { ver = DesktopVersion.v2; } else if (major == 4 && minor == 0 && patch < 10000) { ver = DesktopVersion.v4; } else { // Assume future versions will all work on the newest runtime version. return(new V45Runtime(this, lib)); } return(new LegacyRuntime(this, lib, ver, patch)); }
public LegacyRuntime(DataTargetImpl dt, DacLibrary lib, DesktopVersion version, int minor) : base(dt, lib) { _version = version; _minor = minor; if (!GetCommonMethodTables(ref _commonMTs)) throw new ClrDiagnosticsException("Could not request common MethodTable list.", ClrDiagnosticsException.HR.DacError); // Ensure the version of the dac API matches the one we expect. (Same for both // v2 and v4 rtm.) byte[] tmp = new byte[sizeof(int)]; if (!Request(DacRequests.VERSION, null, tmp)) throw new ClrDiagnosticsException("Failed to request dac version.", ClrDiagnosticsException.HR.DacError); int v = BitConverter.ToInt32(tmp, 0); if (v != 8) throw new ClrDiagnosticsException("Unsupported dac version.", ClrDiagnosticsException.HR.DacError); }
public RuntimeBase(ClrInfo info, DataTargetImpl dataTarget, DacLibrary lib) { Debug.Assert(lib != null); Debug.Assert(lib.DacInterface != null); ClrInfo = info; _dataTarget = dataTarget; _library = lib; _dacInterface = _library.DacInterface; InitApi(); _dacInterface.Flush(); IGCInfo data = GetGCInfo(); if (data != null) { ServerGC = data.ServerMode; HeapCount = data.HeapCount; CanWalkHeap = data.GCStructuresValid; } _dataReader = dataTarget.DataReader; }
public override ClrRuntime CreateRuntime(object clrDataProcess) { DacLibrary lib = new DacLibrary(this, (IXCLRDataProcess)clrDataProcess); // Figure out what version we are on. if (clrDataProcess is ISOSDac) { return(new V45Runtime(this, lib)); } else { byte[] buffer = new byte[Marshal.SizeOf(typeof(V2HeapDetails))]; int val = lib.DacInterface.Request(DacRequests.GCHEAPDETAILS_STATIC_DATA, 0, null, (uint)buffer.Length, buffer); if ((uint)val == (uint)0x80070057) { return(new LegacyRuntime(this, lib, DesktopVersion.v4, 10000)); } else { return(new LegacyRuntime(this, lib, DesktopVersion.v2, 3054)); } } }
/// <summary> /// Creates a runtime from a given IXClrDataProcess interface. Used for debugger plugins. /// </summary> public ClrRuntime CreateRuntime(object clrDataProcess) { DacLibrary lib = new DacLibrary(_dataTarget, DacLibrary.TryGetDacPtr(clrDataProcess)); // Figure out what version we are on. if (lib.GetSOSInterfaceNoAddRef() != null) { return(new V45Runtime(this, _dataTarget, lib)); } else { byte[] buffer = new byte[Marshal.SizeOf(typeof(V2HeapDetails))]; int val = lib.InternalDacPrivateInterface.Request(DacRequests.GCHEAPDETAILS_STATIC_DATA, 0, null, (uint)buffer.Length, buffer); if ((uint)val == 0x80070057) { return(new LegacyRuntime(this, _dataTarget, lib, Desktop.DesktopVersion.v4, 10000)); } else { return(new LegacyRuntime(this, _dataTarget, lib, Desktop.DesktopVersion.v2, 3054)); } } }
public override ClrRuntime CreateRuntime(string dacFilename) { if (IntPtr.Size != (int)_dataReader.GetPointerSize()) throw new InvalidOperationException("Mismatched architecture between this process and the dac."); if (string.IsNullOrEmpty(dacFilename)) throw new ArgumentNullException("dacFilename"); if (!File.Exists(dacFilename)) throw new FileNotFoundException(dacFilename); DacLibrary lib = new DacLibrary(this, dacFilename); // TODO: There has to be a better way to determine this is coreclr. string dacFileNoExt = Path.GetFileNameWithoutExtension(dacFilename).ToLower(); bool isCoreClr = dacFileNoExt.Contains("mscordaccore"); bool isNative = dacFileNoExt.Contains("mrt100dac"); int major, minor, revision, patch; bool res = NativeMethods.GetFileVersion(dacFilename, out major, out minor, out revision, out patch); DesktopVersion ver; if (isCoreClr) { return new V45Runtime(null, this, lib); } else if (isNative) { return new Native.NativeRuntime(null, this, lib); } else if (major == 2) { ver = DesktopVersion.v2; } else if (major == 4 && minor == 0 && patch < 10000) { ver = DesktopVersion.v4; } else { // Assume future versions will all work on the newest runtime version. return new V45Runtime(null, this, lib); } return new LegacyRuntime(null, this, lib, ver, patch); }
public override ClrRuntime CreateRuntime(string dacFilename) { if (IntPtr.Size != (int)m_dataReader.GetPointerSize()) throw new InvalidOperationException("Mismatched architecture between this process and the dac."); if (string.IsNullOrEmpty(dacFilename)) throw new ArgumentNullException("dacFilename"); if (!File.Exists(dacFilename)) throw new FileNotFoundException(dacFilename); DacLibrary lib = new DacLibrary(this, dacFilename); // TODO: There has to be a better way to determine this is coreclr. string dacFileNoExt = Path.GetFileNameWithoutExtension(dacFilename).ToLower(); bool isCoreClr = dacFileNoExt.Contains("mscordaccore"); #if _REDHAWK bool isRedhawk = dacFileNoExt.Contains("mrt100"); #endif int major, minor, revision, patch; bool res = NativeMethods.GetFileVersion(dacFilename, out major, out minor, out revision, out patch); string version = string.Format("v{0}.{1}.{2}.{3}", major, minor, revision, patch); DesktopVersion ver; if (isCoreClr) { return new V45Runtime(this, lib); } #if _REDHAWK else if (isRedhawk) { return new Redhawk.RhRuntime(this, lib); } #endif else if (major == 2) { ver = DesktopVersion.v2; } else if (major == 4) { if (patch < 10000) ver = DesktopVersion.v4; else return new V45Runtime(this, lib); } else { throw new ClrDiagnosticsException("Unsupported runtime: " + version); } return new LegacyRuntime(this, lib, ver, patch); }
protected internal override void AddDacLibrary(DacLibrary dacLibrary) { _dacLibraries.Add(dacLibrary); }
private ClrRuntime ConstructRuntime(string dac) { if (IntPtr.Size != (int)_dataTarget.DataReader.GetPointerSize()) throw new InvalidOperationException("Mismatched architecture between this process and the dac."); if (_dataTarget.IsMinidump) _dataTarget.SymbolLocator.PrefetchBinary(ModuleInfo.FileName, (int)ModuleInfo.TimeStamp, (int)ModuleInfo.FileSize); DacLibrary lib = new DacLibrary(_dataTarget, dac); Desktop.DesktopVersion ver; if (Flavor == ClrFlavor.CoreCLR) { return new Desktop.V45Runtime(this, _dataTarget, lib); } else if (Flavor == ClrFlavor.Native) { return new Native.NativeRuntime(this, _dataTarget, lib); } else if (Version.Major == 2) { ver = Desktop.DesktopVersion.v2; } else if (Version.Major == 4 && Version.Minor == 0 && Version.Patch < 10000) { ver = Desktop.DesktopVersion.v4; } else { // Assume future versions will all work on the newest runtime version. return new Desktop.V45Runtime(this, _dataTarget, lib); } return new Desktop.LegacyRuntime(this, _dataTarget, lib, ver, Version.Patch); }
internal abstract void AddDacLibrary(DacLibrary dacLibrary);
public override ClrRuntime CreateRuntime(object clrDataProcess) { DacLibrary lib = new DacLibrary(this, (IXCLRDataProcess)clrDataProcess); // Figure out what version we are on. if (clrDataProcess is ISOSDac) { return new V45Runtime(null, this, lib); } else { byte[] buffer = new byte[Marshal.SizeOf(typeof(V2HeapDetails))]; int val = lib.DacInterface.Request(DacRequests.GCHEAPDETAILS_STATIC_DATA, 0, null, (uint)buffer.Length, buffer); if ((uint)val == (uint)0x80070057) return new LegacyRuntime(null, this, lib, DesktopVersion.v4, 10000); else return new LegacyRuntime(null, this, lib, DesktopVersion.v2, 3054); } }
public override ClrRuntime CreateRuntime(string dacFilename) { if (IntPtr.Size != (int)m_dataReader.GetPointerSize()) { throw new InvalidOperationException("Mismatched architecture between this process and the dac."); } if (string.IsNullOrEmpty(dacFilename)) { throw new ArgumentNullException("dacFilename"); } if (!File.Exists(dacFilename)) { throw new FileNotFoundException(dacFilename); } DacLibrary lib = new DacLibrary(this, dacFilename); // TODO: There has to be a better way to determine this is coreclr. string dacFileNoExt = Path.GetFileNameWithoutExtension(dacFilename).ToLower(); bool isCoreClr = dacFileNoExt.Contains("mscordaccore"); #if _REDHAWK bool isRedhawk = dacFileNoExt.Contains("mrt100"); #endif int major, minor, revision, patch; bool res = NativeMethods.GetFileVersion(dacFilename, out major, out minor, out revision, out patch); string version = string.Format("v{0}.{1}.{2}.{3}", major, minor, revision, patch); DesktopVersion ver; if (isCoreClr) { return(new V45Runtime(this, lib)); } #if _REDHAWK else if (isRedhawk) { return(new Redhawk.RhRuntime(this, lib)); } #endif else if (major == 2) { ver = DesktopVersion.v2; } else if (major == 4) { // Allow support for .NET 4.5 runtimes if (minor == 0 && patch < 10000) { ver = DesktopVersion.v4; } else { return(new V45Runtime(this, lib)); } } else { throw new ClrDiagnosticsException("Unsupported runtime: " + version); } return(new LegacyRuntime(this, lib, ver, patch)); }
internal override void AddDacLibrary(DacLibrary dacLibrary) => _dacLibraries.Add(dacLibrary);