Exemplo n.º 1
0
        public static DnDebugger Attach(AttachProcessOptions options)
        {
            var process = Process.GetProcessById(options.ProcessId);
            var filename = process.MainModule.FileName;

            string debuggeeVersion;
            var corDebug = CreateCorDebug(options, out debuggeeVersion);
            if (corDebug == null)
                throw new Exception("An ICorDebug instance couldn't be created");
            var dbg = new DnDebugger(corDebug, options.DebugOptions, options.DebugMessageDispatcher, debuggeeVersion);
            ICorDebugProcess comProcess;
            corDebug.DebugActiveProcess(options.ProcessId, 0, out comProcess);
            var dnProcess = dbg.TryAdd(comProcess);
            if (dnProcess != null)
                dnProcess.Initialize(true, filename, string.Empty, string.Empty);
            return dbg;
        }
Exemplo n.º 2
0
 static DnDebugger CreateDnDebuggerCoreCLR(DebugProcessOptions options)
 {
     var clrType = (CoreCLRTypeDebugInfo)options.CLRTypeDebugInfo;
     var dbg2 = CoreCLRHelper.CreateDnDebugger(options, clrType, () => false, (cd, pid) => {
         var dbg = new DnDebugger(cd, options.DebugOptions, options.DebugMessageDispatcher, null);
         if (options.BreakProcessType != BreakProcessType.None)
             new BreakProcessHelper(dbg, options.BreakProcessType, options.Filename);
         ICorDebugProcess comProcess;
         cd.DebugActiveProcess((int)pid, 0, out comProcess);
         var dnProcess = dbg.TryAdd(comProcess);
         if (dnProcess != null)
             dnProcess.Initialize(false, options.Filename, options.CurrentDirectory, options.CommandLine);
         return dbg;
     });
     if (dbg2 == null)
         throw new Exception("Could not create a debugger instance");
     return dbg2;
 }
Exemplo n.º 3
0
		public static DnDebugger Attach(AttachProcessOptions options) {
			ICLRRuntimeInfo rtInfo = null;
			var process = Process.GetProcessById(options.ProcessId);
			var filename = process.MainModule.FileName;
			foreach (var t in GetCLRRuntimeInfos(process)) {
				if (string.IsNullOrEmpty(options.DebuggeeVersion) || t.Item1 == options.DebuggeeVersion) {
					rtInfo = t.Item2;
					break;
				}
			}
			if (rtInfo == null)
				throw new Exception("Couldn't find a .NET runtime or the correct .NET runtime");

			var clsid = new Guid("DF8395B5-A4BA-450B-A77C-A9A47762C520");
			var riid = typeof(ICorDebug).GUID;
			var corDebug = (ICorDebug)rtInfo.GetInterface(ref clsid, ref riid);
			var dbg = new DnDebugger(corDebug, options.DebugOptions, options.DebugMessageDispatcher, options.DebuggeeVersion);
			ICorDebugProcess comProcess;
			corDebug.DebugActiveProcess(options.ProcessId, 0, out comProcess);
			var dnProcess = dbg.TryAdd(comProcess);
			if (dnProcess != null)
				dnProcess.Initialize(true, filename, string.Empty, string.Empty);
			return dbg;
		}