Inheritance: DebuggerMarshalByRefObject
Esempio n. 1
0
        private void OnInitialized(MD.Debugger debugger, Process process)
        {
            Console.WriteLine(">> OnInitialized");

            this.process  = process;
            this.debugger = debugger;

            mdbAdaptor.Process = process;

            guiManager = process.StartGUIManager();

            //FIXME: conditionally add event handlers
            process.TargetOutputEvent += OnTargetOutput;

            debugger.ProcessCreatedEvent += OnProcessCreatedEvent;
            debugger.ProcessExecdEvent   += OnProcessExecdEvent;
            debugger.ProcessExitedEvent  += OnProcessExitedEvent;

            debugger.ThreadCreatedEvent += OnThreadCreatedEvent;
            debugger.ThreadExitedEvent  += OnThreadExitedEvent;

            debugger.TargetExitedEvent += OnTargetExitedEvent;
            guiManager.TargetEvent     += OnTargetEvent;

            // Not supported
            //guiManager.BreakpointHitHandler = BreakEventCheck;

            activeThread = process.MainThread;
            running      = true;

            Console.WriteLine("<< OnInitialized");
        }
Esempio n. 2
0
        internal BfdDisassembler(Process process, bool is_x86_64)
        {
            this.process = process;

            read_handler = new ReadMemoryHandler (read_memory_func);
            output_handler = new OutputHandler (output_func);
            print_handler = new PrintAddressHandler (print_address_func);

            handle = bfd_glue_create_disassembler (
                is_x86_64, read_handler, output_handler, print_handler);
        }
Esempio n. 3
0
 MD.Thread GetThread(long procId, long threadId)
 {
     MD.Process proc = GetProcess(procId);
     if (proc != null)
     {
         foreach (MD.Thread t in proc.GetThreads())
         {
             if (t.ID == (int)threadId)
             {
                 return(t);
             }
         }
     }
     return(null);
 }
Esempio n. 4
0
        public ThreadInfo[] GetThreads(long processId)
        {
            MD.Process p = GetProcess(processId);
            if (p == null)
            {
                return(new ThreadInfo [0]);
            }
            List <DL.ThreadInfo> list = new List <DL.ThreadInfo> ();

            foreach (MD.Thread t in p.GetThreads())
            {
                DL.ThreadInfo ct = CreateThreadInfo(t);
                list.Add(ct);
            }
            return(list.ToArray());
        }
Esempio n. 5
0
        public Process OpenCoreFile(string core_file)
        {
            if ((debugger != null) || (main_process != null))
                throw new TargetException (TargetError.AlreadyHaveTarget);

            Console.WriteLine ("Loading core file {0}", core_file);

            try {
                debugger = new Debugger (config);

                new InterpreterEventSink (this, debugger);

                Thread[] threads;
                current_process = main_process = debugger.OpenCoreFile (
                    session, core_file, out threads);

                current_thread = current_process.MainThread;

                return current_process;
            } catch (TargetException) {
                debugger.Dispose ();
                debugger = null;
                throw;
            }
        }
Esempio n. 6
0
 protected virtual void OnProcessReachedMain(Process process)
 {
 }
Esempio n. 7
0
 protected virtual void OnProcessExecd(Process process)
 {
     Print ("Process #{0} exec()'d: {1}", process.ID,
            PrintCommandLineArgs (process));
 }
Esempio n. 8
0
 protected virtual void OnMainProcessCreated(Process process)
 {
     new ProcessEventSink (this, process);
 }
Esempio n. 9
0
 public string PrintProcess(Process process)
 {
     string command_line = PrintCommandLineArgs (process);
     if (command_line.Length > 70) {
         command_line = command_line.Substring (0, 70);
         command_line += " ...";
     }
     return String.Format ("#{0} ({1}:{2})", process.ID,
                   process.MainThread.PID, command_line);
 }
Esempio n. 10
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;
            }
        }
Esempio n. 11
0
 public void Detach(Process process)
 {
     if (process == main_process)
         Detach ();
     else
         process.Detach ();
 }
Esempio n. 12
0
 private void OnProcessExecdEvent(MD.Debugger debugger, MD.Process process)
 {
     WriteDebuggerOutput(string.Format("Process {0} execd.\n", process.ID));
 }
        private void thread_exited(ThreadManager manager, Process process)
        {
            lock (procs) {
                procs.Remove (process.ID);
            }

            EmitThreadStateEvent (null);
        }
        private void thread_created(ThreadManager manager, Process process)
        {
            lock (procs) {
                procs.Add (process.ID, process);

                process.TargetOutput += new TargetOutputHandler (target_output);
                process.DebuggerOutput += new DebuggerOutputHandler (debugger_output);
                process.DebuggerError += new DebuggerErrorHandler (debugger_error);
            }

            EmitThreadStateEvent (null);
        }
        private void initialized_event(ThreadManager manager, Process process)
        {
            this.proc = process;

            proc.TargetOutput += new TargetOutputHandler (target_output);
            proc.DebuggerOutput += new DebuggerOutputHandler (debugger_output);
            proc.DebuggerError += new DebuggerErrorHandler (debugger_error);
            proc.TargetEvent += new TargetEventHandler (target_event);

            insert_breakpoints ();

            if (StartedEvent != null)
                StartedEvent (this, EventArgs.Empty);

            // This should not be needed, but it hangs if not dispatched in this way
            // It's prolly a synchronization issue that does not show when the call
            // is delayed by the dispatcher
            Runtime.DispatchService.GuiDispatch (new StatefulMessageHandler (ChangeState), null);
        }
Esempio n. 16
0
 public void process_exited(Debugger debugger, Process process)
 {
     interpreter.OnProcessExited (process);
 }
        void Cleanup()
        {
            if (!IsDebugging)
                return;

            if (StoppedEvent != null)
                StoppedEvent (this, new EventArgs ());

            backend.Dispose ();
            backend = null;
            console.Dispose ();
            console = null;
            #if NET_2_0
            attr_handler = null;
            #endif
            proc = null;

            if (ExecutionLocationChanged != null)
                ExecutionLocationChanged (this, EventArgs.Empty);
        }
Esempio n. 18
0
 protected OperatingSystemBackend(Process process)
 {
     this.Process = process;
 }
Esempio n. 19
0
 public void Kill(Process process)
 {
     if (process == main_process)
         Kill ();
     else
         process.Kill ();
 }
Esempio n. 20
0
 internal BreakpointCommandResult(Process process)
 {
     this.process = process;
 }
Esempio n. 21
0
 public string PrintCommandLineArgs(Process process)
 {
     StringBuilder sb = new StringBuilder ();
     string[] args = process.CommandLineArguments;
     int start = 0;
     if ((args.Length > 1) && (args [0] == BuildInfo.mono)) {
         if (args [1] == "--inside-mdb")
             start = 2;
         else
             start = 1;
     }
     for (int i = start; i < args.Length; i++) {
         if (i > start)
             sb.Append (" ");
         sb.Append (args [i]);
     }
     return sb.ToString ();
 }
Esempio n. 22
0
 public MyOperationHost(Process process)
 {
     this.Process = process;
 }
Esempio n. 23
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;
            }
        }
Esempio n. 24
0
        private Process(Process parent, int pid)
            : this(parent.manager, parent.session)
        {
            this.start = new ProcessStart (parent.ProcessStart, pid);

            this.is_forked = true;
            this.initialized = true;

            this.parent = parent;

            breakpoint_manager = new BreakpointManager (parent.breakpoint_manager);

            exception_handlers = new Dictionary<int,ExceptionCatchPoint> ();
            foreach (KeyValuePair<int,ExceptionCatchPoint> catchpoint in parent.exception_handlers)
                exception_handlers.Add (catchpoint.Key, catchpoint.Value);

            symtab_manager = parent.symtab_manager;

            native_language = parent.native_language;
            os = parent.os;
        }
Esempio n. 25
0
 protected virtual void OnProcessCreated(Process process)
 {
     process_event.Set ();
     new ProcessEventSink (this, process);
     Print ("Created new process #{0}.", process.ID);
     if (current_process == null) {
         current_process = process;
         current_thread = process.MainThread;
     }
 }
Esempio n. 26
0
 internal ProcessCommandResult(Process process, ThreadingModel model)
     : base(model)
 {
     this.Process = process;
 }
Esempio n. 27
0
 protected virtual void OnProcessExited(Process process)
 {
     Print ("Process #{0} exited.", process.ID);
     if (process == main_process) {
         current_process = main_process = null;
         current_thread = null;
     } else if (process == current_process) {
         current_process = main_process;
         current_thread = main_process.MainThread;
     }
 }
Esempio n. 28
0
        internal void ChildForked(Inferior inferior, int pid)
        {
            Process new_process = new Process (this, pid);
            new_process.ProcessStart.StopInMain = false;

            Inferior new_inferior = Inferior.CreateInferior (
                manager, new_process, new_process.ProcessStart);
            new_inferior.InitializeThread (pid);

            if (!manager.Debugger.Configuration.FollowFork) {
                new_inferior.DetachAfterFork ();
                return;
            }

            SingleSteppingEngine new_thread = new SingleSteppingEngine (
                manager, new_process, new_inferior, pid);

            Report.Debug (DebugFlags.Threads, "Child forked: {0} {1}", pid, new_thread);

            new_process.main_thread = new_thread;

            manager.Debugger.OnProcessCreatedEvent (new_process);
            new_process.OnThreadCreatedEvent (new_thread);

            CommandResult result = new_process.CloneParentOperation (new_thread);
            new_thread.StartForkedChild (result);
        }
Esempio n. 29
0
        protected virtual void OnTargetExited()
        {
            debugger = null;
            main_process = current_process = null;
            current_thread = null;

            Print ("Target exited.");
        }
Esempio n. 30
0
 public ProcessEventSink(Interpreter interpreter, Process process)
 {
     this.interpreter = interpreter;
     process.TargetOutputEvent += target_output;
 }
Esempio n. 31
0
 public void process_created(Debugger debugger, Process process)
 {
     interpreter.OnProcessCreated (process);
 }
Esempio n. 32
0
        public Process Attach(int pid)
        {
            if ((debugger != null) || (main_process != null))
                throw new TargetException (TargetError.AlreadyHaveTarget);

            if (!IsScript)
                Print ("Attaching to {0}", pid);

            try {
                debugger = new Debugger (config);

                new InterpreterEventSink (this, debugger);

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

                Wait (result);

                return current_process;
            } catch (TargetException) {
                debugger.Dispose ();
                debugger = null;
                throw;
            }
        }
Esempio n. 33
0
 public void process_reached_main(Debugger debugger, Process process)
 {
     interpreter.OnProcessReachedMain (process);
 }
 public void LoadLibrary(Process thread, string assembly)
 {
     backend.LoadLibrary (thread, assembly);
 }