Ejemplo n.º 1
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);
        }