public ClrDacImpl(DataTarget dataTarget, ClrRuntime clrRuntime, IClrDacDebugger clrDacDebugger) { this.dataTarget = dataTarget ?? throw new ArgumentNullException(nameof(dataTarget)); this.clrRuntime = clrRuntime ?? throw new ArgumentNullException(nameof(clrRuntime)); this.clrDacDebugger = clrDacDebugger ?? throw new ArgumentNullException(nameof(clrDacDebugger)); toClrThread = new Dictionary <int, ClrThread>(); clrDacDebugger.ClrDacPaused += ClrDacDebugger_ClrDacPaused; clrDacDebugger.ClrDacRunning += ClrDacDebugger_ClrDacRunning; clrDacDebugger.ClrDacTerminated += ClrDacDebugger_ClrDacTerminated; }
void ClrDacDebugger_ClrDacTerminated(object?sender, EventArgs e) { clrDacDebugger.ClrDacPaused -= ClrDacDebugger_ClrDacPaused; clrDacDebugger.ClrDacRunning -= ClrDacDebugger_ClrDacRunning; clrDacDebugger.ClrDacTerminated -= ClrDacDebugger_ClrDacTerminated; Flush(); dataTarget.Dispose(); dataTarget = null !; clrRuntime = null !; clrDacDebugger = null !; }
public override ClrDac Create(int pid, string clrPath, IClrDacDebugger clrDacDebugger) { if (clrPath == null) { throw new ArgumentNullException(nameof(clrPath)); } var clrDac = CreateCore(pid, clrPath, clrDacDebugger); Debug.Assert(clrDac != null); return(clrDac ?? NullClrDac.Instance); }
ClrDac CreateCore(int pid, string clrPath, IClrDacDebugger clrDacDebugger) { DataTarget dataTarget = null; bool failed = true; try { // The timeout isn't used if Passive is used dataTarget = DataTarget.AttachToProcess(pid, 0, AttachFlag.Passive); var clrInfo = GetClrInfo(dataTarget, clrPath); if (clrInfo == null) { return(null); } // Use this overload to make sure it doesn't try to download the dac file which // will block this thread for several seconds or much longer. var clrRuntime = clrInfo.CreateRuntime(clrInfo.LocalMatchingDac); var clrDac = new ClrDacImpl(dataTarget, clrRuntime, clrDacDebugger); failed = false; return(clrDac); } catch (ClrDiagnosticsException) { return(null); } catch (IOException) { return(null); } catch (InvalidOperationException) { return(null); } finally { if (failed) { dataTarget?.Dispose(); } } }
public abstract ClrDac Create(int pid, string clrPath, IClrDacDebugger clrDacDebugger);