Exemplo n.º 1
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;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public static CorDebugProcess CreateProcessEx(IDebugPort2 pPort, string lpApplicationName, string lpCommandLine, System.IntPtr lpProcessAttributes, System.IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, System.IntPtr lpEnvironment, string lpCurrentDirectory, ref _STARTUPINFO lpStartupInfo, ref _PROCESS_INFORMATION lpProcessInformation, uint debuggingFlags)
        {
            DebugPort port = pPort as DebugPort;
            if (port == null)
                throw new Exception("IDebugPort2 object passed to Micro Framework package by Visual Studio is not a valid device port");

            CommandLineBuilder cb = new CommandLineBuilder(lpCommandLine);
            string[] args = cb.Arguments;
            string deployDeviceName = args[args.Length-1];

            //Extract deployDeviceName
            if (!deployDeviceName.StartsWith(CorDebugProcess.c_DeployDeviceName))
                throw new Exception(String.Format("\"{0}\" does not appear to be a valid Micro Framework device name", CorDebugProcess.c_DeployDeviceName));

            deployDeviceName = deployDeviceName.Substring(CorDebugProcess.c_DeployDeviceName.Length);
            cb.RemoveArguments(args.Length - 1, 1);

            lpCommandLine = cb.ToString();

            CorDebugProcess process = port.IsLocalPort
                ? new CorDebugProcess(port, null)
                : port.GetDeviceProcess(deployDeviceName, 60);

            if (process == null)
                throw new Exception("CorDebugProcess.CreateProcessEx() could not create or find the device process");

            process.StoreAssemblyPaths(args);
            process.InternalCreateProcess(port, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, ref lpStartupInfo, ref lpProcessInformation, debuggingFlags);

            return process;
        }
Exemplo n.º 4
0
		public static CorDebugProcess CreateProcess (DebugPort pPort, string lpCommandLine)
		{
			CommandLineBuilder cb = new CommandLineBuilder (lpCommandLine);
			string[] args = cb.Arguments;
			string deployDeviceName = args [args.Length - 1];

			//Extract deployDeviceName
			if (!deployDeviceName.StartsWith (CorDebugProcess.c_DeployDeviceName))
				throw new Exception (String.Format ("\"{0}\" does not appear to be a valid Micro Framework device name", deployDeviceName));

			deployDeviceName = deployDeviceName.Substring (CorDebugProcess.c_DeployDeviceName.Length);
			cb.RemoveArguments (args.Length - 1, 1);

			lpCommandLine = cb.ToString ();
			//CorDebugProcess process = port.GetDeviceProcess(deployDeviceName, 60);
			CorDebugProcess process = pPort.GetDeviceProcess (deployDeviceName, 60);
			if (process == null)
				throw new Exception ("CorDebugProcess.CreateProcessEx() could not create or find the device process");

			process.StoreAssemblyPaths (args);

			bool fDidDeploy = true;     //What if we did a launch but no deploy to a device...

			if (!fDidDeploy) {
				process.Engine.RebootDevice (Engine.RebootOption.RebootClrWaitForDebugger);
			}

			return process;
		}
        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");
        }
        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);
            }
        }