Exemplo n.º 1
0
        /// <summary>
        /// get/create a single thread group of actions containing the given branch id.
        /// it is used for loading debugger viewer
        /// </summary>
        /// <param name="branchId">the given branch id to be included in the result group</param>
        /// <returns>the action group containing the given branch id</returns>
        public IActionGroup GetThreadGroup(UInt32 branchId)
        {
            List <ActionBranch> independentThreads = FindoutActionThreads(false);

            foreach (ActionBranch a in independentThreads)
            {
                if (a.ContainsAction(branchId))
                {
                    IActionGroup g = a as IActionGroup;
                    if (g != null)
                    {
                        g = (IActionGroup)g.Clone();
                        g.ResetGroupId(_method.MethodID);                        //all threads has the same group id. they can be distinguished at runtime by thread id
                        return(g);
                    }
                    AB_ActionString s = a as AB_ActionString;
                    if (s != null)
                    {
                        IActionGroup sg = s.GetThreadGroup(branchId);
                        sg.ResetGroupId(_method.MethodID);                        //all threads has the same group id. they can be distinguished at runtime by thread id
                        return(sg);
                    }
                    List <UInt32>  used = new List <uint>();
                    AB_ActionGroup ag   = new AB_ActionGroup(_actsHolder);
                    ag.SetOwnerMethod(used, _method);
                    ag.BranchId = _method.MethodID;                     //all threads has the same group id. they can be distinguished at runtime by thread id
                    ag.AppendAction(a);
                    return(ag);
                }
            }
            return(null);
        }
        private void showBreakPointInMethod(int threadId, MethodClass method, IActionGroup group, ActionBranch branch)
        {
            MethodDesignerHolder h = getViewer(threadId, method, group, branch);

            if (h == null)
            {
                IActionGroup g = (IActionGroup)(group.Clone());
                g = g.GetThreadGroup(branch.BranchId);
                //create a viewer
                SplitContainer c            = getLastContainer(splitContainer1);
                SplitContainer newContainer = new SplitContainer();
                newContainer.Dock = DockStyle.Fill;
                c.Panel2.Controls.Add(newContainer);
                c.Panel2Collapsed            = false;
                newContainer.Panel2Collapsed = true;
                h          = Activator.CreateInstance(g.ViewerHolderType, this, _designer) as MethodDesignerHolder;
                h.ThreadId = threadId;
                h.SetBackgroundText(group.GroupName);
                h.Dock = DockStyle.Fill;
                newContainer.Panel1.Controls.Add(h);
                h.LoadActions(g);
                _currentThreadId              = threadId;
                h.DesignerSelected           += new EventHandler(h_DesignerSelected);
                newContainer.Panel1.GotFocus += new EventHandler(Panel1_GotFocus);
                newContainer.SplitterMoved   += new SplitterEventHandler(newContainer_SplitterMoved);
                newContainer.Resize          += new EventHandler(newContainer_Resize);
            }
            else
            {
                if (h.ActionGroup.GroupFinished)
                {
                    h.ActionGroup.GroupFinished = false;
                    ThreadDebug td = ThreadData(threadId);
                    if (td.Status == EnumRunStatus.Finished)
                    {
                        FormDebugger f = this.FindForm() as FormDebugger;
                        if (f != null)
                        {
                            td.Status = f.DebugCommandStatus;
                        }
                        else
                        {
                            td.Status = EnumRunStatus.Run;
                        }
                    }
                    UpdateViewersBackColor();
                }
            }
            h.UpdateBreakpoint(branch);
        }