public void SetRunStatus(int threadId, EnumRunStatus status)
        {
            if (status == EnumRunStatus.Stop)
            {
                _stopping = true;
                foreach (KeyValuePair <int, ThreadDebug> kv in _threadData)
                {
                    kv.Value.Status = EnumRunStatus.Stop;
                }
            }
            else
            {
                ThreadDebug t = ThreadData(threadId);
                t.Status = status;
                if (status == EnumRunStatus.StepOver || status == EnumRunStatus.StepOut)
                {
                    t.StepOverLevel = t.StackLevel;
                }
                else if (status == EnumRunStatus.Finished)
                {
                    //a none-main thread finishes
                    setThreadGroupFinish(threadId);
                    setViewerBackColor();
                }
            }
            FormDebugger f = this.FindForm() as FormDebugger;

            if (f != null)
            {
                f.setButtonImages();
            }
        }
Example #2
0
        public void LeaveEvent(string objectKey, string eventName, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            EventAction ea = _ComponentDebugger.RootClass.GetEventHandler(eventName, objectKey);

            if (ea != null)
            {
                int           threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
                EnumRunStatus status   = _ComponentDebugger.GetRunStatus(threadId);
                if ((status != EnumRunStatus.Stop && status != EnumRunStatus.Run) || ea.BreakAfterExecute)
                {
                    _ComponentDebugger.SetSelectedObject(executer);
                    _ComponentDebugger.SetAtBreak(threadId, true);
                    _debugUI.ShowBreakPoint(_ComponentDebugger);
                    _ComponentDebugger.ShowEventBreakPointInTreeView(objectKey, eventName, executer, false);
                    waitForBreakPoint(threadId);
                }
            }
            _ComponentDebugger.ClearBreakpointDisplay();
            _ComponentDebugger.LeaveEvent();
            FormDebugger f = _ComponentDebugger.FindForm() as FormDebugger;

            if (f != null)
            {
                f.setButtonImages();
            }
        }
        public bool ShouldBreak(int threadId)
        {
            EnumRunStatus status = ThreadData(threadId).Status;

            if (status == EnumRunStatus.Pause || status == EnumRunStatus.StepInto)
            {
                return(true);
            }
            return(false);
        }
Example #4
0
        /// <summary>
        /// called from event action list, not from a custom method.
        /// called only between event actions
        /// </summary>
        /// <param name="objectKey"></param>
        /// <param name="eventName"></param>
        /// <param name="taskId"></param>
        /// <param name="executer"></param>
        public void BeforeExecuteEventAction(string objectKey, string eventName, int actionIndex, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            _ComponentDebugger.ClearBreakpointDisplay();
            EventAction ea = _ComponentDebugger.RootClass.GetEventHandler(eventName, objectKey);

            if (ea != null)
            {
                int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
                if (actionIndex > 0)
                {
                    //check the action just finished is an custom method or not
                    if (!ea.TaskIDList[actionIndex - 1].IsEmbedded)
                    {
                        IAction a = _ComponentDebugger.RootClass.GetActionInstance(ea.TaskIDList[actionIndex - 1].ActionId);
                        if (a != null)
                        {
                            CustomMethodPointer cmp = a.ActionMethod as CustomMethodPointer;
                            if (cmp != null)
                            {
                                MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, cmp.MethodDef.MethodID);
                                if (h != null)
                                {
                                    h.ActionGroup.GroupFinished = true;
                                    _ComponentDebugger.UpdateViewersBackColor();
                                }
                            }
                        }
                    }
                }
                EnumRunStatus status = _ComponentDebugger.GetRunStatus(threadId);
                if ((status != EnumRunStatus.Stop && status != EnumRunStatus.Run) || ea.TaskIDList[actionIndex].BreakAsEventAction)
                {
                    _ComponentDebugger.SetSelectedObject(executer);
                    _ComponentDebugger.SetAtBreak(threadId, true);
                    _debugUI.ShowBreakPoint(_ComponentDebugger);
                    _ComponentDebugger.ShowEventBreakPointInTreeView(objectKey, eventName, executer, actionIndex);
                    waitForBreakPoint(threadId);
                }
            }
        }
Example #5
0
        public void EnterEvent(string objectKey, string eventName, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            _ComponentDebugger.EnterEvent();
            _ComponentDebugger.AddComponent(objectKey, executer);
            EventAction ea = _ComponentDebugger.RootClass.GetEventHandler(eventName, objectKey);

            if (ea != null)
            {
                int           threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
                EnumRunStatus status   = _ComponentDebugger.GetRunStatus(threadId);
                if ((status != EnumRunStatus.Stop && status != EnumRunStatus.Run) || ea.BreakBeforeExecute)
                {
                    _ComponentDebugger.SetSelectedObject(executer);
                    _ComponentDebugger.SetAtBreak(threadId, true);
                    _debugUI.ShowBreakPoint(_ComponentDebugger);
                    _ComponentDebugger.ShowEventBreakPointInTreeView(objectKey, eventName, executer, true);
                    waitForBreakPoint(threadId);
                }
            }
        }
Example #6
0
 public static Image GetStatusImg(EnumRunStatus status)
 {
     return FileStatusImage[status];
 }
Example #7
0
        /// <summary>
        /// finish execute an action
        /// </summary>
        /// <param name="objectKey"></param>
        /// <param name="methodWholeId"></param>
        /// <param name="branchId"></param>
        /// <param name="executer"></param>
        public void AfterExecuteAction(string objectKey, UInt64 methodWholeId, UInt32 branchId, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;

            _ComponentDebugger.DecrementStackLevel(threadId);
            //check if it is at a break point
            MethodClass mc = _ComponentDebugger.GetMethod(methodWholeId);

            if (mc != null)
            {
                IActionGroup g      = mc;
                ActionBranch branch = mc.GetBranchByIdInGroup(branchId, ref g);
                if (branch != null)
                {
                    IActionGroup g0 = branch as IActionGroup;
                    if (g0 != null)
                    {
                        //finished calling a group of actions
                        MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, g0.GroupId);
                        if (h != null)
                        {
                            h.ActionGroup.GroupFinished = true;
                            _ComponentDebugger.UpdateViewersBackColor();
                        }
                    }
                    else
                    {
                        ISingleAction sa = branch as ISingleAction;
                        if (sa != null)
                        {
                            CustomMethodPointer ac = sa.ActionData.ActionMethod as CustomMethodPointer;
                            if (ac != null)
                            {
                                //finished calling a custom action
                                MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, ac.MethodDef.MethodID);
                                if (h != null)
                                {
                                    h.ActionGroup.GroupFinished = true;
                                    _ComponentDebugger.UpdateViewersBackColor();
                                }
                            }
                        }
                    }
                    EnumRunStatus status = _ComponentDebugger.GetRunStatus(threadId);
                    bool          b      = (status == EnumRunStatus.Pause || status == EnumRunStatus.StepInto);
                    if (!b)
                    {
                        if (status == EnumRunStatus.StepOver && _ComponentDebugger.ReachStepOver(threadId))
                        {
                            b = true;
                        }
                        if (!b)
                        {
                            if (status == EnumRunStatus.StepOut && _ComponentDebugger.ReachStepOut(threadId))
                            {
                                b = true;
                            }
                        }
                    }

                    if (b || branch.BreakAfterExecute)
                    {
                        _ComponentDebugger.SetSelectedObject(executer);
                        _ComponentDebugger.SetAtBreak(threadId, true);
                        _debugUI.ShowBreakPoint(_ComponentDebugger);
                        branch.AtBreak = EnumActionBreakStatus.After;
                        _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch);
                        waitForBreakPoint(threadId);
                        branch.AtBreak = EnumActionBreakStatus.None;
                        _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch);
                    }
                    else
                    {
                        branch.AtBreak = EnumActionBreakStatus.None;
                        _ComponentDebugger.ClearBreakPointInMethod(threadId, mc, g, branch);
                    }
                }
            }
        }