public static DBG.AttachProcessOptions Convert(AttachOptions options, IDebuggerSettings settings, string debuggeeVersion = null) { if (options == null) throw new ArgumentNullException(); var o = new DBG.AttachProcessOptions(new DBG.DesktopCLRTypeAttachInfo(debuggeeVersion)); o.ProcessId = options.ProcessId; o.DebugMessageDispatcher = WpfDebugMessageDispatcher.Instance; o.DebugOptions.IgnoreBreakInstructions = settings.IgnoreBreakInstructions; return o; }
public static DBG.AttachProcessOptions Convert(AttachOptions options, IDebuggerSettings settings, string debuggeeVersion = null) { if (options == null) { throw new ArgumentNullException(); } var o = new DBG.AttachProcessOptions(new DBG.DesktopCLRTypeAttachInfo(debuggeeVersion)); o.ProcessId = options.ProcessId; o.DebugMessageDispatcher = WpfDebugMessageDispatcher.Instance; o.DebugOptions.IgnoreBreakInstructions = settings.IgnoreBreakInstructions; return(o); }
static ICorDebug CreateCorDebugDesktop(AttachProcessOptions options, out string debuggeeVersion) { var clrType = (DesktopCLRTypeAttachInfo)options.CLRTypeAttachInfo; debuggeeVersion = clrType.DebuggeeVersion; ICLRRuntimeInfo rtInfo = null; var process = Process.GetProcessById(options.ProcessId); var filename = process.MainModule.FileName; foreach (var t in GetCLRRuntimeInfos(process)) { if (string.IsNullOrEmpty(clrType.DebuggeeVersion) || t.Item1 == clrType.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; return (ICorDebug)rtInfo.GetInterface(ref clsid, ref riid); }
static ICorDebug CreateCorDebugCoreCLR(AttachProcessOptions options, out string debuggeeVersion) { debuggeeVersion = null; var clrType = (CoreCLRTypeAttachInfo)options.CLRTypeAttachInfo; return CoreCLRHelper.CreateCorDebug(clrType); }
static ICorDebug CreateCorDebug(AttachProcessOptions options, out string debuggeeVersion) { switch (options.CLRTypeAttachInfo.CLRType) { case CLRType.Desktop: return CreateCorDebugDesktop(options, out debuggeeVersion); case CLRType.CoreCLR: return CreateCorDebugCoreCLR(options, out debuggeeVersion); default: Debug.Fail("Invalid CLRType"); throw new InvalidOperationException(); } }
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; }
bool Attach(AttachProcessOptions options) { if (IsDebugging) return false; if (options == null) return false; RemoveDebugger(); DnDebugger newDebugger; try { newDebugger = DnDebugger.Attach(options); } catch (Exception ex) { MainWindow.Instance.ShowMessageBox(string.Format("Could not start debugger.\n\nError: {0}", ex.Message)); return false; } Initialize(newDebugger); return true; }
public void Attach() { if (!CanAttach) return; var data = new AttachProcessVM(MainWindow.Instance.Dispatcher); var win = new AttachProcessDlg(); win.DataContext = data; win.Owner = MainWindow.Instance; var res = win.ShowDialog(); data.Dispose(); if (res != true) return; var processVM = data.SelectedProcess; if (processVM == null) return; var options = new AttachProcessOptions(processVM.CLRTypeInfo); options.ProcessId = processVM.PID; options.DebugMessageDispatcher = WpfDebugMessageDispatcher.Instance; Attach(options); }
bool Attach(AttachProcessOptions options, out string errMsg) { errMsg = null; if (IsDebugging) return false; if (options == null) return false; TheDebugger.RemoveDebugger(); DnDebugger newDebugger; try { newDebugger = DnDebugger.Attach(options); } catch (Exception ex) { errMsg = string.Format(dnSpy_Debugger_Resources.Error_CouldNotStartDebugger2, ex.Message); return false; } if (newDebugger.Processes.Length == 0) { errMsg = string.Format(dnSpy_Debugger_Resources.Error_CouldNotStartDebugger2, "Could not attach to the process"); return false; } TheDebugger.Initialize(newDebugger); return true; }
public bool Attach(AttachProcessOptions options) { string errMsg; return Attach(options, out errMsg); }
public bool Attach() { if (!CanAttach) return false; var classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.UIMisc); var data = new AttachProcessVM(Dispatcher.CurrentDispatcher, DebuggerSettings.SyntaxHighlightAttach, classificationFormatMap, textElementProvider); var win = new AttachProcessDlg(); win.DataContext = data; win.Owner = appWindow.MainWindow; var res = win.ShowDialog(); data.Dispose(); if (res != true) return false; var processVM = data.SelectedProcess; if (processVM == null) return false; var options = new AttachProcessOptions(processVM.CLRTypeInfo); options.ProcessId = processVM.PID; options.DebugMessageDispatcher = WpfDebugMessageDispatcher.Instance; string errMsg; if (!Attach(options, out errMsg)) { if (!string.IsNullOrEmpty(errMsg)) messageBoxService.Show(errMsg); return false; } return true; }
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; }
bool Attach(AttachProcessOptions options) { if (IsDebugging) return false; if (options == null) return false; TheDebugger.RemoveDebugger(); DnDebugger newDebugger; try { newDebugger = DnDebugger.Attach(options); } catch (Exception ex) { messageBoxManager.Show(string.Format(dnSpy_Debugger_Resources.Error_CouldNotStartDebugger2, ex.Message)); return false; } TheDebugger.Initialize(newDebugger); return true; }
public bool Attach() { if (!CanAttach) return false; var data = new AttachProcessVM(Dispatcher.CurrentDispatcher, debuggerSettings.SyntaxHighlightAttach); var win = new AttachProcessDlg(); win.DataContext = data; win.Owner = appWindow.MainWindow; var res = win.ShowDialog(); data.Dispose(); if (res != true) return false; var processVM = data.SelectedProcess; if (processVM == null) return false; var options = new AttachProcessOptions(processVM.CLRTypeInfo); options.ProcessId = processVM.PID; options.DebugMessageDispatcher = WpfDebugMessageDispatcher.Instance; string errMsg; if (!Attach(options, out errMsg)) { if (!string.IsNullOrEmpty(errMsg)) messageBoxManager.Show(errMsg); return false; } return true; }