예제 #1
0
 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;
 }
예제 #2
0
 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 !;
 }
예제 #3
0
        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);
        }
예제 #4
0
        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();
                }
            }
        }
예제 #5
0
 public abstract ClrDac Create(int pid, string clrPath, IClrDacDebugger clrDacDebugger);