private void GetCommandLineForLaunch(bool fNoDebug, PlatformInfo.Emulator emulatorConfig, CommandLineBuilder cb, bool fIsTargetBigEndian)
        {
            if (emulatorConfig != null)
            {
                if (!string.IsNullOrEmpty(emulatorConfig.config))
                {
                    cb.AddArguments("/config:" + emulatorConfig.config);
                }
            }

            if (!fNoDebug)
            {
                cb.AddArguments("/waitfordebugger");
            }

            foreach (string assembly in m_project.GetDependencies(true, true, fIsTargetBigEndian))
            {
                cb.AddArguments("/load:" + assembly);
            }

            string args = this.m_project.ProjectProperties.ActiveConfigurationSettings.StartArguments;

            args = args.Trim();
            if (args.Length > 0)
            {
                cb.AddArguments("/commandlinearguments:" + args);
            }
        }
        private string GetCommandLineForLaunch(bool fNoDebug, Debugger.PlatformInfo.Emulator emulatorConfig, bool fIsTargetBigEndian)
        {
            CommandLineBuilder cb = new CommandLineBuilder();

            if (emulatorConfig != null && !string.IsNullOrEmpty(emulatorConfig.additionalOptions))
            {
                CommandLineBuilder cbT = new CommandLineBuilder(emulatorConfig.additionalOptions);
                cb.AddArguments(cbT.Arguments);
            }

            if (emulatorConfig != null && emulatorConfig.legacyCommandLine)
            {
                GetCommandLineForLaunchLegacy(fNoDebug, emulatorConfig, cb, fIsTargetBigEndian);
            }
            else
            {
                GetCommandLineForLaunch(fNoDebug, emulatorConfig, cb, fIsTargetBigEndian);
            }

            string commandLine = cb.ToString();

            commandLine = Environment.ExpandEnvironmentVariables(commandLine);

            return(commandLine);
        }
        private void GetCommandLineForLaunchLegacy(bool fNoDebug, PlatformInfo.Emulator emulatorConfig, CommandLineBuilder cb, bool fIsTargetBigEndian)
        {
#if DEBUG   // TRACE has been removed from release builds
            cb.AddArguments("-Trace_MemoryStats", Utility.Boolean.BoolToInt(true));
#endif

            if (!fNoDebug)
            {
                cb.AddArguments("-PipeName", "");
            }

#if DEBUG
            cb.AddArguments("-Force_Compaction", Utility.Boolean.BoolToInt(true));
#endif

            string deviceCfg = Environment.GetEnvironmentVariable("CLRROOT");
            if (deviceCfg != null)
            {
                deviceCfg = Path.Combine(deviceCfg, "test.devicecfg");
                if (File.Exists(deviceCfg))
                {
                    cb.AddArguments("-devicecfg", deviceCfg);
                }
            }


            foreach (string assembly in m_project.GetDependencies(true, true, fIsTargetBigEndian))
            {
                cb.AddArguments("-load", assembly);
            }

            string args = this.m_project.ProjectProperties.ActiveConfigurationSettings.StartArguments;
            args = args.Trim();
            if (args.Length > 0)
            {
                cb.AddArguments("-commandLineArgs", args);
            }

            cb.AddArguments("-resolve");
            cb.AddArguments("-execute");
        }
Esempio n. 4
0
        public static Process LaunchEmulator(_DBG.PortDefinition_Emulator pd, bool fWaitForDebugger, string program)
        {
            _DBG.PlatformInfo          pi  = new _DBG.PlatformInfo(null);
            _DBG.PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port);

            _DBG.CommandLineBuilder cb = new _DBG.CommandLineBuilder();

            if (emu == null)
            {
                throw new ArgumentException();
            }
            if (emu.legacyCommandLine)
            {
                throw new NotSupportedException("Legacy emulators not supported.");
            }

            if (!string.IsNullOrEmpty(emu.additionalOptions))
            {
                _DBG.CommandLineBuilder cbT = new _DBG.CommandLineBuilder(emu.additionalOptions);
                cb.AddArguments(cbT.Arguments);
            }

            if (!string.IsNullOrEmpty(emu.config))
            {
                cb.AddArguments("/config:" + emu.config);
            }

            if (fWaitForDebugger)
            {
                cb.AddArguments("/waitfordebugger");
            }

            string[] files = EmulatorLauncher.GetFilesToLoad(program);
            foreach (string pe in files)
            {
                cb.AddArguments("/load:" + pe);
            }

            string args = "";

            args = args.Trim();
            if (args.Length > 0)
            {
                cb.AddArguments("/commandlinearguments:" + args);
            }

            string commandLine = cb.ToString();

            commandLine = Environment.ExpandEnvironmentVariables(commandLine);

            Process p = new System.Diagnostics.Process();

            p.StartInfo.FileName         = emu.application;
            p.StartInfo.Arguments        = commandLine;
            p.StartInfo.UseShellExecute  = false;
            p.StartInfo.WorkingDirectory = Path.GetDirectoryName(emu.application);

            try
            {
                p.Start();
            }
            catch (System.ComponentModel.Win32Exception we)
            {
                MessageBox.Show(string.Format("Failed to launch emulator: {0}", we.NativeErrorCode),
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            return(p);
        }
        public static Process LaunchEmulator(_DBG.PortDefinition_Emulator pd, bool fWaitForDebugger, string program)
        {
            _DBG.PlatformInfo pi = new _DBG.PlatformInfo(null);
            _DBG.PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port);

            _DBG.CommandLineBuilder cb = new _DBG.CommandLineBuilder();

            if (emu == null) { throw new ArgumentException(); }
            if (emu.legacyCommandLine) { throw new NotSupportedException("Legacy emulators not supported."); }

            if (!string.IsNullOrEmpty(emu.additionalOptions))
            {
                _DBG.CommandLineBuilder cbT = new _DBG.CommandLineBuilder(emu.additionalOptions);
                cb.AddArguments(cbT.Arguments);
            }

            if (!string.IsNullOrEmpty(emu.config))
            {
                cb.AddArguments("/config:" + emu.config);
            }

            if (fWaitForDebugger)
            {
                cb.AddArguments("/waitfordebugger");
            }

            string[] files = EmulatorLauncher.GetFilesToLoad(program);
            foreach (string pe in files)
            {
                cb.AddArguments("/load:" + pe);
            }

            string args = "";
            args = args.Trim();
            if (args.Length > 0)
            {
                cb.AddArguments("/commandlinearguments:" + args);
            }

            string commandLine = cb.ToString();
            commandLine = Environment.ExpandEnvironmentVariables(commandLine);

            Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = emu.application;
            p.StartInfo.Arguments = commandLine;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.WorkingDirectory = Path.GetDirectoryName(emu.application);

            try
            {
                p.Start();
            }
            catch (System.ComponentModel.Win32Exception we)
            {
                MessageBox.Show(string.Format("Failed to launch emulator: {0}", we.NativeErrorCode),
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            return p;
        }
        private string GetCommandLineForLaunch(bool fNoDebug, Debugger.PlatformInfo.Emulator emulatorConfig, bool fIsTargetBigEndian)
        {
            CommandLineBuilder cb = new CommandLineBuilder();

            if (emulatorConfig != null && !string.IsNullOrEmpty(emulatorConfig.additionalOptions))
            {
                CommandLineBuilder cbT = new CommandLineBuilder(emulatorConfig.additionalOptions);
                cb.AddArguments(cbT.Arguments);
            }

            if (emulatorConfig != null && emulatorConfig.legacyCommandLine)
            {
                GetCommandLineForLaunchLegacy(fNoDebug, emulatorConfig, cb, fIsTargetBigEndian);
            }
            else
            {
                GetCommandLineForLaunch(fNoDebug, emulatorConfig, cb, fIsTargetBigEndian);
            }

            string commandLine = cb.ToString();
            commandLine = Environment.ExpandEnvironmentVariables(commandLine);

            return commandLine;
        }