예제 #1
0
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            var dsi       = (MonoMacDebuggerStartInfo)startInfo;
            var startArgs = (SoftDebuggerRemoteArgs)dsi.StartArgs;
            var cmd       = dsi.ExecutionCommand;

            int assignedPort;

            StartListening(dsi, out assignedPort);

            Action <string> stdout = s => OnTargetOutput(false, s);
            Action <string> stderr = s => OnTargetOutput(true, s);

            var asi = new ApplicationStartInfo(cmd.AppPath);

            asi.Environment ["MONOMAC_DEBUGLAUNCHER_OPTIONS"]
                = string.Format("--debug --debugger-agent=transport=dt_socket,address={0}:{1}", startArgs.Address, assignedPort);

            process = MonoMacExecutionHandler.OpenApplication(cmd, asi, stdout, stderr);

            process.Completed += delegate {
                EndSession();
                process = null;
            };
        }
		public static MonoMacProcess OpenApplication (MonoMacExecutionCommand command, ApplicationStartInfo asi,
			Action<string> stdout, Action<string> stderr)
		{
			var logDir = command.AppPath.ParentDirectory;
			var outLog = logDir.Combine ("stdout.log");
			var errLog = logDir.Combine ("stderr.log");
			try {
				if (File.Exists (errLog))
				    File.Delete (errLog);
				if (File.Exists (outLog))
					File.Delete (outLog);
			} catch (IOException) {}
			
			var outTail = new Tail (outLog, stdout);
			var errTail = new Tail (errLog, stderr);
			outTail.Start ();
			errTail.Start ();
			
			if (asi == null)
				asi = new ApplicationStartInfo (command.AppPath);
			asi.NewInstance = true;
			
			//need async or we won't be able to debug things that happen while the app is launching
			asi.Async = true;
			
			var monoRuntime = (MonoDevelop.Core.Assemblies.MonoTargetRuntime)command.Runtime;
			
			//assume MD is running on /L/F/M.f/V/Current
			//if target runtime is different then override for bundle
			if (!monoRuntime.IsRunning) {
				asi.Environment ["MONOMAC_DEBUGLAUNCHER_RUNTIME"] = monoRuntime.Prefix;
			}
			
			asi.Environment ["MONOMAC_DEBUGLAUNCHER_LOGDIR"] = logDir;
			
			var psn = LaunchServices.OpenApplication (asi);
			return new MonoMacProcess (psn, outTail, errTail);
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (MonoMacDebuggerStartInfo) startInfo;
			var startArgs = (SoftDebuggerRemoteArgs) dsi.StartArgs;
			var cmd = dsi.ExecutionCommand;		
			
			int assignedPort;
			StartListening (dsi, out assignedPort);
			
			Action<string> stdout = s => OnTargetOutput (false, s);
			Action<string> stderr = s => OnTargetOutput (true, s);
			
			var asi = new ApplicationStartInfo (cmd.AppPath);
			asi.Environment ["MONOMAC_DEBUGLAUNCHER_OPTIONS"]
				= string.Format ("--debug --debugger-agent=transport=dt_socket,address={0}:{1}", startArgs.Address, assignedPort);
			
			process = MonoMacExecutionHandler.OpenApplication (cmd, asi, stdout, stderr);
			
			process.Completed += delegate {
				EndSession ();
				process = null;
			};
		}