protected unsafe override void Handle() { if (!RSession.IsHostRunning) { return; } var debugger = VsAppShell.Current.GetGlobalService <IVsDebugger2>(typeof(SVsShellDebugger)); if (debugger == null) { return; } var pDebugEngines = stackalloc Guid[1]; pDebugEngines[0] = DebuggerGuids.DebugEngine; uint pid = RDebugPortSupplier.GetProcessId(RSession.Id); var debugTarget = new VsDebugTargetInfo2 { cbSize = (uint)Marshal.SizeOf <VsDebugTargetInfo2>(), dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning, guidPortSupplier = DebuggerGuids.PortSupplier, bstrPortName = RDebugPortSupplier.PortName, guidLaunchDebugEngine = DebuggerGuids.DebugEngine, dwDebugEngineCount = 1, pDebugEngines = (IntPtr)pDebugEngines, dwProcessId = pid, bstrExe = RDebugPortSupplier.GetExecutableForAttach(pid), }; var pDebugTarget = stackalloc byte[Marshal.SizeOf(debugTarget)]; Marshal.StructureToPtr(debugTarget, (IntPtr)pDebugTarget, false); Marshal.ThrowExceptionForHR(debugger.LaunchDebugTargets2(1, (IntPtr)pDebugTarget)); // If we have successfully attached, VS has switched to debugging UI context, which hides // the REPL window. Show it again and give it focus. _interactiveWorkflow.ActiveWindow?.Container.Show(true); }
public override Task <IReadOnlyList <IDebugLaunchSettings> > QueryDebugTargetsAsync(DebugLaunchOptions launchOptions) { var targets = new List <IDebugLaunchSettings>(); if (Session.IsHostRunning) { uint pid = RDebugPortSupplier.GetProcessId(Session.Id); var target = new DebugLaunchSettings(launchOptions) { LaunchOperation = DebugLaunchOperation.AlreadyRunning, PortSupplierGuid = DebuggerGuids.PortSupplier, PortName = RDebugPortSupplier.PortName, LaunchDebugEngineGuid = DebuggerGuids.DebugEngine, ProcessId = (int)pid, Executable = RDebugPortSupplier.GetExecutableForAttach(pid), }; targets.Add(target); } return(Task.FromResult((IReadOnlyList <IDebugLaunchSettings>)targets)); }