コード例 #1
0
        public int DebugLaunch(uint flags)
        {
            VsDebugTargetInfo2[] targets;
            int hr = QueryDebugTargets(out targets);

            if (ErrorHandler.Failed(hr))
            {
                return(hr);
            }

            flags |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask;

            VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1];
            int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4));

            this.CopyDebugTargetInfo(ref targets[0], ref appPackageDebugTarget[0], flags);
            IVsAppContainerBootstrapperResult result = this.BootstrapForDebuggingSync(targets[0].bstrRemoteMachine);

            appPackageDebugTarget[0].bstrRemoteMachine = result.Address;

            // Pass the debug launch targets to the debugger
            IVsDebugger4 debugger4 = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger));

            VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1];

            debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results);

            return(VSConstants.S_OK);
        }
コード例 #2
0
        private void LaunchDebugTarget(string filePath, string debuggerDesc)
        {
            var debugger = (IVsDebugger4)this.ServiceProvider.GetService(typeof(IVsDebugger));

            Assumes.Present(debugger);
            ((IVsDebugger)debugger).AdviseDebuggerEvents(this, out _);
            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe = filePath;
            //debugTargets[0].bstrPortName = "1243";
            //debugTargets[0].guidPortSupplier = new Guid(ILRuntimeDebugEngine.EngineConstants.PortSupplier);
            debugTargets[0].guidLaunchDebugEngine = new Guid(EngineConstants.EngineGUID);
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];
            try
            {
                currentDebuggerDesc = debuggerDesc;
                debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
            }
            catch /*(Exception ex)*/
            {
                var shell = (IVsUIShell)this.ServiceProvider.GetService(typeof(SVsUIShell));
                Assumes.Present(shell);
                string msg;
                shell.GetErrorInfo(out msg);
            }
        }
コード例 #3
0
        private void AttachToRemoteProcess(string machineName, string processName)
        {
            IVsDebugger3 vsDebugger = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger3;

            VsDebugTargetInfo3[]       arrDebugTargetInfo   = new VsDebugTargetInfo3[1];
            VsDebugTargetProcessInfo[] arrTargetProcessInfo = new VsDebugTargetProcessInfo[1];

            arrDebugTargetInfo[0].bstrExe           = processName;
            arrDebugTargetInfo[0].bstrRemoteMachine = machineName;

            arrDebugTargetInfo[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
            arrDebugTargetInfo[0].guidLaunchDebugEngine = Guid.Empty;
            arrDebugTargetInfo[0].dwDebugEngineCount    = 1;

            Guid   guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid;
            IntPtr pGuids        = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));

            Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
            arrDebugTargetInfo[0].pDebugEngines = pGuids;
            int hr = vsDebugger.LaunchDebugTargets3(1, arrDebugTargetInfo, arrTargetProcessInfo);

            // cleanup
            if (pGuids != IntPtr.Zero)
            {
                Marshal.FreeCoTaskMem(pGuids);
            }
        }
コード例 #4
0
ファイル: QmlDebugLauncher.cs プロジェクト: qt-labs/vstools
        void LaunchDebug(
            string execPath,
            string execCmd,
            uint procId,
            IEnumerable <string> rccItems)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var targets = new[] { new VsDebugTargetInfo4
                                  {
                                      dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess,
                                      bstrExe               = new Uri(execPath).LocalPath,
                                      bstrArg               = execCmd,
                                      bstrOptions           = procId.ToString(),
                                      bstrEnv               = "QTRCC=" + string.Join(";", rccItems),
                                      guidLaunchDebugEngine = QmlEngine.Id,
                                      LaunchFlags           = (uint)__VSDBGLAUNCHFLAGS5.DBGLAUNCH_BreakOneProcess,
                                  } };

            var processInfo = new VsDebugTargetProcessInfo[targets.Length];

            try {
                debugger4.LaunchDebugTargets4((uint)targets.Length, targets, processInfo);
            } catch (System.Exception e) {
                OutputWriteLine(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
            }
        }
コード例 #5
0
        /// <summary>
        /// Launches the Visual Studio debugger.
        /// </summary>
        protected async Task <IReadOnlyList <VsDebugTargetProcessInfo> > DoLaunchAsync(params IDebugLaunchSettings[] launchSettings)
        {
            VsDebugTargetInfo4[] launchSettingsNative = launchSettings.Select(GetDebuggerStruct4).ToArray();
            if (launchSettingsNative.Length == 0)
            {
                return(Array.Empty <VsDebugTargetProcessInfo>());
            }

            try
            {
                // The debugger needs to be called on the UI thread
                await ThreadingService.SwitchToUIThread();

                IVsDebugger4 shellDebugger = await _vsDebuggerService.GetValueAsync();

                var launchResults = new VsDebugTargetProcessInfo[launchSettingsNative.Length];
                shellDebugger.LaunchDebugTargets4((uint)launchSettingsNative.Length, launchSettingsNative, launchResults);
                return(launchResults);
            }
            finally
            {
                // Free up the memory allocated to the (mostly) managed debugger structure.
                foreach (VsDebugTargetInfo4 nativeStruct in launchSettingsNative)
                {
                    FreeVsDebugTargetInfoStruct(nativeStruct);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Called by the EXECUTION ENGINE to attach this TESTER to the newly
        /// started TESTEE.
        /// </summary>
        /// <returns>True if the attach occurred; otherwise, false.</returns>
        public bool AttachToProcess(int processId, bool mixedMode)
        {
            using (var evt = TesterDebugAttacherShared.GetNotifyEvent()) {
                if (evt == null) {
                    return false;
                }

                var debug = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger3;

                var targets = new VsDebugTargetInfo3[1];
                var results = new VsDebugTargetProcessInfo[1];

                targets[0].bstrExe = string.Format("\0{0:X}", processId);
                targets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                targets[0].guidLaunchDebugEngine = Guid.Empty;
                targets[0].dwDebugEngineCount = 1;

                var engine = mixedMode ?
                    VSConstants.DebugEnginesGuids.ManagedAndNative_guid :
                    VSConstants.DebugEnginesGuids.ManagedOnly_guid;

                var pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(engine));
                try {
                    Marshal.StructureToPtr(engine, pGuids, false);
                    targets[0].pDebugEngines = pGuids;

                    ErrorHandler.ThrowOnFailure(debug.LaunchDebugTargets3((uint)targets.Length, targets, results));
                } finally {
                    Marshal.FreeCoTaskMem(pGuids);
                }
                evt.Set();
            }
            return true;
        }
コード例 #7
0
        /// <summary>
        /// Called by the EXECUTION ENGINE to attach this TESTER to the newly
        /// started TESTEE.
        /// </summary>
        /// <returns>True if the attach occurred; otherwise, false.</returns>
        public bool AttachToProcess(int processId, bool mixedMode)
        {
            using (var evt = TesterDebugAttacherShared.GetNotifyEvent()) {
                if (evt == null)
                {
                    return(false);
                }

                var debug = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger3;

                var targets = new VsDebugTargetInfo3[1];
                var results = new VsDebugTargetProcessInfo[1];

                targets[0].bstrExe = string.Format("\0{0:X}", processId);
                targets[0].dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                targets[0].guidLaunchDebugEngine = Guid.Empty;
                targets[0].dwDebugEngineCount    = 1;

                var engine = mixedMode ?
                             VSConstants.DebugEnginesGuids.ManagedAndNative_guid :
                             VSConstants.DebugEnginesGuids.ManagedOnly_guid;

                var pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(engine));
                try {
                    Marshal.StructureToPtr(engine, pGuids, false);
                    targets[0].pDebugEngines = pGuids;

                    ErrorHandler.ThrowOnFailure(debug.LaunchDebugTargets3((uint)targets.Length, targets, results));
                } finally {
                    Marshal.FreeCoTaskMem(pGuids);
                }
                evt.Set();
            }
            return(true);
        }
コード例 #8
0
        private void StartWithChromeV2Debugger(string file, string nodePath, bool startBrowser)
        {
            var serviceProvider = _project.Site;

            // Here we need to massage the env variables into the format expected by node and vs code
            var webBrowserUrl = GetFullUrl();
            var envVars       = GetEnvironmentVariables(webBrowserUrl);

            var runtimeArguments = ConvertArguments(this._project.GetProjectProperty(NodeProjectProperty.NodeExeArguments));
            var scriptArguments  = ConvertArguments(this._project.GetProjectProperty(NodeProjectProperty.ScriptArguments));

            var cwd           = _project.GetWorkingDirectory(); // Current working directory
            var configuration = new JObject(
                new JProperty("name", "Debug Node.js program from Visual Studio"),
                new JProperty("type", "node2"),
                new JProperty("request", "launch"),
                new JProperty("program", file),
                new JProperty("args", scriptArguments),
                new JProperty("runtimeExecutable", nodePath),
                new JProperty("runtimeArgs", runtimeArguments),
                new JProperty("cwd", cwd),
                new JProperty("console", "externalTerminal"),
                new JProperty("env", JObject.FromObject(envVars)),
                new JProperty("trace", CheckEnableDiagnosticLoggingOption()),
                new JProperty("sourceMaps", true),
                new JProperty("stopOnEntry", true));

            var jsonContent = configuration.ToString();

            var debugTargets = new[] {
                new VsDebugTargetInfo4()
                {
                    dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess,
                    guidLaunchDebugEngine = WebKitDebuggerV2Guid,
                    bstrExe     = file,
                    bstrOptions = jsonContent
                }
            };

            var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger));

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);

            // Launch browser
            if (startBrowser && !string.IsNullOrWhiteSpace(webBrowserUrl))
            {
                var uri = new Uri(webBrowserUrl);
                OnPortOpenedHandler.CreateHandler(
                    uri.Port,
                    timeout: 5_000, // 5 seconds
                    action: () =>
                {
                    VsShellUtilities.OpenBrowser(webBrowserUrl, (uint)__VSOSPFLAGS.OSP_LaunchNewBrowser);
                }
                    );
            }
        }
コード例 #9
0
ファイル: Connect.cs プロジェクト: wordijp/DynamicPatcher
        public bool LaunchAndDoInject()
        {
            IVsOutputWindowPane output = (IVsOutputWindowPane)Package.GetGlobalService(typeof(SVsGeneralOutputWindowPane));

            String   exepath     = "";
            String   workdir     = "";
            String   environment = "";
            String   addindir    = "";
            Solution sln         = _applicationObject.Solution;
            String   startup     = (String)((Array)sln.SolutionBuild.StartupProjects).GetValue(0);

            foreach (EnvDTE.Project project in sln.Projects)
            {
                if (project.UniqueName == startup)
                {
                    VCProject vcproj = (VCProject)project.Object;
                    if (vcproj == null)
                    {
                        // this is not a visual c++ project
                        continue;
                    }
                    IVCCollection   cfgs = vcproj.Configurations;
                    VCConfiguration cfg  = cfgs.Item(1);
                    exepath     = cfg.Evaluate("$(LocalDebuggerCommand)");
                    workdir     = cfg.Evaluate("$(LocalDebuggerWorkingDirectory)");
                    environment = cfg.Evaluate("$(LocalDebuggerEnvironment)");
                    addindir    = cfg.Evaluate("$(USERPROFILE)\\Documents\\Visual Studio 2012\\Addins");
                    output.OutputString(exepath);
                }
            }

            uint pid = dpVSHelper.ExecuteSuspended(exepath, addindir, environment);

            if (pid != 0)
            {
                VsDebugTargetProcessInfo[] res  = new VsDebugTargetProcessInfo[1];
                VsDebugTargetInfo4[]       info = new VsDebugTargetInfo4[1];
                info[0].bstrExe = exepath;
                info[0].dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                //info[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AttachToSuspendedLaunchProcess; // somehow this makes debugger not work
                info[0].dwProcessId = pid;
                info[0].LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd | (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop;

                Guid   guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid;
                IntPtr pGuids        = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
                Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
                info[0].pDebugEngines      = pGuids;
                info[0].dwDebugEngineCount = 1;

                IVsDebugger4 idbg = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger));
                idbg.LaunchDebugTargets4(1, info, res);

                dpVSHelper.Resume(pid);
            }

            return(true);
        }
コード例 #10
0
        public void LaunchVsDebugger(VsDebugTargetInfo4 target)
        {
            var targets = new VsDebugTargetInfo4[1] {
                target
            };

            VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[targets.Length];
            IVsDebugger4 vsDebugger            = (IVsDebugger4)project.GetService(typeof(SVsShellDebugger));

            vsDebugger.LaunchDebugTargets4((uint)targets.Length, targets, results);
        }
コード例 #11
0
ファイル: HostDebugger.cs プロジェクト: rajkumar42/MIEngine
            public static void LaunchDebugTarget(string filePath, string options, Guid engineId)
            {
                IVsDebugger4 debugger = (IVsDebugger4)Package.GetGlobalService(typeof(IVsDebugger));
                VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
                debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
                debugTargets[0].bstrExe = filePath;
                debugTargets[0].bstrOptions = options;
                debugTargets[0].guidLaunchDebugEngine = engineId;
                VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

                debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
            }
コード例 #12
0
        private void LaunchDebugTarget(string filePath)
        {
            var debugger = (IVsDebugger4)GetService(typeof(IVsDebugger));

            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe = filePath;
            debugTargets[0].guidLaunchDebugEngine = new Guid(Microsoft.VisualStudio.Debugger.SampleEngine.EngineConstants.EngineId);
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }
コード例 #13
0
        public bool StartDebugger(SoftDebuggerSession session, StartInfo startInfo)
        {
            tracer.Verbose("Entering Launch for: {0}", this);
            var debugger = ServiceProvider.GlobalProvider.GetService <SVsShellDebugger, IVsDebugger4>();

            var sessionMarshalling = new SessionMarshalling(session, startInfo);

            VsDebugTargetInfo4 info = new VsDebugTargetInfo4();

            info.dlo = (uint)Microsoft.VisualStudio.Shell.Interop.DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;

            var startArgs = startInfo.StartArgs;
            var appName   = "Mono";

            if (startArgs is SoftDebuggerRemoteArgs)
            {
                appName = ((SoftDebuggerRemoteArgs)startArgs).AppName;
            }
            else if (startArgs is SoftDebuggerLaunchArgs)
            {
                appName = Path.GetFileNameWithoutExtension(startInfo.Command);
            }

            info.bstrExe               = appName;
            info.bstrCurDir            = "";
            info.bstrArg               = null; // no command line parameters
            info.bstrRemoteMachine     = null;
            info.fSendToOutputWindow   = 0;    // Let stdout stay with the application.
            info.guidPortSupplier      = Guids.PortSupplierGuid;
            info.guidLaunchDebugEngine = Guids.EngineGuid;
            info.bstrPortName          = appName;

            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf   = new BinaryFormatter();
                ObjRef          oref = RemotingServices.Marshal(sessionMarshalling);
                bf.Serialize(ms, oref);
                info.bstrOptions = Convert.ToBase64String(ms.ToArray());
            }

            try
            {
                var results = new VsDebugTargetProcessInfo[1];
                debugger.LaunchDebugTargets4(1, new[] { info }, results);
                return(true);
            }
            catch (Exception ex)
            {
                tracer.Error("Controller.Launch ()", ex);
                throw;
            }
        }
コード例 #14
0
        private void LaunchDebugTarget(string filePath, string options)
        {
            IVsDebugger4 debugger = (IVsDebugger4)GetService(typeof(IVsDebugger));

            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe               = filePath;
            debugTargets[0].bstrOptions           = options;
            debugTargets[0].guidLaunchDebugEngine = Microsoft.MIDebugEngine.EngineConstants.EngineId;
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }
コード例 #15
0
ファイル: HostDebugger.cs プロジェクト: yizhang82/MIEngine
            public static void LaunchDebugTarget(string filePath, string options, Guid engineId)
            {
                IVsDebugger4 debugger = (IVsDebugger4)Package.GetGlobalService(typeof(IVsDebugger));

                VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
                debugTargets[0].dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
                debugTargets[0].bstrExe               = filePath;
                debugTargets[0].bstrOptions           = options;
                debugTargets[0].guidLaunchDebugEngine = engineId;
                VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

                debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
            }
コード例 #16
0
        public int DebugLaunch(uint flags)
        {
            VsDebugTargetInfo2[] targets;
            int hr = QueryDebugTargets(out targets);

            if (ErrorHandler.Failed(hr))
            {
                return(hr);
            }

            flags |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask;

            VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1];
            int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4));

            appPackageDebugTarget[0].AppPackageLaunchInfo.AppUserModelID = DeployAppUserModelID;
            appPackageDebugTarget[0].AppPackageLaunchInfo.PackageMoniker = DeployPackageMoniker;

            appPackageDebugTarget[0].dlo                   = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug;
            appPackageDebugTarget[0].LaunchFlags           = flags;
            appPackageDebugTarget[0].bstrRemoteMachine     = targets[0].bstrRemoteMachine;
            appPackageDebugTarget[0].bstrExe               = targets[0].bstrExe;
            appPackageDebugTarget[0].bstrArg               = targets[0].bstrArg;
            appPackageDebugTarget[0].bstrCurDir            = targets[0].bstrCurDir;
            appPackageDebugTarget[0].bstrEnv               = targets[0].bstrEnv;
            appPackageDebugTarget[0].dwProcessId           = targets[0].dwProcessId;
            appPackageDebugTarget[0].pStartupInfo          = IntPtr.Zero; //?
            appPackageDebugTarget[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine;
            appPackageDebugTarget[0].dwDebugEngineCount    = targets[0].dwDebugEngineCount;
            appPackageDebugTarget[0].pDebugEngines         = targets[0].pDebugEngines;
            appPackageDebugTarget[0].guidPortSupplier      = targets[0].guidPortSupplier;

            appPackageDebugTarget[0].bstrPortName        = targets[0].bstrPortName;
            appPackageDebugTarget[0].bstrOptions         = targets[0].bstrOptions;
            appPackageDebugTarget[0].fSendToOutputWindow = targets[0].fSendToOutputWindow;
            appPackageDebugTarget[0].pUnknown            = targets[0].pUnknown;
            appPackageDebugTarget[0].guidProcessLanguage = targets[0].guidProcessLanguage;
            appPackageDebugTarget[0].project             = this.project;

            // Pass the debug launch targets to the debugger
            System.IServiceProvider sp        = this.project as System.IServiceProvider;
            IVsDebugger4            debugger4 = (IVsDebugger4)sp.GetService(typeof(SVsShellDebugger));

            VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1];

            debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results);

            return(VSConstants.S_OK);
        }
コード例 #17
0
        private void AttachDebugger(VsDebugTargetInfo4 dbgInfo)
        {
            var serviceProvider = _project.Site;

            var debugger = serviceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4;

            if (debugger == null)
            {
                throw new InvalidOperationException("Failed to get the debugger service.");
            }

            var launchResults = new VsDebugTargetProcessInfo[1];

            debugger.LaunchDebugTargets4(1, new[] { dbgInfo }, launchResults);
        }
コード例 #18
0
        private void LaunchDebugTarget(string filePath, string options)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var debugger     = (IVsDebugger4)serviceProvider.GetService(typeof(IVsDebugger));
            var debugTargets = new VsDebugTargetInfo4[1];

            debugTargets[0].dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe               = filePath;
            debugTargets[0].bstrOptions           = options;
            debugTargets[0].guidLaunchDebugEngine = Guids.DebugEngineGuid;
            var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }
コード例 #19
0
        // Token: 0x06000012 RID: 18 RVA: 0x0000229C File Offset: 0x0000049C
        public bool StartDebugger(SoftDebuggerSession session, StartInfo startInfo)
        {
            DebugLauncher.tracer.Verbose("Entering Launch for: {0}", new object[]
            {
                this
            });
            IVsDebugger4       service           = ServiceProvider.GlobalProvider.GetService <SVsShellDebugger, IVsDebugger4>();
            SessionMarshalling obj               = new SessionMarshalling(session, startInfo);
            VsDebugTargetInfo4 vsDebugTargetInfo = default(VsDebugTargetInfo4);

            vsDebugTargetInfo.dlo                   = 1U;
            vsDebugTargetInfo.bstrExe               = "Mono";
            vsDebugTargetInfo.bstrCurDir            = "";
            vsDebugTargetInfo.bstrArg               = null;
            vsDebugTargetInfo.bstrRemoteMachine     = null;
            vsDebugTargetInfo.fSendToOutputWindow   = 0;
            vsDebugTargetInfo.guidPortSupplier      = Guids.PortSupplierGuid;
            vsDebugTargetInfo.guidLaunchDebugEngine = Guids.EngineGuid;
            vsDebugTargetInfo.bstrPortName          = "Mono";
            using (MemoryStream memoryStream = new MemoryStream())
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                ObjRef          graph           = RemotingServices.Marshal(obj);
                binaryFormatter.Serialize(memoryStream, graph);
                vsDebugTargetInfo.bstrOptions = Convert.ToBase64String(memoryStream.ToArray());
            }
            bool result;

            try
            {
                VsDebugTargetProcessInfo[] array = new VsDebugTargetProcessInfo[1];
                service.LaunchDebugTargets4(1U, new VsDebugTargetInfo4[]
                {
                    vsDebugTargetInfo
                }, array);
                result = true;
            }
            catch (Exception ex)
            {
                DebugLauncher.tracer.Error("Controller.Launch ()", new object[]
                {
                    ex
                });
                throw;
            }
            return(result);
        }
コード例 #20
0
        public override async Task LaunchAsync(DebugLaunchOptions launchOptions)
        {
            // The properties that are available via DebuggerProperties are determined by the property XAML files in your project.
            var debuggerProperties = await this.DebuggerProperties.GetMocheDebuggerPropertiesAsync();

            LocalLaunchOptions llo = new LocalLaunchOptions();

            llo.ExePath = await debuggerProperties.LocalDebuggerCommand.GetEvaluatedValueAtEndAsync();

            llo.ExeArguments = await debuggerProperties.LocalDebuggerCommandArguments.GetEvaluatedValueAtEndAsync();

            llo.WorkingDirectory = await debuggerProperties.LocalDebuggerWorkingDirectory.GetEvaluatedValueAtEndAsync();

            llo.MIDebuggerPath = await debuggerProperties.LocalDebuggerPath.GetEvaluatedValueAtEndAsync();

            MIMode miMode;

            if (Enum.TryParse(await debuggerProperties.LocalDebuggerType.GetEvaluatedValueAtEndAsync(), out miMode))
            {
                llo.MIMode          = miMode;
                llo.MIModeSpecified = true;
            }
            if (llo.ExePath == null)
            {
                var generalProperties = await this.DebuggerProperties.GetConfigurationGeneralPropertiesAsync();

                llo.ExePath = await generalProperties.TargetPath.GetEvaluatedValueAtEndAsync();
            }

            IVsDebugger4 debugger = (IVsDebugger4)ServiceProvider.GetService(typeof(IVsDebugger));

            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe = llo.MIDebuggerPath;
            using (MemoryStream s = new MemoryStream())
            {
                new System.Xml.Serialization.XmlSerializer(typeof(LocalLaunchOptions)).Serialize(s, llo);
                s.Flush();
                s.Seek(0, SeekOrigin.Begin);
                debugTargets[0].bstrOptions = await new StreamReader(s).ReadToEndAsync();
            }
            debugTargets[0].guidLaunchDebugEngine = Microsoft.MIDebugEngine.EngineConstants.EngineId;
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }
コード例 #21
0
        public bool StartDebugger(SoftDebuggerSession session, StartInfo startInfo)
        {
            IVsDebugger4 service = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4;

            if (service == null)
            {
                return(false);
            }

            SessionMarshalling sessionMarshalling = new SessionMarshalling(session, startInfo);
            VsDebugTargetInfo4 debugTargetInfo4   = new VsDebugTargetInfo4
            {
                dlo                   = 1U,
                bstrExe               = string.Format("CRYENGINE - {0}", startInfo.StartupProject.Name),
                bstrCurDir            = "",
                bstrArg               = null,
                bstrRemoteMachine     = null,
                fSendToOutputWindow   = 0,
                guidPortSupplier      = Guids.PortSupplierGuid,
                guidLaunchDebugEngine = Guids.EngineGuid,
                bstrPortName          = "Mono"
            };

            using (MemoryStream memoryStream = new MemoryStream())
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                ObjRef          objRef          = RemotingServices.Marshal(sessionMarshalling);
                binaryFormatter.Serialize(memoryStream, objRef);
                debugTargetInfo4.bstrOptions = Convert.ToBase64String(memoryStream.ToArray());
            }

            try
            {
                VsDebugTargetProcessInfo[] pLaunchResults = new VsDebugTargetProcessInfo[1];
                service.LaunchDebugTargets4(1U, new VsDebugTargetInfo4[1] {
                    debugTargetInfo4
                }, pLaunchResults);
                return(true);
            }
            catch
            {
                throw;
            }
        }
コード例 #22
0
        private void LaunchDebugTarget(string filePath, string options)
        {
            ////////////////////////////////////////////////////////
            //  EXPERIMENTAL to launch debug from VS command line //
            ////////////////////////////////////////////////////////

            IVsDebugger4 debugger = (IVsDebugger4)GetService(typeof(IVsDebugger));

            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe               = typeof(CorDebugProcess).Assembly.Location;
            debugTargets[0].bstrArg               = options;
            debugTargets[0].guidPortSupplier      = DebugPortSupplier.PortSupplierGuid;
            debugTargets[0].guidLaunchDebugEngine = CorDebug.EngineGuid;
            debugTargets[0].bstrCurDir            = filePath;
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }
コード例 #23
0
        public int DebugLaunch(uint grfLaunch)
        {
            var dteProject           = GetDTEProject(project);
            var projectFolder        = Path.GetDirectoryName(dteProject.FullName);
            var projectConfiguration = dteProject.ConfigurationManager.ActiveConfiguration;
            var dir        = Path.GetDirectoryName(Path.Combine(projectFolder, projectConfiguration.Properties.Item("OutputPath").Value.ToString()));
            var fileName   = dteProject.Properties.Item("OutputFileName").Value.ToString();
            var outputFile = Path.Combine(dir, fileName);

            var sourceMappings = new List <MonoSourceMapping>();

            foreach (Project currentProject in dteProject.Collection)
            {
                MonoProgramFlavorCfg cfg;

                if (cfgsByDteProject.TryGetValue(Tuple.Create(currentProject, $"{projectConfiguration.ConfigurationName}|{projectConfiguration.PlatformName}"), out cfg))
                {
                    var sourceRoot = Path.GetDirectoryName(currentProject.FullName);
                    var buildRoot  = cfg[MonoPropertyPage.BuildFolderProperty].NullIfEmpty() ?? ConvertToUnixPath(sourceRoot);
                    sourceMappings.Add(new MonoSourceMapping(sourceRoot, buildRoot));
                }
            }
//	        var sourceRoot = projectFolder;
//	        var buildRoot = this[MonoPropertyPage.BuildFolderProperty].NullIfEmpty() ?? ConvertToUnixPath(sourceRoot);
            var settings = new MonoDebuggerSettings(this[MonoPropertyPage.DebugHostProperty], this[MonoPropertyPage.DebugUsernameProperty], this[MonoPropertyPage.DebugPasswordProperty], sourceMappings.ToArray());

            var debugger     = (IVsDebugger4)project.Package.GetGlobalService <IVsDebugger>();
            var debugTargets = new VsDebugTargetInfo4[1];

            debugTargets[0].LaunchFlags           = grfLaunch;
            debugTargets[0].dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe               = outputFile;
            debugTargets[0].bstrCurDir            = this[MonoPropertyPage.DebugDestinationProperty].Trim('/'); // If the user has a slash on either side, just get rid of it
            debugTargets[0].bstrOptions           = settings.ToString();
            debugTargets[0].guidLaunchDebugEngine = new Guid(Guids.EngineId);

            var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);

            return(VSConstants.S_OK);
        }
コード例 #24
0
        private async System.Threading.Tasks.Task LaunchDebugTargetAsync(string filePath, string options)
        {
            ////////////////////////////////////////////////////////
            //  EXPERIMENTAL to launch debug from VS command line //
            ////////////////////////////////////////////////////////
            await JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsDebugger4 debugger = (IVsDebugger4)GetServiceAsync(typeof(IVsDebugger));

            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe               = typeof(CorDebugProcess).Assembly.Location;
            debugTargets[0].bstrArg               = options;
            debugTargets[0].guidPortSupplier      = DebugPortSupplier.PortSupplierGuid;
            debugTargets[0].guidLaunchDebugEngine = CorDebug.EngineGuid;
            debugTargets[0].bstrCurDir            = filePath;
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }
コード例 #25
0
        public int DebugLaunch(uint grfLaunch)
        {
            try
            {
                var dteProject = GetDteProject(_project);
                var projectFolder = Path.GetDirectoryName(dteProject.FullName);

                if (projectFolder == null)
                    throw new Exception("projectFolder is null");

                var projectConfiguration = dteProject.ConfigurationManager.ActiveConfiguration;
                var dir =
                    Path.GetDirectoryName(Path.Combine(projectFolder,
                        projectConfiguration.Properties.Item("OutputPath").Value.ToString()));

                if (dir == null)
                    throw new Exception("dir is null");

                var fileName = dteProject.Properties.Item("OutputFileName").Value.ToString();

                var outputFile = Path.Combine(dir, fileName);

                // ReSharper disable once SuspiciousTypeConversion.Global
                var debugger = (IVsDebugger4) _project.Package.GetGlobalService<IVsDebugger>();
                var debugTargets = new VsDebugTargetInfo4[1];
                debugTargets[0].LaunchFlags = grfLaunch;
                debugTargets[0].dlo = (uint) DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
                debugTargets[0].bstrExe = outputFile;
                debugTargets[0].guidLaunchDebugEngine = Guids.EngineIdGuid;
                debugTargets[0].bstrOptions = $"{this[SampSharpPropertyPage.GameMode]}|split|{this[SampSharpPropertyPage.NoWindow]}";

                var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];
                debugger.LaunchDebugTargets4(1, debugTargets, processInfo);

                return S_OK;
            }
            catch
            {
                return E_ABORT;
            }
        }
コード例 #26
0
        private void AttachDebugger(object sender, EventArgs e)
        {
            var debugger     = (IVsDebugger4)GetService(typeof(IVsDebugger));
            var debugTargets = new VsDebugTargetInfo4[1];

            debugTargets[0].dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe = "TestDebug.exe";
            debugTargets[0].guidLaunchDebugEngine = new Guid(Guids.EngineId);

//            var guidDbgEngine = new Guid(Guids.EngineId);
//            var pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
//            Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
//            debugTargets[0].pDebugEngines = pGuids;

            var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);

//            if (pGuids != IntPtr.Zero)
//                Marshal.FreeCoTaskMem(pGuids);
        }
コード例 #27
0
        private void LaunchInBuiltinDebugger(string file)
        {
            VsDebugTargetInfo4[] targets = new VsDebugTargetInfo4[1];
            targets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            targets[0].guidLaunchDebugEngine = Constants.NativeOnlyEngine;
            targets[0].bstrExe = file;
            if (!string.IsNullOrEmpty(_debugConfig.CommandLineArgs))
            {
                targets[0].bstrArg = _debugConfig.CommandLineArgs;
            }
            if (!string.IsNullOrEmpty(_debugConfig.WorkingDir))
            {
                targets[0].bstrCurDir = _debugConfig.WorkingDir;
            }

            VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[targets.Length];

            IVsDebugger4 vsDebugger = (IVsDebugger4)_project.GetService(typeof(SVsShellDebugger));

            vsDebugger.LaunchDebugTargets4((uint)targets.Length, targets, results);
        }
コード例 #28
0
        private void LaunchDebugTarget(string filePath, string options)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsDebugger4 debugger = (IVsDebugger4)GetService(typeof(IVsDebugger));

            if (debugger != null)
            {
                VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
                debugTargets[0].dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
                debugTargets[0].bstrExe               = filePath;
                debugTargets[0].bstrOptions           = options;
                debugTargets[0].guidLaunchDebugEngine = Microsoft.MIDebugEngine.EngineConstants.EngineId;
                VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

                debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
            }
            else
            {
                throw new InvalidOperationException("Why is IVsDebugger4 null?");
            }
        }
コード例 #29
0
        /// <summary>
        /// Start GGP Debugger attached to the core file.
        /// </summary>
        void DebugWithGgpClicked(object sender, RoutedEventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var vsDebugger =
                (IVsDebugger4)ServiceProvider.GlobalProvider.GetService(typeof(IVsDebugger));

            Assumes.Present(vsDebugger);
            try
            {
                var debugTarget =
                    new VsDebugTargetInfo4
                {
                    dlo                   = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess,
                    bstrExe               = _filename,
                    bstrCurDir            = Path.GetTempPath(),
                    guidLaunchDebugEngine =
                        YetiConstants.DebugEngineGuid
                };
                VsDebugTargetInfo4[] debugTargets      = { debugTarget };
                uint debugTargetCount                  = 1;
                VsDebugTargetProcessInfo[] processInfo =
                    new VsDebugTargetProcessInfo[debugTargetCount];

                vsDebugger.LaunchDebugTargets4(debugTargetCount, debugTargets, processInfo);
            }
            catch (COMException exception)
            {
                if (exception.ErrorCode == Microsoft.VisualStudio.VSConstants.E_ABORT)
                {
                    Trace.WriteLine("Opening of core file aborted by the user.");
                }
                else
                {
                    string errorMessage = $"Failed to start debugger: {exception}";
                    Trace.WriteLine(errorMessage);
                    MessageBox.Show(ErrorStrings.FailedToStartDebugger, "Core dump debugger",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #30
0
        /// <summary>
        /// IVsDebuggableProjectCfg
        /// </summary>
        public int DebugLaunch(uint grfLaunch)
        {
            VsDebugTargetInfo4 info = new VsDebugTargetInfo4();

            info.dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            info.guidLaunchDebugEngine = CLSID_ComPlusOnlyDebugEngine4;

            // Note. A bug in the debugger will cause a failure if a PID is set but the exe name
            // is NULL. So we just blindly set it here.
            info.bstrExe     = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cmd.exe");
            info.bstrArg     = null;
            info.bstrCurDir  = null;
            info.LaunchFlags = grfLaunch;

            IVsDebugger4 debugger         = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4;
            var          debugTargetInfos = new VsDebugTargetInfo4[] { info };
            // Debugger will throw on failure
            var tpi = new VsDebugTargetProcessInfo[1];

            debugger.LaunchDebugTargets4(1, debugTargetInfos, tpi);
            return(VSConstants.S_OK);
        }
コード例 #31
0
        private bool AttachToProcessNode2DebugAdapter(int port)
        {
            var dte = (VisualStudio.OLE.Interop.IServiceProvider) this.GetDTE();

            var serviceProvider = new ServiceProvider(dte);

            // setup debug info and attach
            var pDebugEngine = Marshal.AllocCoTaskMem(Marshal.SizeOf <Guid>());
            var debugUri     = $"http://127.0.0.1:{port}";

            try
            {
                Marshal.StructureToPtr(Node2AttachEngineGuid, pDebugEngine, false);
                var dbgInfo = new VsDebugTargetInfo4()
                {
                    dlo                = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning,
                    pDebugEngines      = pDebugEngine,
                    dwDebugEngineCount = 1,
                    bstrExe            = "dummy",
                    guidPortSupplier   = WebkitPortSupplierGuid,
                    bstrPortName       = debugUri,
                    dwProcessId        = 1
                };

                var launchResults = new VsDebugTargetProcessInfo[1];
                var debugger      = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger));
                debugger.LaunchDebugTargets4(1, new[] { dbgInfo }, launchResults);
            }
            finally
            {
                if (pDebugEngine != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pDebugEngine);
                }
            }

            return(true);
        }
コード例 #32
0
        /// <summary>
        /// Launches the Visual Studio debugger.
        /// </summary>
        protected Task <IReadOnlyList <VsDebugTargetProcessInfo> > DoLaunchAsync(params IDebugLaunchSettings[] launchSettings)
        {
            VsDebugTargetInfo4[] launchSettingsNative = launchSettings.Select(GetDebuggerStruct4).ToArray();
            if (launchSettingsNative.Length == 0)
            {
                return(Task.FromResult <IReadOnlyList <VsDebugTargetProcessInfo> >(new VsDebugTargetProcessInfo[0]));
            }

            try
            {
                var shellDebugger = ServiceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4;
                var launchResults = new VsDebugTargetProcessInfo[launchSettingsNative.Length];
                shellDebugger.LaunchDebugTargets4((uint)launchSettingsNative.Length, launchSettingsNative, launchResults);
                return(Task.FromResult <IReadOnlyList <VsDebugTargetProcessInfo> >(launchResults));
            }
            finally
            {
                // Free up the memory allocated to the (mostly) managed debugger structure.
                foreach (var nativeStruct in launchSettingsNative)
                {
                    FreeVsDebugTargetInfoStruct(nativeStruct);
                }
            }
        }
コード例 #33
0
        private void LaunchDebugTarget(string filePath, string options)
        {
            IVsDebugger4 debugger = (IVsDebugger4)GetService(typeof(IVsDebugger));
            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe = filePath;
            debugTargets[0].bstrOptions = options;
            debugTargets[0].guidLaunchDebugEngine = Microsoft.MIDebugEngine.EngineConstants.EngineId;
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }
コード例 #34
0
ファイル: Connect.cs プロジェクト: ezhangle/DynamicPatcher
        public bool LaunchAndDoInject()
        {
            IVsOutputWindowPane output = (IVsOutputWindowPane)Package.GetGlobalService(typeof(SVsGeneralOutputWindowPane));

            String exepath = "";
            String workdir = "";
            String environment = "";
            String addindir = "";
            Solution sln = _applicationObject.Solution;
            String startup = (String)((Array)sln.SolutionBuild.StartupProjects).GetValue(0);
            foreach (EnvDTE.Project project in sln.Projects)
            {
                if (project.UniqueName == startup)
                {
                    VCProject vcproj = (VCProject)project.Object;
                    if (vcproj == null)
                    {
                        // this is not a visual c++ project
                        continue;
                    }
                    IVCCollection cfgs = vcproj.Configurations;
                    VCConfiguration cfg = cfgs.Item(1);
                    exepath = cfg.Evaluate("$(LocalDebuggerCommand)");
                    workdir = cfg.Evaluate("$(LocalDebuggerWorkingDirectory)");
                    environment = cfg.Evaluate("$(LocalDebuggerEnvironment)");
                    addindir = cfg.Evaluate("$(USERPROFILE)\\Documents\\Visual Studio 2012\\Addins");
                    output.OutputString(exepath);
                }
            }

            uint pid = dpVSHelper.ExecuteSuspended(exepath, addindir, environment);
            if (pid != 0)
            {
                VsDebugTargetProcessInfo[] res = new VsDebugTargetProcessInfo[1];
                VsDebugTargetInfo4[] info = new VsDebugTargetInfo4[1];
                info[0].bstrExe = exepath;
                info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
                //info[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AttachToSuspendedLaunchProcess; // somehow this makes debugger not work
                info[0].dwProcessId = pid;
                info[0].LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd | (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop;

                Guid guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid;
                IntPtr pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));
                Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
                info[0].pDebugEngines = pGuids;
                info[0].dwDebugEngineCount = 1;

                IVsDebugger4 idbg = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger));
                idbg.LaunchDebugTargets4(1, info, res);

                dpVSHelper.Resume(pid);
            }

            return true;
        }
コード例 #35
0
        public int DebugLaunch(uint flags)
        {
            VsDebugTargetInfo2[] targets;
            int hr = QueryDebugTargets(out targets);
            if (ErrorHandler.Failed(hr))
                return hr;

            flags |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask;

            VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1];
            int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4));

            appPackageDebugTarget[0].AppPackageLaunchInfo.AppUserModelID = DeployAppUserModelID;
            appPackageDebugTarget[0].AppPackageLaunchInfo.PackageMoniker = DeployPackageMoniker;

            appPackageDebugTarget[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug;
            appPackageDebugTarget[0].LaunchFlags = flags;
            appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine;
            appPackageDebugTarget[0].bstrExe = targets[0].bstrExe;
            appPackageDebugTarget[0].bstrArg = targets[0].bstrArg;
            appPackageDebugTarget[0].bstrCurDir = targets[0].bstrCurDir;
            appPackageDebugTarget[0].bstrEnv = targets[0].bstrEnv;
            appPackageDebugTarget[0].dwProcessId = targets[0].dwProcessId;
            appPackageDebugTarget[0].pStartupInfo = IntPtr.Zero; //?
            appPackageDebugTarget[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine;
            appPackageDebugTarget[0].dwDebugEngineCount = targets[0].dwDebugEngineCount;
            appPackageDebugTarget[0].pDebugEngines = targets[0].pDebugEngines;
            appPackageDebugTarget[0].guidPortSupplier = targets[0].guidPortSupplier;

            appPackageDebugTarget[0].bstrPortName = targets[0].bstrPortName;
            appPackageDebugTarget[0].bstrOptions = targets[0].bstrOptions;
            appPackageDebugTarget[0].fSendToOutputWindow = targets[0].fSendToOutputWindow;
            appPackageDebugTarget[0].pUnknown = targets[0].pUnknown;
            appPackageDebugTarget[0].guidProcessLanguage = targets[0].guidProcessLanguage;
            appPackageDebugTarget[0].project = this.project;

            // Pass the debug launch targets to the debugger
            System.IServiceProvider sp = this.project as System.IServiceProvider;
            IVsDebugger4 debugger4 = (IVsDebugger4)sp.GetService(typeof(SVsShellDebugger));
            VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1];

            debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results);

            return VSConstants.S_OK;
        }
コード例 #36
0
        public int DebugLaunch(uint flags)
        {
            VsDebugTargetInfo2[] targets;
            int hr = QueryDebugTargets(out targets);
            if (ErrorHandler.Failed(hr))
                return hr;

            flags |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask;

            VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1];
            int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4));

            this.CopyDebugTargetInfo(ref targets[0], ref appPackageDebugTarget[0], flags);
            if (TargetType.Phone == ActiveTargetType || TargetType.Remote == ActiveTargetType)
            {
                IVsAppContainerBootstrapperResult result = this.BootstrapForDebuggingSync(targets[0].bstrRemoteMachine);
                appPackageDebugTarget[0].bstrRemoteMachine = result.Address;
            }
            else if (TargetType.Local == ActiveTargetType)
            {
                appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine;
            }

            // Pass the debug launch targets to the debugger
            IVsDebugger4 debugger4 = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger));
            VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1];

            debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results);

            return VSConstants.S_OK;
        }
コード例 #37
0
        public int DebugLaunch(uint grfLaunch) {
            if (PythonConfig.IsAppxPackageableProject()) {
                VsDebugTargetInfo2[] targets;
                int hr = QueryDebugTargets(out targets);
                if (ErrorHandler.Failed(hr))
                    return hr;

                VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1];
                int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4));

                // Setup the app-specific parameters
                appPackageDebugTarget[0].AppPackageLaunchInfo.AppUserModelID = DeployAppUserModelID;
                appPackageDebugTarget[0].AppPackageLaunchInfo.PackageMoniker = DeployPackageMoniker;
                appPackageDebugTarget[0].AppPackageLaunchInfo.AppPlatform = VsAppPackagePlatform.APPPLAT_WindowsAppx;

                // Check if this project contains a startup task and set launch flag appropriately
                IVsBuildPropertyStorage bps = (IVsBuildPropertyStorage)this.PythonConfig;
                string canonicalName;
                string containsStartupTaskValue = null;
                bool containsStartupTask = false;

                get_CanonicalName(out canonicalName);

                bps.GetPropertyValue("ContainsStartupTask", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out containsStartupTaskValue);

                if (containsStartupTaskValue != null && bool.TryParse(containsStartupTaskValue, out containsStartupTask) && containsStartupTask) {
                    grfLaunch |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask;
                }

                appPackageDebugTarget[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug;
                appPackageDebugTarget[0].LaunchFlags = grfLaunch;
                appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine;
                appPackageDebugTarget[0].bstrExe = targets[0].bstrExe;
                appPackageDebugTarget[0].bstrArg = targets[0].bstrArg;
                appPackageDebugTarget[0].bstrCurDir = targets[0].bstrCurDir;
                appPackageDebugTarget[0].bstrEnv = targets[0].bstrEnv;
                appPackageDebugTarget[0].dwProcessId = targets[0].dwProcessId;
                appPackageDebugTarget[0].pStartupInfo = IntPtr.Zero;
                appPackageDebugTarget[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine;
                appPackageDebugTarget[0].dwDebugEngineCount = targets[0].dwDebugEngineCount;
                appPackageDebugTarget[0].pDebugEngines = targets[0].pDebugEngines;
                appPackageDebugTarget[0].guidPortSupplier = targets[0].guidPortSupplier;

                appPackageDebugTarget[0].bstrPortName = targets[0].bstrPortName;
                appPackageDebugTarget[0].bstrOptions = targets[0].bstrOptions;
                appPackageDebugTarget[0].fSendToOutputWindow = targets[0].fSendToOutputWindow;
                appPackageDebugTarget[0].pUnknown = targets[0].pUnknown;
                appPackageDebugTarget[0].guidProcessLanguage = targets[0].guidProcessLanguage;
                appPackageDebugTarget[0].project = PythonConfig;

                // Pass the debug launch targets to the debugger
                IVsDebugger4 debugger4 = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger));

                VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1];

                IVsDebugger debugger = (IVsDebugger)debugger4;

                // Launch task to monitor to attach to Python remote process
                var sourceDir = Path.GetFullPath(PythonConfig.GetProjectProperty("ProjectDir")).Trim('\\');
                var targetDir = Path.GetFullPath(this.LayoutDir).Trim('\\');
                var debugPort = PythonConfig.GetProjectProperty("RemoteDebugPort") ?? DefaultRemoteDebugPort;
                var debugId = Guid.NewGuid();
                var serializer = new JavaScriptSerializer();
                var debugCmdJson = serializer.Serialize(new string[] { "visualstudio_py_remote_launcher.py", debugPort.ToString(), debugId.ToString() });

                Debugger.PythonRemoteDebugEvents.Instance.RemoteDebugCommandInfo = Encoding.Unicode.GetBytes(debugCmdJson);
                Debugger.PythonRemoteDebugEvents.Instance.AttachRemoteProcessFunction = () => {
                    return RemoteProcessAttachAsync(
                         appPackageDebugTarget[0].bstrRemoteMachine,
                         debugId.ToString(),
                         debugPort,
                         sourceDir,
                         targetDir);
                };

                int result = debugger.AdviseDebugEventCallback(Debugger.PythonRemoteDebugEvents.Instance);

                if (result == VSConstants.S_OK) {
                    debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results);
                } else {
                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Failure {0}", result));
                }

                return result;
            } else {
                IVsDebuggableProjectCfg cfg = _pythonCfg as IVsDebuggableProjectCfg;
                if (cfg != null) {
                    return cfg.DebugLaunch(grfLaunch);
                }
                return VSConstants.E_NOTIMPL;
            }
        }
コード例 #38
0
        private void LaunchDebugTarget(string filePath)
        {
            var debugger = (IVsDebugger4)GetService(typeof(IVsDebugger));
            VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1];
            debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTargets[0].bstrExe = filePath;
            debugTargets[0].guidLaunchDebugEngine = new Guid(Microsoft.VisualStudio.Debugger.Lua.EngineConstants.EngineId);
            VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];

            debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
        }