Run() public method

public Run ( DebuggerSession session ) : Process
session DebuggerSession
return Process
Exemplo n.º 1
0
        public Process Start()
        {
            if ((debugger != null) || (main_process != null))
                throw new TargetException (TargetError.AlreadyHaveTarget);

            if (!IsScript)
                Print ("Starting program: {0} {1}", Options.File,
                       String.Join (" ", Options.InferiorArgs));

            try {
                debugger = new Debugger (config);

                new InterpreterEventSink (this, debugger);

                CommandResult result;
                current_process = main_process = debugger.Run (session, out result);
                current_thread = current_process.MainThread;

                Wait (result);

                return current_process;
            } catch (TargetException) {
                debugger.Dispose ();
                debugger = null;
                throw;
            }
        }
Exemplo n.º 2
0
        public void Run(MonoDebuggerStartInfo startInfo, DebuggerSessionOptions sessionOptions)
        {
            try {
                if (startInfo == null)
                {
                    throw new ArgumentNullException("startInfo");
                }

                Console.WriteLine("MDB version: " + mdbAdaptor.MdbVersion);

                this.SessionOptions  = sessionOptions;
                mdbAdaptor.StartInfo = startInfo;

                Report.Initialize();

                DebuggerConfiguration config = new DebuggerConfiguration();
                config.LoadConfiguration();
                mdbAdaptor.Configuration = config;
                mdbAdaptor.InitializeConfiguration();

                debugger = new MD.Debugger(config);

                debugger.ModuleLoadedEvent   += OnModuleLoadedEvent;
                debugger.ModuleUnLoadedEvent += OnModuleUnLoadedEvent;

                debugger.ProcessReachedMainEvent += delegate(MD.Debugger deb, MD.Process proc) {
                    OnInitialized(deb, proc);
                };

                if (startInfo.IsXsp)
                {
                    mdbAdaptor.SetupXsp();
                    config.FollowFork = false;
                }
                config.OpaqueFileNames = false;

                DebuggerOptions options = DebuggerOptions.ParseCommandLine(new string[] { startInfo.Command });
                options.WorkingDirectory     = startInfo.WorkingDirectory;
                Environment.CurrentDirectory = startInfo.WorkingDirectory;
                options.StopInMain           = false;

                if (!string.IsNullOrEmpty(startInfo.Arguments))
                {
                    options.InferiorArgs = ToArgsArray(startInfo.Arguments);
                }

                if (startInfo.EnvironmentVariables != null)
                {
                    foreach (KeyValuePair <string, string> env in startInfo.EnvironmentVariables)
                    {
                        options.SetEnvironment(env.Key, env.Value);
                    }
                }
                session            = new MD.DebuggerSession(config, options, "main", null);
                mdbAdaptor.Session = session;
                mdbAdaptor.InitializeSession();

                ST.ThreadPool.QueueUserWorkItem(delegate {
                    // Run in a thread to avoid a deadlock, since NotifyStarted calls back to the client.
                    NotifyStarted();
                    debugger.Run(session);
                });
            } catch (Exception e) {
                Console.WriteLine("error: " + e.ToString());
                throw;
            }
        }
Exemplo n.º 3
0
        public Process LoadSession(Stream stream)
        {
            if ((debugger != null) || (main_process != null))
                throw new TargetException (TargetError.AlreadyHaveTarget);

            try {
                debugger = new Debugger (config);
                parser = new ExpressionParser (this);
                session = new DebuggerSession (config, stream, parser);
                parser.Session = session;

                new InterpreterEventSink (this, debugger);

                CommandResult result;
                current_process = main_process = debugger.Run (session, out result);
                current_thread = current_process.MainThread;

                Wait (result);

                return current_process;
            } catch (TargetException ex) {
                Console.WriteLine ("Got a TargetException during LoadSession: {0}", ex);
                debugger.Dispose ();
                debugger = null;
                throw;
            } catch (Exception ex) {
                Console.WriteLine ("Got an Exception during LoadSession: {0}", ex);
                debugger.Dispose ();
                debugger = null;
                throw;
            }
        }
		public void Run (MonoDebuggerStartInfo startInfo, DebuggerSessionOptions sessionOptions)
		{
			try {
				if (startInfo == null)
					throw new ArgumentNullException ("startInfo");
			
				Console.WriteLine ("MDB version: " + mdbAdaptor.MdbVersion);
				
				this.SessionOptions = sessionOptions;
				mdbAdaptor.StartInfo = startInfo;

				Report.Initialize ();

				DebuggerConfiguration config = new DebuggerConfiguration ();
				config.LoadConfiguration ();
				mdbAdaptor.Configuration = config;
				mdbAdaptor.InitializeConfiguration ();
				
				debugger = new MD.Debugger (config);
				
				debugger.ModuleLoadedEvent += OnModuleLoadedEvent;
				debugger.ModuleUnLoadedEvent += OnModuleUnLoadedEvent;
				
				debugger.ProcessReachedMainEvent += delegate (MD.Debugger deb, MD.Process proc) {
					OnInitialized (deb, proc);
				};

				if (startInfo.IsXsp) {
					mdbAdaptor.SetupXsp ();
					config.FollowFork = false;
				}
				config.OpaqueFileNames = false;
				
				DebuggerOptions options = DebuggerOptions.ParseCommandLine (new string[] { startInfo.Command } );
				options.WorkingDirectory = startInfo.WorkingDirectory;
				Environment.CurrentDirectory = startInfo.WorkingDirectory;
				options.StopInMain = false;
				
				if (!string.IsNullOrEmpty (startInfo.Arguments))
					options.InferiorArgs = ToArgsArray (startInfo.Arguments);
				
				if (startInfo.EnvironmentVariables != null) {
					foreach (KeyValuePair<string,string> env in startInfo.EnvironmentVariables)
						options.SetEnvironment (env.Key, env.Value);
				}
				session = new MD.DebuggerSession (config, options, "main", null);
				mdbAdaptor.Session = session;
				mdbAdaptor.InitializeSession ();
				
				ST.ThreadPool.QueueUserWorkItem (delegate {
					// Run in a thread to avoid a deadlock, since NotifyStarted calls back to the client.
					NotifyStarted ();
					debugger.Run(session);
				});

			} catch (Exception e) {
				Console.WriteLine ("error: " + e.ToString ());
				throw;
			}
		}