Beispiel #1
0
        public IEnumerable <TrackBreakpointType> GetCrossedBreakpoints(int oldPosition, int newPosition)
        {
            var crossedBreakpoints = new List <TrackBreakpointType>();

            for (var i = oldPosition - 1; i >= newPosition; i--)
            {
                if (Breakpoints.ContainsKey(i))
                {
                    crossedBreakpoints.Add(Breakpoints[i]);
                }
            }
            return(crossedBreakpoints);
        }
 /// <summary>
 /// Checks if the virtual machine should stop at the specified address
 /// </summary>
 /// <param name="address">Address to check</param>
 /// <returns>
 /// True, if the address means a breakpoint to stop; otherwise, false
 /// </returns>
 public bool ShouldBreakAtAddress(ushort address)
 {
     return(Breakpoints.ContainsKey(address));
 }
Beispiel #3
0
        private void DebugPanel_Paint(object sender, PaintEventArgs e)
        {
            bool paint     = false;
            int  currentPC = kernel.CPU.PC;

            //if ((kernel.CPU.DebugPause))
            if (true && codeList != null)
            {
                int queueLength = codeList.Count;
                int painted     = 0;
                int index       = 0;

                // Draw the position box
                if (position.X > 0 && position.Y > 0)
                {
                    int row = position.Y / ROW_HEIGHT;
                    int col = 12;
                    e.Graphics.FillRectangle(Brushes.LightBlue, col, row * ROW_HEIGHT, 7 * 6, 14);
                }

                bool offsetPrinted = false;
                foreach (DebugLine line in codeList)
                {
                    if (line != null)
                    {
                        if (line.PC == currentPC)
                        {
                            paint        = true;
                            TopLineIndex = index;
                            if (!offsetPrinted)
                            {
                                if (index > 4)
                                {
                                    TopLineIndex -= 5;
                                    for (int c = 5; c > 0; c--)
                                    {
                                        DebugLine q0 = codeList[index - c];
                                        // Draw the label as a black box with white text
                                        if (q0.label != null)
                                        {
                                            e.Graphics.FillRectangle(Brushes.Blue, 1, painted * ROW_HEIGHT, LABEL_WIDTH + 2, ROW_HEIGHT + 2);
                                            e.Graphics.DrawString(q0.label, HeaderTextbox.Font, Brushes.Yellow, 2, painted * ROW_HEIGHT);
                                        }
                                        if (q0.PC == IRQPC)
                                        {
                                            e.Graphics.FillRectangle(Brushes.Orange, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT);
                                        }
                                        if (knl_breakpoints.ContainsKey(q0.PC))
                                        {
                                            e.Graphics.DrawEllipse(Pens.White, LABEL_WIDTH - ROW_HEIGHT - 1, painted * ROW_HEIGHT, ROW_HEIGHT + 1, ROW_HEIGHT + 1);
                                            e.Graphics.FillEllipse(Brushes.DarkRed, LABEL_WIDTH - ROW_HEIGHT, painted * ROW_HEIGHT + 1, ROW_HEIGHT, ROW_HEIGHT);
                                        }
                                        // Check if the memory still matches the opcodes
                                        if (!q0.CheckOpcodes(kernel.MemMgr.RAM))
                                        {
                                            e.Graphics.FillRectangle(Brushes.Red, LABEL_WIDTH + 3, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT);
                                        }
                                        e.Graphics.DrawString(q0.ToString(), HeaderTextbox.Font, Brushes.Black, LABEL_WIDTH + 2, painted * ROW_HEIGHT);
                                        if (q0.PC == ActiveLine[0])
                                        {
                                            e.Graphics.DrawLine(Pens.Black, LABEL_WIDTH + ActiveLine[1], (painted + 1) * ROW_HEIGHT, LABEL_WIDTH + ActiveLine[1] + ActiveLine[2], (painted + 1) * ROW_HEIGHT);
                                        }
                                        painted++;
                                    }
                                }
                                offsetPrinted = true;
                            }
                            e.Graphics.FillRectangle(line.PC == IRQPC ? Brushes.Orange : Brushes.LightBlue, LABEL_WIDTH + 1, painted * ROW_HEIGHT, DebugPanel.Width, ROW_HEIGHT);
                        }
                        if (painted > 27)
                        {
                            paint = false;
                            break;
                        }
                        if (paint)
                        {
                            if (line.label != null)
                            {
                                e.Graphics.FillRectangle(Brushes.Blue, 1, painted * ROW_HEIGHT, LABEL_WIDTH + 2, ROW_HEIGHT + 2);
                                e.Graphics.DrawString(line.label, HeaderTextbox.Font, Brushes.Yellow, 2, painted * ROW_HEIGHT);
                            }
                            if (knl_breakpoints.ContainsKey(line.PC))
                            {
                                e.Graphics.DrawEllipse(Pens.White, LABEL_WIDTH - ROW_HEIGHT - 1, painted * ROW_HEIGHT, ROW_HEIGHT + 1, ROW_HEIGHT + 1);
                                e.Graphics.FillEllipse(Brushes.DarkRed, LABEL_WIDTH - ROW_HEIGHT, painted * ROW_HEIGHT + 1, ROW_HEIGHT, ROW_HEIGHT);
                            }
                            if (line.PC == IRQPC)
                            {
                                e.Graphics.FillRectangle(Brushes.Orange, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT);
                            }
                            // Check if the memory still matches the opcodes
                            if (!line.CheckOpcodes(kernel.MemMgr.RAM))
                            {
                                e.Graphics.FillRectangle(Brushes.Red, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT);
                            }
                            e.Graphics.DrawString(line.ToString(), HeaderTextbox.Font, Brushes.Black, 102, painted * ROW_HEIGHT);
                            if (line.PC == ActiveLine[0])
                            {
                                e.Graphics.DrawLine(Pens.Black, LABEL_WIDTH + ActiveLine[1], (painted + 1) * ROW_HEIGHT, LABEL_WIDTH + ActiveLine[1] + ActiveLine[2], (painted + 1) * ROW_HEIGHT);
                            }
                            painted++;
                        }
                    }
                    index++;
                }
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.LightBlue, 0, 0, this.Width, this.Height);
                e.Graphics.DrawString("Running code real fast ... no time to write!", HeaderTextbox.Font, Brushes.Black, 8, DebugPanel.Height / 2);
            }
        }
Beispiel #4
0
        //public void OnActionExecuting(DebugInfo command)
        //{
        //    if (Breakpoints.ContainsKey(command.ActionId))
        //    {
        //        while (!ShouldContinue)
        //        {
        //            ElementsDesigner.Instance.Repaint();
        //            EditorApplication.Step();


        //        }
        //    }
        //}

        public void OnActionExecuting(DebugInfo command)
        {
            // If we are at the breakpoint
            if (CurrentBreakId != null && CurrentBreakId == command.ActionId)
            {
                if (ShouldContinue == true)
                {
                    command.Result = 0;
                    if (!ShouldStep)
                    {
                        CurrentBreakId = null;
                    }

                    return;
                }
                command.Result = 1;
                return;
            }

            if (CurrentBreakId != null && CurrentBreakId == command.PreviousId && command.PreviousId != null)
            {
                if (ShouldStep)
                {
                    CurrentBreakId = command.ActionId;
                    command.Result = 1;
                    ShouldContinue = false;
                    Execute(new NavigateToNodeCommand()
                    {
                        Node = Container.Resolve <IRepository>().GetById <SequenceItemNode>(command.ActionId)
                    });
                }
                else
                if (ShouldContinue)
                {
                    ShouldContinue = false;
                    command.Result = 0;
                    CurrentBreakId = null;
                }



                return;
            }

            if (Breakpoints.ContainsKey(command.ActionId))
            {
                CurrentBreakId = command.ActionId;
                command.Result = 1;
                Execute(new NavigateToNodeCommand()
                {
                    Node = Container.Resolve <IRepository>().GetById <SequenceItemNode>(command.ActionId)
                });
            }



            //if (CurrentBreakId == command.ActionId)
            //{
            //    if (ShouldContinue)
            //    {
            //        command.Result = 0;
            //    }
            //    else
            //    {
            //        command.Result = 1;
            //    }
            //}
            //else
            //{
            //    ShouldContinue = false;



            //}


            LastDebugEvent = command;
            //if (Breakpoints.ContainsKey(command.ActionId))
            //{
            //    command.Result = 1;
            //    Signal<IBreakpointHit>(_ => _.BreakpointHit());
            //    CurrentBreakpoint = Breakpoints[command.ActionId].Action;
            //    Execute(new NavigateToNodeCommand()
            //    {
            //        Node = CurrentBreakpoint
            //    });

            //}
            //else if (ShouldStep)
            //{
            //    if (CurrentBreakpoint != null && command.PreviousId == LastActionId)
            //    {
            //        CurrentBreakpoint = Container.Resolve<IRepository>().GetById<ActionNode>(command.ActionId);
            //        command.Result = 1;
            //        Execute(new NavigateToNodeCommand()
            //        {
            //            Node = CurrentBreakpoint
            //        });
            //        ShouldStep = false;

            //    }

            //}
        }
 /// <summary>
 /// Checks if the virtual machine should stop at the specified address
 /// </summary>
 /// <param name="address">Address to check</param>
 /// <returns>
 /// True, if the address means a breakpoint to stop; otherwise, false
 /// </returns>
 public bool ShouldBreakAtAddress(ushort address)
 => Breakpoints.ContainsKey(address);