Exemplo n.º 1
0
        void DoDispose()
        {
            if (!is_forked)
            {
                if (architecture != null)
                {
                    architecture.Dispose();
                    architecture = null;
                }

                if (mono_language != null)
                {
                    mono_language.Dispose();
                    mono_language = null;
                }

                if (native_language != null)
                {
                    native_language.Dispose();
                    native_language = null;
                }

                if (os != null)
                {
                    os.Dispose();
                    os = null;
                }

                if (symtab_manager != null)
                {
                    symtab_manager.Dispose();
                    symtab_manager = null;
                }
            }

            if (breakpoint_manager != null)
            {
                breakpoint_manager.Dispose();
                breakpoint_manager = null;
            }

            if (thread_db != null)
            {
                thread_db.Dispose();
                thread_db = null;
            }

            if (thread_lock_mutex != null)
            {
                thread_lock_mutex.Dispose();
                thread_lock_mutex = null;
            }

            exception_handlers = null;

            manager.RemoveProcess(this);
        }
Exemplo n.º 2
0
        internal Process(ThreadManager manager, ProcessStart start)
            : this(manager, start.Session)
        {
            this.start = start;

            is_attached = start.PID != 0;

            breakpoint_manager = new BreakpointManager();

            exception_handlers = new Dictionary <int, ExceptionCatchPoint> ();

            symtab_manager = new SymbolTableManager(session);

            os = Inferior.CreateOperatingSystemBackend(this);
            native_language = new NativeLanguage(this, os, target_info);

            session.OnProcessCreated(this);
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        internal void ChildExecd(SingleSteppingEngine engine, Inferior inferior)
        {
            is_execed = true;

            if (!is_forked)
            {
                if (mono_language != null)
                {
                    mono_language.Dispose();
                }

                if (native_language != null)
                {
                    native_language.Dispose();
                }

                if (os != null)
                {
                    os.Dispose();
                }

                if (symtab_manager != null)
                {
                    symtab_manager.Dispose();
                }
            }

            if (breakpoint_manager != null)
            {
                breakpoint_manager.Dispose();
            }

            session.OnProcessExecd(this);

            breakpoint_manager = new BreakpointManager();

            exception_handlers = new Dictionary <int, ExceptionCatchPoint> ();

            symtab_manager = new SymbolTableManager(session);

            os = Inferior.CreateOperatingSystemBackend(this);
            native_language = new NativeLanguage(this, os, target_info);

            Inferior new_inferior = Inferior.CreateInferior(manager, this, start);

            try {
                new_inferior.InitializeAfterExec(inferior.PID);
            } catch (Exception ex) {
                if ((ex is TargetException) && (((TargetException)ex).Type == TargetError.PermissionDenied))
                {
                    Report.Error("Permission denied when trying to debug exec()ed child {0}, detaching!",
                                 inferior.PID);
                }
                else
                {
                    Report.Error("InitializeAfterExec() failed on pid {0}: {1}", inferior.PID, ex);
                }
                new_inferior.DetachAfterFork();
                return;
            }

            SingleSteppingEngine new_thread = new SingleSteppingEngine(
                manager, this, new_inferior, inferior.PID);

            ThreadServant[] threads;
            lock (thread_hash.SyncRoot) {
                threads = new ThreadServant [thread_hash.Count];
                thread_hash.Values.CopyTo(threads, 0);
            }

            for (int i = 0; i < threads.Length; i++)
            {
                if (threads [i].PID != inferior.PID)
                {
                    threads [i].Kill();
                }
            }

            thread_hash [inferior.PID] = new_thread;

            inferior.Dispose();
            inferior = null;

            manager.Debugger.OnProcessExecdEvent(this);
            manager.Debugger.OnThreadCreatedEvent(new_thread.Thread);
            initialized = is_forked = false;
            main_thread = new_thread;

            if ((engine.Thread.ThreadFlags & Thread.Flags.StopOnExit) != 0)
            {
                new_thread.Thread.ThreadFlags |= Thread.Flags.StopOnExit;
            }

            CommandResult result = engine.OnExecd(new_thread);

            new_thread.StartExecedChild(result);
        }