Example #1
0
        internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller)
        {
            if (!ThreadManager.InBackgroundThread)
            {
                throw new InternalError();
            }

            if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded))
            {
                throw new TargetException(TargetError.NotStopped);
            }

            if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Single)
            {
                current_state = ProcessState.SingleThreaded;
                if ((model & ThreadingModel.ResumeThreads) != 0)
                {
                    ResumeUserThreads(model, caller);
                }
                return(new ThreadCommandResult(caller.Thread));
            }
            else if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Process)
            {
                throw new ArgumentException();
            }

            lock (this) {
                current_state = ProcessState.Running;
                stopped_event.Reset();
                current_operation = new ProcessCommandResult(this, model);
            }

            ResumeUserThreads(model, caller);
            return(current_operation);
        }
Example #2
0
        internal void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model)
        {
            if (!ThreadManager.InBackgroundThread && Inferior.HasThreadEvents)
            {
                throw new InternalError();
            }

            if (current_state == ProcessState.Stopping)
            {
                return;
            }
            else if (current_state != ProcessState.Running)
            {
                throw new InternalError();
            }

            if ((result != null) && (caller != main_thread) &&
                ((result.Type == TargetEventType.TargetExited) || (result.Type == TargetEventType.TargetSignaled)))
            {
                return;
            }

            current_state = ProcessState.Stopping;
            SuspendUserThreads(model, caller);

            lock (this) {
                current_state = ProcessState.Stopped;
                current_operation.Completed();
                current_operation = null;
                stopped_event.Set();
            }
        }
Example #3
0
        CommandResult CloneParentOperation(SingleSteppingEngine new_thread)
        {
            if (parent.current_state == ProcessState.SingleThreaded)
            {
                current_state = ProcessState.SingleThreaded;
                return(new ThreadCommandResult(new_thread.Thread));
            }

            if (parent.current_state != ProcessState.Running)
            {
                throw new InternalError();
            }

            current_state = ProcessState.Running;
            if ((parent.current_operation.ThreadingModel & ThreadingModel.ThreadingMode) == ThreadingModel.Global)
            {
                current_operation = parent.current_operation;
            }
            else if ((parent.current_operation.ThreadingModel & ThreadingModel.ThreadingMode) == ThreadingModel.Process)
            {
                current_operation = new ProcessCommandResult(this, parent.current_operation.ThreadingModel);
            }
            else
            {
                throw new InternalError();
            }

            return(current_operation);
        }
Example #4
0
        internal void Stop()
        {
            main_thread.Invoke(delegate {
                current_state = ProcessState.Stopping;

                SuspendUserThreads(ThreadingModel.Process, null);
                current_state = ProcessState.Stopped;
                if (current_operation != null)
                {
                    current_operation.Completed();
                    current_operation = null;
                }
                stopped_event.Set();
                return(null);
            }, null);
        }
Example #5
0
        void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model)
        {
            if (!ThreadManager.InBackgroundThread)
            {
                throw new InternalError();
            }

            foreach (Process process in process_hash.Values)
            {
                process.OperationCompleted(caller, result, model);
            }

            lock (this) {
                current_operation = null;
                stopped_event.Set();
            }
        }
Example #6
0
        internal void StartGlobalOperation(ThreadingModel model, SingleSteppingEngine caller, OperationCommandResult operation)
        {
            if (!ThreadManager.InBackgroundThread)
            {
                throw new InternalError();
            }

            if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded))
            {
                throw new TargetException(TargetError.NotStopped);
            }

            lock (this) {
                current_state = ProcessState.Running;
                stopped_event.Reset();
                current_operation = operation;
            }

            ResumeUserThreads(model, caller);
        }
Example #7
0
        internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller)
        {
            if (!ThreadManager.InBackgroundThread)
            {
                throw new InternalError();
            }

            if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Default)
            {
                if (Inferior.HasThreadEvents)
                {
                    model |= ThreadingModel.Single;
                }
                else
                {
                    model |= ThreadingModel.Process;
                }
            }

            if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Global)
            {
                return(caller.Process.StartOperation(model, caller));
            }

            if (current_operation != null)
            {
                throw new TargetException(TargetError.NotStopped);
            }

            lock (this) {
                stopped_event.Reset();
                current_operation = new GlobalCommandResult(this, model);
            }

            foreach (Process process in process_hash.Values)
            {
                process.StartGlobalOperation(model, caller, current_operation);
            }

            return(current_operation);
        }
Example #8
0
        CommandResult CloneParentOperation(SingleSteppingEngine new_thread)
        {
            if (parent.current_state == ProcessState.SingleThreaded) {
                current_state = ProcessState.SingleThreaded;
                return new ThreadCommandResult (new_thread.Thread);
            }

            if (parent.current_state != ProcessState.Running)
                throw new InternalError ();

            current_state = ProcessState.Running;
            if ((parent.current_operation.ThreadingModel & ThreadingModel.ThreadingMode) == ThreadingModel.Global)
                current_operation = parent.current_operation;
            else if ((parent.current_operation.ThreadingModel & ThreadingModel.ThreadingMode) == ThreadingModel.Process)
                current_operation = new ProcessCommandResult (this, parent.current_operation.ThreadingModel);
            else
                throw new InternalError ();

            return current_operation;
        }
Example #9
0
        internal void Stop()
        {
            main_thread.Invoke (delegate {
                current_state = ProcessState.Stopping;

                SuspendUserThreads (ThreadingModel.Process, null);
                current_state = ProcessState.Stopped;
                if (current_operation != null) {
                    current_operation.Completed ();
                    current_operation = null;
                }
                stopped_event.Set ();
                return null;
            }, null);
        }
Example #10
0
        internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller)
        {
            if (!ThreadManager.InBackgroundThread)
                throw new InternalError ();

            if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded))
                throw new TargetException (TargetError.NotStopped);

            if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Single) {
                current_state = ProcessState.SingleThreaded;
                if ((model & ThreadingModel.ResumeThreads) != 0)
                    ResumeUserThreads (model, caller);
                return new ThreadCommandResult (caller.Thread);
            } else if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Process) {
                throw new ArgumentException ();
            }

            lock (this) {
                current_state = ProcessState.Running;
                stopped_event.Reset ();
                current_operation = new ProcessCommandResult (this, model);
            }

            ResumeUserThreads (model, caller);
            return current_operation;
        }
Example #11
0
        internal void StartGlobalOperation(ThreadingModel model, SingleSteppingEngine caller, OperationCommandResult operation)
        {
            if (!ThreadManager.InBackgroundThread)
                throw new InternalError ();

            if ((current_state != ProcessState.Stopped) && (current_state != ProcessState.SingleThreaded))
                throw new TargetException (TargetError.NotStopped);

            lock (this) {
                current_state = ProcessState.Running;
                stopped_event.Reset ();
                current_operation = operation;
            }

            ResumeUserThreads (model, caller);
        }
Example #12
0
        internal void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model)
        {
            if (!ThreadManager.InBackgroundThread && Inferior.HasThreadEvents)
                throw new InternalError ();

            if (current_state == ProcessState.Stopping)
                return;
            else if (current_state != ProcessState.Running)
                throw new InternalError ();

            if ((result != null) && (caller != main_thread) &&
                ((result.Type == TargetEventType.TargetExited) || (result.Type == TargetEventType.TargetSignaled)))
                return;

            current_state = ProcessState.Stopping;
            SuspendUserThreads (model, caller);

            lock (this) {
                current_state = ProcessState.Stopped;
                current_operation.Completed ();
                current_operation = null;
                stopped_event.Set ();
            }
        }
Example #13
0
        internal void OnProcessExitedEvent()
        {
            DropGlobalThreadLock ();

            if (current_state == ProcessState.Running) {
                current_state = ProcessState.Exited;
                current_operation.Completed ();
                current_operation = null;
                stopped_event.Set ();
            }

            if (!is_forked)
                session.OnProcessExited (this);
            session.MainThreadGroup.RemoveThread (main_thread.ID);
            manager.Debugger.OnProcessExitedEvent (this);
        }
Example #14
0
        void OperationCompleted(SingleSteppingEngine caller, TargetEventArgs result, ThreadingModel model)
        {
            if (!ThreadManager.InBackgroundThread)
                throw new InternalError ();

            foreach (Process process in process_hash.Values) {
                process.OperationCompleted (caller, result, model);
            }

            lock (this) {
                current_operation = null;
                stopped_event.Set ();
            }
        }
Example #15
0
        internal CommandResult StartOperation(ThreadingModel model, SingleSteppingEngine caller)
        {
            if (!ThreadManager.InBackgroundThread)
                throw new InternalError ();

            if ((model & ThreadingModel.ThreadingMode) == ThreadingModel.Default) {
                if (Inferior.HasThreadEvents)
                    model |= ThreadingModel.Single;
                else
                    model |= ThreadingModel.Process;
            }

            if ((model & ThreadingModel.ThreadingMode) != ThreadingModel.Global)
                return caller.Process.StartOperation (model, caller);

            if (current_operation != null)
                throw new TargetException (TargetError.NotStopped);

            lock (this) {
                stopped_event.Reset ();
                current_operation = new GlobalCommandResult (this, model);
            }

            foreach (Process process in process_hash.Values) {
                process.StartGlobalOperation (model, caller, current_operation);
            }

            return current_operation;
        }