Пример #1
0
        public RustProjectConfig(RustProjectNode project, string configuration)
            : base(project, configuration)
        {
            this.UserCfg = new Configuration.MsBuildConfiguration(project.UserConfig, configuration, "default");
            if (!initialized)
            {
                // Determine IDE version and whether GDB engine is installed (only in VS2015+)

                var     env = (EnvDTE.DTE)project.GetService(typeof(SDTE));
                Version ver;
                if (Version.TryParse(env.Version, out ver))
                {
                    isGdbSupported = ver.Major >= 14;
                }

                var    debugger = (IVsDebugger2)project.GetService(typeof(SVsShellDebugger));
                string name;
                Guid   gdbEngine = Constants.GdbEngine;
                if (debugger.GetEngineName(ref gdbEngine, out name) == 0)
                {
                    isGdbInstalled = true;
                    isGdbSupported = true;
                }

                initialized = true;
            }

            DebugType = isGdbInstalled ? Constants.GdbDebugger : Constants.BuiltinDebugger;
        }
Пример #2
0
        public RustProjectConfig(RustProjectNode project, string configuration)
            : base(project, configuration)
        {
            this.UserCfg = new Configuration.MsBuildConfiguration(project.UserConfig, configuration, "default");
            if (!initialized)
            {
                // Determine IDE version and whether GDB engine is installed (only in VS2015+)

                var env = (EnvDTE.DTE)project.GetService(typeof(SDTE));
                Version ver;
                if (Version.TryParse(env.Version, out ver))
                {
                    isGdbSupported = ver.Major >= 14;
                }

                var debugger = (IVsDebugger2)project.GetService(typeof(SVsShellDebugger));
                string name;
                Guid gdbEngine = Constants.GdbEngine;
                if (debugger.GetEngineName(ref gdbEngine, out name) == 0)
                {
                    isGdbInstalled = true;
                    isGdbSupported = true;
                }

                initialized = true;
            }

            DebugType = isGdbInstalled ? Constants.GdbDebugger : Constants.BuiltinDebugger;
        }
Пример #3
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);
        }
Пример #4
0
        private void LaunchInGdbDebugger(string file)
        {
            var targets = new VsDebugTargetInfo4[1];

            targets[0].dlo     = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            targets[0].bstrExe = file;
            targets[0].guidLaunchDebugEngine = new Guid(EngineConstants.EngineId);

            bool   useCustomPath = GetDebugProperty <bool>("UseCustomGdbPath");
            string gdbPath;

            if (useCustomPath)
            {
                gdbPath = GetDebugProperty <string>("DebuggerLocation");
            }
            else
            {
                gdbPath = Path.Combine(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                    "gdb",
                    GuessArchitecture(),
                    "bin\\gdb");
            }
            string gdbArgs =
                "-q " +                                 // quiet
                "-interpreter=mi " +                    // use machine interface
                GetDebugProperty <string>("ExtraArgs"); // add extra options from Visual Rust/Debugging options page

            var options = new StringBuilder();

            using (var writer = XmlWriter.Create(options, new XmlWriterSettings {
                OmitXmlDeclaration = true
            }))
            {
                writer.WriteStartElement("PipeLaunchOptions", "http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014");
                writer.WriteAttributeString("PipePath", gdbPath);
                writer.WriteAttributeString("PipeArguments", gdbArgs);
                writer.WriteAttributeString("ExePath", EscapePath(file));
                if (!string.IsNullOrEmpty(debugConfig.CommandLineArgs))
                {
                    writer.WriteAttributeString("ExeArguments", debugConfig.CommandLineArgs);
                }
                if (!string.IsNullOrEmpty(debugConfig.WorkingDir))
                {
                    writer.WriteAttributeString("WorkingDirectory", EscapePath(debugConfig.WorkingDir));
                    // GDB won't search working directory by default, but this is expected on Windows.
                    string rustBinPath = RustBinPath();
                    string additionalPath;
                    if (rustBinPath != null)
                    {
                        additionalPath = rustBinPath + ";" + debugConfig.WorkingDir;
                    }
                    else
                    {
                        additionalPath = debugConfig.WorkingDir;
                    }
                    writer.WriteAttributeString("AdditionalSOLibSearchPath", additionalPath);
                }
                else
                {
                    writer.WriteAttributeString("WorkingDirectory", EscapePath(Path.GetDirectoryName(file)));
                    string rustBinPath = RustBinPath();
                    if (rustBinPath != null)
                    {
                        writer.WriteAttributeString("AdditionalSOLibSearchPath", rustBinPath);
                    }
                }
                // this affects the number of bytes the engine reads when disassembling commands,
                // x64 has the largest maximum command size, so it should be safe to use for x86 as well
                writer.WriteAttributeString("TargetArchitecture", "x64");

                // GDB engine expects to find a shell on the other end of the pipe, so the first thing it sends over is "gdb --interpreter=mi",
                // (which GDB complains about, since this isn't a valid command).
                // Since we are launching GDB directly, here we create a noop alias for "gdb" to make the error message go away.
                writer.WriteElementString("Command", "alias -a gdb=echo");
                // launch debuggee in a new console window
                writer.WriteElementString("Command", "set new-console on");
                if (!string.IsNullOrEmpty(debugConfig.DebuggerScript))
                {
                    foreach (string cmd in debugConfig.DebuggerScript.Split('\r', '\n'))
                    {
                        if (!string.IsNullOrEmpty(cmd))
                        {
                            writer.WriteElementString("Command", cmd);
                        }
                    }
                }

                writer.WriteEndElement();
            }
            targets[0].bstrOptions = options.ToString();

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

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

            vsDebugger.LaunchDebugTargets4((uint)targets.Length, targets, results);
        }