protected override void OnRun(DebuggerStartInfo startInfo)
        {
            if (process != null)
                throw new InvalidOperationException("Already debugging!");

            var dsi = (MonobjcDebuggerStartInfo) startInfo;
            var cmd = dsi.ExecutionCommand;

            StartListening(dsi);

            var psi = new System.Diagnostics.ProcessStartInfo(cmd.CommandString) {
                Arguments = cmd.Arguments,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                RedirectStandardInput = true,
                UseShellExecute = false
            };
            psi.EnvironmentVariables["MONO_OPTIONS"] = String.Format("--debug --debugger-agent=transport=dt_socket,address={0}:{1}", dsi.Address, dsi.DebugPort);

            foreach (var kv in cmd.EnvironmentVariables)
                psi.EnvironmentVariables[kv.Key] = kv.Value;

            process = System.Diagnostics.Process.Start(psi);

            ConnectOutput(process.StandardOutput, false);
            ConnectOutput(process.StandardError, true);

            process.EnableRaisingEvents = true;
            process.Exited += delegate {
                EndSession();
                process = null;
            };
        }
예제 #2
0
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			lock (gdbLock) {
				// Create a script to be run in a terminal
				string script = Path.GetTempFileName ();
				string ttyfile = Path.GetTempFileName ();
				string ttyfileDone = ttyfile + "_done";
				string tty;
				
				try {
					File.WriteAllText (script, "tty > " + ttyfile + "\ntouch " + ttyfileDone + "\nsleep 10000d");
					Mono.Unix.Native.Syscall.chmod (script, FilePermissions.ALLPERMS);
					
					console = Runtime.ProcessService.StartConsoleProcess (script, "", ".", ExternalConsoleFactory.Instance.CreateConsole (true), null);
					DateTime tim = DateTime.Now;
					while (!File.Exists (ttyfileDone)) {
						System.Threading.Thread.Sleep (100);
						if ((DateTime.Now - tim).TotalSeconds > 10)
							throw new InvalidOperationException ("Console could not be created.");
					}
					tty = File.ReadAllText (ttyfile).Trim (' ','\n');
				} finally {
					try {
						if (File.Exists (script))
							File.Delete (script);
						if (File.Exists (ttyfile))
							File.Delete (ttyfile);
						if (File.Exists (ttyfileDone))
							File.Delete (ttyfileDone);
					} catch {
						// Ignore
					}
				}
				
				StartGdb ();
				
				// Initialize the terminal
				RunCommand ("-inferior-tty-set", Escape (tty));
				
				try {
					RunCommand ("-file-exec-and-symbols", Escape (startInfo.Command));
				} catch {
					FireTargetEvent (TargetEventType.TargetExited, null);
					throw;
				}

				RunCommand ("-environment-cd", Escape (startInfo.WorkingDirectory));
				
				// Set inferior arguments
				if (!string.IsNullOrEmpty (startInfo.Arguments))
					RunCommand ("-exec-arguments", startInfo.Arguments);
				
				currentProcessName = startInfo.Command + " " + startInfo.Arguments;
				
				CheckIsMonoProcess ();
				OnStarted ();
				
				RunCommand ("-exec-run");
			}
		}
		public DebuggerStartInfo CreateDebuggerStartInfo (ExecutionCommand command)
		{
			DotNetExecutionCommand cmd = command as DotNetExecutionCommand;
			if (cmd != null) {
				DebuggerStartInfo startInfo = new DebuggerStartInfo ();
				startInfo.Command = cmd.Command;
				startInfo.Arguments = cmd.Arguments;
				startInfo.WorkingDirectory = cmd.WorkingDirectory;
				if (cmd.EnvironmentVariables.Count > 0) {
					foreach (KeyValuePair<string, string> val in cmd.EnvironmentVariables)
						startInfo.EnvironmentVariables[val.Key] = val.Value;
				}
				return startInfo;
			}
			AspNetExecutionCommand acmd = command as AspNetExecutionCommand;
			if (acmd != null) {
				DebuggerStartInfo startInfo = new DebuggerStartInfo ();
				string xspName = (acmd.ClrVersion == ClrVersion.Net_1_1) ? "xsp" : "xsp2";
				string xspPath = acmd.TargetRuntime.GetToolPath (acmd.TargetFramework, xspName);
				if (!File.Exists (xspPath))
					throw new UserException (string.Format ("The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null);

				startInfo.Command = xspPath;
				startInfo.Arguments = acmd.XspParameters.GetXspParameters () + " --nonstop";
				startInfo.WorkingDirectory = acmd.BaseDirectory;

				// Set DEVPATH when running on Windows (notice that this has no effect unless
				// <developmentMode developerInstallation="true" /> is set in xsp2.exe.config

				startInfo.EnvironmentVariables["DEVPATH"] = Path.GetDirectoryName (xspPath);
				return startInfo;
			}
			throw new NotSupportedException ();
		}
		protected override string GetConnectingMessage (DebuggerStartInfo startInfo)
		{
			var dsi = (TizenSoftDebuggerStartInfo) startInfo;
			var dra = (SoftDebuggerRemoteArgs) dsi.StartArgs;

			return string.Format ("Waiting for debugger to connect on {0}:{1}...", dra.Address, dra.DebugPort);
		}
		/*protected override string GetConnectingMessage (SoftDebuggerStartInfo dsi)
		{
			return string.Format ("Waiting for debugger to connect on {0}:{1}...", dsi.Address, dsi.DebugPort);
		}*/
		protected override void OnRun(DebuggerStartInfo startInfo)
		{
			var dsi = (MonoBrickSoftDebuggerStartInfo)startInfo;
			StartProcess(dsi);
			Thread.Sleep(500);
			StartConnecting(dsi);
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (MoonlightDebuggerStartInfo) startInfo;
			int assignedDebugPort;
			StartListening (dsi, out assignedDebugPort);
			StartBrowserProcess (dsi, assignedDebugPort);
		}
        /// <summary>
        ///   Called when debugger runs.
        /// </summary>
        /// <param name = "startInfo">The start info.</param>
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            MonobjcDebuggerStartInfo dsi = (MonobjcDebuggerStartInfo)startInfo;
            SoftDebuggerRemoteArgs startArgs = (SoftDebuggerRemoteArgs)dsi.StartArgs;
            MonobjcExecutionCommand command = dsi.ExecutionCommand;

            int assignedPort;
            this.StartListening (dsi, out assignedPort);

            // Create the start information
            ProcessStartInfo psi = new ProcessStartInfo (command.CommandString) { Arguments = command.CommandLineParameters, RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true, UseShellExecute = false };
            psi.EnvironmentVariables ["MONO_OPTIONS"] = string.Format ("--debug --debugger-agent=transport=dt_socket,address={0}:{1}", startArgs.Address, assignedPort);

            // Try to start the process
            this.process = Process.Start (psi);
            if (this.process == null) {
                this.EndSession ();
                return;
            }

            // Connect the stdout and stderr to the MonoDevelop's output
            this.ConnectOutput (this.process.StandardOutput, false);
            this.ConnectOutput (this.process.StandardError, true);

            // When process exits, end the session
            this.process.EnableRaisingEvents = true;
            this.process.Exited += delegate {
                this.EndSession ();
                this.process = null;
            };
        }
예제 #8
0
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (MonoMacDebuggerStartInfo) startInfo;
			var cmd = dsi.ExecutionCommand;		
		
			StartListening (dsi);
			
			var psi = new ProcessStartInfo (cmd.LaunchScript) {
				Arguments = "",
				RedirectStandardOutput = true,
				RedirectStandardError = true,
				UseShellExecute = false
			};
			psi.EnvironmentVariables["MONO_OPTIONS"] = 
				string.Format ("--debug --debugger-agent=transport=dt_socket,address={0}:{1}",
				              dsi.Address, dsi.DebugPort);
			
			process = System.Diagnostics.Process.Start (psi);
			
			ConnectOutput (process.StandardOutput, false);
			ConnectOutput (process.StandardError, true);
			
			process.EnableRaisingEvents = true;
			process.Exited += delegate {
				EndSession ();
				process = null;
			};
		}
예제 #9
0
        public void Run(DebuggerStartInfo startInfo, DebuggerSessionOptions options)
        {
            if (startInfo == null)
            {
                throw new ArgumentNullException("startInfo");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            lock (slock) {
                this.options = options;
                OnRunning();
                Dispatch(delegate {
                    try {
                        OnRun(startInfo);
                    } catch (Exception ex) {
                        ForceExit();
                        if (!HandleException(ex))
                        {
                            throw;
                        }
                    }
                });
            }
        }
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			started = true;
			MonoDebuggerStartInfo info = (MonoDebuggerStartInfo) startInfo;
			controller.StartDebugger (info);
			InitMdbVersion (info.MonoPrefix);
			controller.DebuggerServer.Run (info, Options);
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (IPhoneDebuggerStartInfo) startInfo;
			var cmd = dsi.ExecutionCommand;
			if (cmd.Simulator)
				StartSimulatorProcess (cmd);
			StartListening (dsi);
		}
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            var dsi = (CemonoDebuggerStartInfo)startInfo;

            int debugPort;
            StartListening(dsi, out debugPort);

            // Start process
        }
예제 #13
0
		protected override void OnRun(DebuggerStartInfo startInfo)
		{
			var dsi = (SoftDebuggerStartInfo)startInfo;
            if (dsi.StartArgs is SoftDebuggerConnectArgs)
			    base.StartConnecting(dsi);
            else if (dsi.StartArgs is SoftDebuggerListenArgs)
                base.StartListening(dsi);
            else
                throw new NotImplementedException();
		}
		public override DebuggerStartInfo CreateDebuggerStartInfo (ExecutionCommand command)
		{
			NativeExecutionCommand pec = (NativeExecutionCommand) command;
			DebuggerStartInfo startInfo = new DebuggerStartInfo ();
			startInfo.Command = pec.Command;
			startInfo.Arguments = pec.Arguments;
			startInfo.WorkingDirectory = pec.WorkingDirectory;
			if (pec.EnvironmentVariables.Count > 0) {
				foreach (KeyValuePair<string,string> val in pec.EnvironmentVariables)
					startInfo.EnvironmentVariables [val.Key] = val.Value;
			}
			return startInfo;
		}
예제 #15
0
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			if (exited)
				throw new InvalidOperationException ("Already exited");
			
			var dsi = (SoftDebuggerStartInfo) startInfo;
			var runtime = Path.Combine (Path.Combine (dsi.MonoRuntimePrefix, "bin"), "mono");
			RegisterUserAssemblies (dsi.UserAssemblyNames);
			
			var psi = new System.Diagnostics.ProcessStartInfo (runtime) {
				Arguments = string.Format ("\"{0}\" {1}", dsi.Command, dsi.Arguments),
				WorkingDirectory = dsi.WorkingDirectory,
				RedirectStandardOutput = true,
				RedirectStandardError = true,
				UseShellExecute = false,
				CreateNoWindow = true,
			};
			
			LaunchOptions options = null;
			
			if (dsi.UseExternalConsole && dsi.ExternalConsoleLauncher != null) {
				options = new LaunchOptions ();
				options.CustomTargetProcessLauncher = dsi.ExternalConsoleLauncher;
				psi.RedirectStandardOutput = false;
				psi.RedirectStandardError = false;
			}

			var sdbLog = Environment.GetEnvironmentVariable ("MONODEVELOP_SDB_LOG");
			if (!String.IsNullOrEmpty (sdbLog)) {
				options = options ?? new LaunchOptions ();
				options.AgentArgs = string.Format ("loglevel=1,logfile='{0}'", sdbLog);
			}
			
			foreach (var env in dsi.MonoRuntimeEnvironmentVariables)
				psi.EnvironmentVariables[env.Key] = env.Value;
			
			foreach (var env in startInfo.EnvironmentVariables)
				psi.EnvironmentVariables[env.Key] = env.Value;
			
			if (!String.IsNullOrEmpty (dsi.LogMessage))
				OnDebuggerOutput (false, dsi.LogMessage + "\n");

			OnConnecting (VirtualMachineManager.BeginLaunch (psi, HandleCallbackErrors (delegate (IAsyncResult ar) {
					HandleConnection (VirtualMachineManager.EndLaunch (ar));
				}),
				options
			));
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var mfStartInfo = startInfo as MicroFrameworkDebuggerStartInfo;
			if (mfStartInfo == null)//This should never happen...
				throw new InvalidOperationException ();
			var command = mfStartInfo.MFCommand;
			var portDefinition = ((MicroFrameworkExecutionTarget)command.Target).PortDefinition;
			using (var deployEngine = new Engine (portDefinition)) {
				deployEngine.Start ();

				string newCommand = "/CorDebug_DeployDeviceName:" + portDefinition.PersistName;

				var listOfAseemblies = new ArrayList ();

				//TODO: Check if this is robust enough will "be" and "le" really always be in output folder?
				OutputDirectory = command.OutputDirectory;
				string dir = command.OutputDirectory;
				if (deployEngine.IsTargetBigEndian)
					dir = Path.Combine (dir, "be");
				else
					dir = Path.Combine (dir, "le");

				string[] files = Directory.GetFiles (dir, "*.pe");
				foreach (var file in files) {
					newCommand = "/load:" + file + " " + newCommand;
					using (var fs = new FileStream (file, FileMode.Open)) {
						byte[] data = new byte[fs.Length];
						fs.Read (data, 0, data.Length);
						listOfAseemblies.Add (data);
					}
				}
				startInfo.Command = newCommand;
				deployEngine.Deployment_Execute (listOfAseemblies, false, (str) => OnDebuggerOutput (false, "Deploy: " + str + Environment.NewLine));
				deployEngine.RebootDevice (Engine.RebootOption.RebootClrWaitForDebugger);
			}
			VsPackage.MessageCentre.Session = this;
			try {
				CorDebugProcess process = CorDebugProcess.CreateProcess (new DebugPortSupplier ().FindPort ("USB"), startInfo.Command);
				process.StartDebugging (this, false);
				// StartDebugging() will either get a connected device into a debuggable state and start the dispatch thread, or throw.
			} catch (ProcessExitException) {
				VsPackage.MessageCentre.DeploymentMsg (DiagnosticStrings.InitializeProcessFailedProcessDied);
			} catch (Exception ex) {
				VsPackage.MessageCentre.DeploymentMsg (DiagnosticStrings.InitializeProcessFailed);
				VsPackage.MessageCentre.InternalErrorMsg (false, ex.Message);
			}
		}
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            try{
                if (startInfo == null) {
                    EndSession ();
                    return;
                }

                base.OnRun (startInfo);
            }catch (Exception ex) {
                Gtk.Application.Invoke (delegate {
                    using (var md = new MessageDialog (null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, ex.Message)) {
                        md.Title = "CustomSoftDebuggerSession";
                        md.Run ();
                        md.Destroy ();
                    }
                });
            }
        }
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (MonoDroidDebuggerStartInfo) startInfo;
			var cmd = dsi.ExecutionCommand;
			
			string monoOptions = string.Format ("debug={0}:{1}:{2}", dsi.Address, dsi.DebugPort, dsi.OutputPort);
			process = MonoDroidFramework.Toolbox.StartActivity (cmd.Device, cmd.Activity, monoOptions,
				ProcessOutput, ProcessError);
			
			process.Completed += delegate {
				process = null;
			};
			
			TargetExited += delegate {
				EndProcess ();
			};
			
			StartListening (dsi);
		}
		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;
			};
		}
예제 #20
0
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			// Create the debugger

			string dversion;
			try {
				dversion = CorDebugger.GetDebuggerVersionFromFile (startInfo.Command);
			}
			catch {
				dversion = CorDebugger.GetDefaultDebuggerVersion ();
			}
			dbg = new CorDebugger (dversion);

			Dictionary<string, string> env = new Dictionary<string, string> ();
			foreach (DictionaryEntry de in Environment.GetEnvironmentVariables ())
				env[(string) de.Key] = (string) de.Value;

			foreach (KeyValuePair<string, string> var in startInfo.EnvironmentVariables)
				env[var.Key] = var.Value;

            // The second parameter of CreateProcess is the command line, and it includes the application being launched
            string cmdLine = "\"" + startInfo.Command + "\" " + startInfo.Arguments;

			int flags = 0;
			if (!startInfo.UseExternalConsole) {
				flags = 0x08000000; /* CREATE_NO_WINDOW*/
				flags |= CorDebugger.CREATE_REDIRECT_STD;
			}

			process = dbg.CreateProcess (startInfo.Command, cmdLine, startInfo.WorkingDirectory, env, flags);
			processId = process.Id;

			process.OnCreateProcess += new CorProcessEventHandler (OnCreateProcess);
			process.OnCreateAppDomain += new CorAppDomainEventHandler (OnCreateAppDomain);
			process.OnAssemblyLoad += new CorAssemblyEventHandler (OnAssemblyLoad);
			process.OnAssemblyUnload += new CorAssemblyEventHandler (OnAssemblyUnload);
			process.OnCreateThread += new CorThreadEventHandler (OnCreateThread);
			process.OnThreadExit += new CorThreadEventHandler (OnThreadExit);
			process.OnModuleLoad += new CorModuleEventHandler (OnModuleLoad);
			process.OnModuleUnload += new CorModuleEventHandler (OnModuleUnload);
			process.OnProcessExit += new CorProcessEventHandler (OnProcessExit);
			process.OnUpdateModuleSymbols += new UpdateModuleSymbolsEventHandler (OnUpdateModuleSymbols);
			process.OnDebuggerError += new DebuggerErrorEventHandler (OnDebuggerError);
			process.OnBreakpoint += new BreakpointEventHandler (OnBreakpoint);
			process.OnStepComplete += new StepCompleteEventHandler (OnStepComplete);
			process.OnBreak += new CorThreadEventHandler (OnBreak);
			process.OnNameChange += new CorThreadEventHandler (OnNameChange);
			process.OnEvalComplete += new EvalEventHandler (OnEvalComplete);
			process.OnEvalException += new EvalEventHandler (OnEvalException);
			process.OnLogMessage += new LogMessageEventHandler (OnLogMessage);
			process.OnStdOutput += new CorTargetOutputEventHandler (OnStdOutput);

			process.Continue (false);

			OnStarted ();
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (MonoDroidDebuggerStartInfo) startInfo;
			var cmd = dsi.ExecutionCommand;
			debugDevice = cmd.Device;
			
			bool alreadyForwarded = MonoDroidFramework.DeviceManager.GetDeviceIsForwarded (cmd.Device.ID);
			if (!alreadyForwarded)
				MonoDroidFramework.DeviceManager.SetDeviceLastForwarded (null);
			
			long date = 0;
			int runningProcessId = 0; // Already running activity
			DateTime setPropertyTime = DateTime.MinValue;
			launchOp = new ChainedAsyncOperationSequence (
				new ChainedAsyncOperation<AndroidToolbox.GetDateOperation> () {
					Create = () => MonoDroidFramework.Toolbox.GetDeviceDate (cmd.Device),
					Completed = (op) => {
						if (op.Success) {
							date = op.Date;
							setPropertyTime = DateTime.Now;
						} else {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to get date from device"));
							this.OnDebuggerOutput (true, op.GetOutput ());
						}
					},
				},
				new ChainedAsyncOperation<AndroidToolbox.AdbOutputOperation> () {
					Create = () => {
						this.OnDebuggerOutput (false, GettextCatalog.GetString ("Setting debug property") + "\n");
						long expireDate = date + (DEBUGGER_TIMEOUT_MS / 1000);
						string monoOptions = string.Format ("debug={0}:{1}:{2},timeout={3},server=y", dsi.Address, dsi.DebugPort, 0, expireDate);
						return MonoDroidFramework.Toolbox.SetProperty (cmd.Device, "debug.mono.extra", monoOptions);
					},
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to set debug property on device"));
							this.OnDebuggerOutput (true, op.GetOutput ());
						} else {
							debugPropertySet = true;
						}
					}
				},
				new ChainedAsyncOperation () {
					Skip = () => alreadyForwarded? "" : null,
					Create = () => {
						this.OnDebuggerOutput (false, GettextCatalog.GetString ("Forwarding debugger port") + "\n");
						return MonoDroidFramework.Toolbox.ForwardPort (cmd.Device, dsi.DebugPort, dsi.DebugPort, DebuggerOutput, DebuggerError);
					},
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to forward port on device"));
						}
					}
				},
				new ChainedAsyncOperation () {
					Skip = () => alreadyForwarded? "" : null,
					Create = () => {
						this.OnDebuggerOutput (false, GettextCatalog.GetString ("Forwarding console port") + "\n");
						return MonoDroidFramework.Toolbox.ForwardPort (cmd.Device, dsi.OutputPort, dsi.OutputPort, DebuggerOutput, DebuggerError);
					},
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to forward port on device"));
						} else {
							MonoDroidFramework.DeviceManager.SetDeviceLastForwarded (cmd.Device.ID);
						}
					}
				},
				new ChainedAsyncOperation<AdbGetProcessIdOperation> () {
					Create = () => new AdbGetProcessIdOperation (cmd.Device, cmd.PackageName),
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, "Error trying to detect already running process");
						} else if (op.ProcessId > 0) {
							this.OnDebuggerOutput (false, GettextCatalog.GetString ("Already running activity detected, restarting it in debug mode") + "\n");
							runningProcessId = op.ProcessId;
						}
					}
				},
				new ChainedAsyncOperation () {
					Skip = () => runningProcessId <= 0 ? "" : null,
					Create = () => new AdbShellOperation (cmd.Device, "kill " + runningProcessId),
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to stop already running activity"));
						}
					}
				},
				new ChainedAsyncOperation () {
					Create = () => MonoDroidFramework.Toolbox.StartActivity (cmd.Device, cmd.Activity, DebuggerOutput, DebuggerError),
					Completed = (op) => {
						if (!op.Success)
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to start activity"));
					}
				}
			);
			launchOp.Completed += delegate (IAsyncOperation op) {
				if (!op.Success) {
					EndSession ();
					return;
				}
				launchOp = null;
					
				Action<string> stdout = s => OnTargetOutput (false, s);
				Action<string> stderr = s => OnTargetOutput (true, s);

				trackProcessOp = new MonoDroidProcess (cmd.Device, cmd.Activity, cmd.PackageName, stdout, stderr);
				trackProcessOp.Completed += delegate {
					EndSession ();
				};
			
				System.Threading.Thread.Sleep (WAIT_BEFORE_CONNECT_MS);
				
				var msSinceSetProperty = (long) Math.Floor ((DateTime.Now - setPropertyTime).TotalMilliseconds);
				long msTillPropertyExpires = DEBUGGER_TIMEOUT_MS - msSinceSetProperty;
				
				if (msTillPropertyExpires < 100 || msTillPropertyExpires > DEBUGGER_TIMEOUT_MS)
					return;
				
				int retries = (int) Math.Floor ((double)  msTillPropertyExpires / WAIT_BEFORE_RETRY_MS) - 2;
				
				StartConnecting (dsi, retries, WAIT_BEFORE_RETRY_MS);
			};
			
			TargetExited += delegate {
				EndLaunch ();
			};
			
			launchOp.Start ();
		}
예제 #22
0
		void ConnectionStarting (IAsyncResult connectionHandle, DebuggerStartInfo dsi) 
		{
			if (this.connectionHandle != null && !this.connectionHandle.IsCompleted)
				throw new InvalidOperationException ("Already connecting");
			bool retrying = this.connectionHandle != null;
			this.connectionHandle = connectionHandle;
			OnConnectionStarting (dsi, retrying);
		}
예제 #23
0
		/// <summary>
		/// Called when the debugger starts connecting.
		/// </summary>
		protected virtual void OnConnectionStarting (DebuggerStartInfo dsi, bool retrying)
		{
		}
예제 #24
0
		public void SetMessage (DebuggerStartInfo dsi, string message, bool listening, int attemptNumber)
		{
			//FIXME: we don't support changing the message
			if (disposed || cts != null)
				return;
			
			cts = new System.Threading.CancellationTokenSource ();
			
			//MessageService is threadsafe but we want this to be async
			Gtk.Application.Invoke (delegate {
				RunDialog (message);
			});
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (UnityDebuggerStartInfo) startInfo;
			StartUnity(dsi);
			StartListening(dsi);
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (MeeGoSoftDebuggerStartInfo) startInfo;
			StartProcess (dsi);
			StartListening (dsi);
		}
예제 #27
0
 protected abstract void OnRun(DebuggerStartInfo startInfo);
		protected virtual string GetConnectingMessage (DebuggerStartInfo dsi)
		{
			return null;
		}
		void ConnectionStarting (IAsyncResult connectionHandle, DebuggerStartInfo dsi, bool listening, int attemptNumber) 
		{
			if (this.connectionHandle != null && (attemptNumber == 0 || !this.connectionHandle.IsCompleted))
				throw new InvalidOperationException ("Already connecting");
			
			this.connectionHandle = connectionHandle;
			
			if (ConnectionDialogCreator != null && attemptNumber == 0) {
				connectionDialog = ConnectionDialogCreator ();
				connectionDialog.UserCancelled += delegate {
					EndSession ();
				};
			}
			if (connectionDialog != null)
				connectionDialog.SetMessage (dsi, GetConnectingMessage (dsi), listening, attemptNumber);
		}
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			if (exited)
				throw new InvalidOperationException ("Already exited");
			
			var dsi = (SoftDebuggerStartInfo) startInfo;
			if (dsi.StartArgs is SoftDebuggerLaunchArgs) {
				StartLaunching (dsi);
			} else if (dsi.StartArgs is SoftDebuggerConnectArgs) {
				StartConnecting (dsi);
			} else if (dsi.StartArgs is SoftDebuggerListenArgs) {
				StartListening (dsi);
			} else if (dsi.StartArgs.ConnectionProvider != null) {
				StartConnection (dsi);
			} else {
				throw new ArgumentException ("StartArgs has no ConnectionProvider");
			}
		}
예제 #31
0
		public void SetMessage (DebuggerStartInfo dsi, string message, bool listening, int attemptNumber)
		{
			if (disposed)
				return;
			
			if (string.IsNullOrEmpty (message))
				message = DefaultListenMessage;
			
			if (dialog == null) {
				Gtk.Application.Invoke (delegate {
					if (disposed)
						return;
					RunDialog (message);
				});
			} else {
				Gtk.Application.Invoke (delegate {
					if (disposed)
						return;
					if (label != null)
						label.Text = message;
				});
			}
		}
		protected override string GetConnectingMessage (DebuggerStartInfo dsi)
		{
			Ide.DispatchService.GuiDispatch (() =>
				Ide.IdeApp.Workbench.CurrentLayout = "Debug"
			);
			return base.GetConnectingMessage (dsi);
		}