Example #1
0
        private void btnApplyChanges_Click(object sender, EventArgs e)
        {
            if (listBreakpoints.SelectedIndices.Count == 0)
            {
                return;
            }
            Types.Breakpoint bp = (Types.Breakpoint)listBreakpoints.SelectedItems[0].Tag;

            bool addressChanged = (bp.Address != GR.Convert.ToI32(editBPAddress.Text, 16));

            bp.Conditions = editTriggerConditions.Text;
            if (addressChanged)
            {
                bp.Address = GR.Convert.ToI32(editBPAddress.Text, 16);
            }
            bp.TriggerOnExec  = checkTriggerExec.Checked;
            bp.TriggerOnLoad  = checkTriggerLoad.Checked;
            bp.TriggerOnStore = checkTriggerStore.Checked;
            bp.RemoteIndex    = -1;

            RaiseDocEvent(new DocEvent(DocEvent.Type.BREAKPOINT_REMOVED, bp));

            if (addressChanged)
            {
                // address was changed, so line index doesn't apply anymore
                bp.LineIndex = -1;
            }
            RaiseDocEvent(new DocEvent(DocEvent.Type.BREAKPOINT_ADDED, bp));
        }
Example #2
0
        public void DeleteBreakpoint(int RemoteIndex, Types.Breakpoint bp)
        {
            RequestData requData = new RequestData(DebugRequestType.DELETE_BREAKPOINT, bp.RemoteIndex);

            requData.Breakpoint = bp;
            QueueRequest(requData);
        }
Example #3
0
 public void RemoveBreakpoint(int BreakPointIndex, Types.Breakpoint BP)
 {
     foreach (Types.Breakpoint breakPoint in m_BreakPoints)
     {
         if (breakPoint.RemoteIndex == BreakPointIndex)
         {
             breakPoint.Virtual.Remove(BP);
             if (breakPoint.Virtual.Count == 0)
             {
                 m_BreakPoints.Remove(breakPoint);
                 break;
             }
             if ((breakPoint.LineIndex == BP.LineIndex) &&
                 (breakPoint.IsVirtual == BP.IsVirtual) &&
                 (breakPoint.Expression == BP.Expression) &&
                 (breakPoint.Conditions == BP.Conditions) &&
                 (breakPoint.DocumentFilename == BP.DocumentFilename))
             {
                 // the main bp is the one to be removed (copy virtual up)
                 breakPoint.LineIndex        = breakPoint.Virtual[0].LineIndex;
                 breakPoint.DocumentFilename = breakPoint.Virtual[0].DocumentFilename;
                 breakPoint.IsVirtual        = breakPoint.Virtual[0].IsVirtual;
                 breakPoint.Expression       = breakPoint.Virtual[0].Expression;
                 breakPoint.Conditions       = breakPoint.Virtual[0].Conditions;
             }
         }
     }
 }
Example #4
0
        public void AddBreakpoint(Types.Breakpoint BreakPoint)
        {
            if ((!BreakPoint.Temporary) &&
                (m_BreakPoints.ContainsValue(BreakPoint)))
            {
                return;
            }

            bool added = false;

            foreach (Types.Breakpoint breakPoint in m_BreakPoints)
            {
                if (breakPoint.Address == BreakPoint.Address)
                {
                    // there is already a breakpoint here
                    breakPoint.Virtual.Add(BreakPoint);
                    added = true;
                    Debug.Log("Virtual bp!");
                    break;
                }
            }
            if (!added)
            {
                m_BreakPoints.Add(BreakPoint);
            }
        }
        public bool OnVirtualBreakpointReached(Types.Breakpoint Breakpoint)
        {
            Debug.Log("OnVirtualBreakpointReached");
            bool        addedRequest = false;
            RequestData prevRequest  = null;

            foreach (var virtualBP in Breakpoint.Virtual)
            {
                if (!virtualBP.IsVirtual)
                {
                    continue;
                }
                var tokenInfos = Core.Compiling.ParserASM.ParseTokenInfo(virtualBP.Expression, 0, virtualBP.Expression.Length);
                if (Core.Compiling.ParserASM.HasError())
                {
                    Core.AddToOutput("Failed to ParseTokenInfo" + System.Environment.NewLine);
                    continue;
                }
                int result = -1;
                if (!Core.Compiling.ParserASM.EvaluateTokens(-1, tokenInfos, out SymbolInfo resultSymbol))
                {
                    Core.AddToOutput("Failed to evaluate " + virtualBP.Expression + System.Environment.NewLine);
                    continue;
                }
                result = resultSymbol.ToInteger();
                if ((result < 0) ||
                    (result >= 65536))
                {
                    Core.AddToOutput("Evaluated address out of range " + result + System.Environment.NewLine);
                    continue;
                }

                if (prevRequest != null)
                {
                    prevRequest.LastInGroup = false;
                }

                int traceSize = 1;
                var requData  = Debugger.RefreshTraceMemory(result, result + traceSize - 1, virtualBP.Expression, virtualBP, Breakpoint);

                if (requData.Parameter2 >= 0x10000)
                {
                    requData.Parameter2 = 0xffff;
                }

                prevRequest = requData;

                addedRequest = true;
            }
            if (!addedRequest)
            {
                // and auto-go on with debugging
                Debugger.Run();
                return(false);
            }
            return(true);
        }
Example #6
0
        private void btnDeleteBreakpoint_Click(object sender, EventArgs e)
        {
            if (listBreakpoints.SelectedIndices.Count == 0)
            {
                return;
            }
            Types.Breakpoint bp = (Types.Breakpoint)listBreakpoints.SelectedItems[0].Tag;

            RaiseDocEvent(new DocEvent(DocEvent.Type.BREAKPOINT_REMOVED, bp));
        }
Example #7
0
 public void RemoveBreakpoint(Types.Breakpoint Breakpoint)
 {
     foreach (ListViewItem item in listBreakpoints.Items)
     {
         if (item.Tag == Breakpoint)
         {
             listBreakpoints.Items.Remove(item);
             return;
         }
     }
 }
Example #8
0
 public void UpdateBreakpoint(Types.Breakpoint Breakpoint)
 {
     foreach (ListViewItem item in listBreakpoints.Items)
     {
         if (item.Tag == Breakpoint)
         {
             AdjustItemText(item, Breakpoint);
             return;
         }
     }
 }
Example #9
0
        public void AddVirtualBreakpoints(Types.ASM.FileInfo ASMFileInfo)
        {
            if (ASMFileInfo == null)
            {
                return;
            }
            foreach (var virtualBP in ASMFileInfo.VirtualBreakpoints.Values)
            {
                virtualBP.IsVirtual = true;
                int globalLineIndex = -1;
                if (!ASMFileInfo.FindGlobalLineIndex(virtualBP.LineIndex, virtualBP.DocumentFilename, out globalLineIndex))
                {
                    Core.AddToOutput("Cannot assign breakpoint for line " + virtualBP.LineIndex + ", no address found" + System.Environment.NewLine);
                    continue;
                }
                int address = ASMFileInfo.FindLineAddress(globalLineIndex);
                if (address != -1)
                {
                    var existingBP = BreakpointAtAddress(address);

                    if (existingBP == null)
                    {
                        C64Studio.Types.Breakpoint bp = new C64Studio.Types.Breakpoint();

                        bp.LineIndex        = virtualBP.LineIndex;
                        bp.Address          = address;
                        bp.TriggerOnExec    = true;
                        bp.IsVirtual        = true;
                        bp.DocumentFilename = virtualBP.DocumentFilename;
                        bp.Virtual.Add(virtualBP);
                        virtualBP.Address = address;
                        // we just need any key (as null is not allowed)
                        if (!BreakPoints.ContainsKey("C64Studio.DebugBreakpoints"))
                        {
                            BreakPoints.Add("C64Studio.DebugBreakpoints", new List <C64Studio.Types.Breakpoint>());
                        }
                        BreakPoints["C64Studio.DebugBreakpoints"].Add(bp);
                        //AddBreakpoint( bp );
                        Debug.Log("Add virtual bp for $" + address.ToString("X4"));
                    }
                    else
                    {
                        // merge with existing
                        existingBP.TriggerOnExec = true;
                        existingBP.Virtual.Add(virtualBP);
                    }
                }
                else
                {
                    Core.AddToOutput("Cannot assign breakpoint for line " + virtualBP.LineIndex + ", no address found" + System.Environment.NewLine);
                }
            }
        }
Example #10
0
        public void AddBreakpoint(Types.Breakpoint Breakpoint)
        {
            ListViewItem item = new ListViewItem();

            for (int i = 0; i < 5; ++i)
            {
                item.SubItems.Add("");
            }
            AdjustItemText(item, Breakpoint);
            item.Tag = Breakpoint;

            listBreakpoints.Items.Add(item);
        }
Example #11
0
        public bool OnInitialBreakpointReached(int Address)
        {
            if ((BreakpointsToAddAfterStartup.Count == 0) &&
                (Core.Debugging.OverrideDebugStart == -1))
            {
                return(false);
            }
            // now add all later breakpoints
            foreach (Types.Breakpoint bp in BreakpointsToAddAfterStartup)
            {
                Debugger.AddBreakpoint(bp);
            }
            // only auto-go on if the initial break point was not the fake first breakpoint
            if (Address != LateBreakpointOverrideDebugStart)
            {
                // need to add new intermediate break point
                Types.Breakpoint bpTemp = new C64Studio.Types.Breakpoint();

                bpTemp.Address       = LateBreakpointOverrideDebugStart;
                bpTemp.TriggerOnExec = true;
                bpTemp.Temporary     = true;

                Debugger.AddBreakpoint(bpTemp);
            }

            if (MarkedDocument != null)
            {
                MarkLine(MarkedDocument.DocumentInfo.Project, MarkedDocument.DocumentInfo, -1);
                MarkedDocument = null;
            }

            // keep running for non cart
            if (!Parser.ASMFileParser.IsCartridge(DebugType))
            {
                Debugger.Run();
            }

            Core.Executing.BringToForeground();

            FirstActionAfterBreak = false;
            Core.MainForm.SetGUIForDebugging(true);

            // force a reset for cartridges, so the debugger starts at the init
            // can't reset on a normal file, just hope our break point is not hit too early
            if (Parser.ASMFileParser.IsCartridge(DebugType))
            {
                Debugger.Reset();
            }
            return(true);
        }
Example #12
0
        private void listBreakpoints_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnDeleteBreakpoint.Enabled = (listBreakpoints.SelectedItems.Count != 0);
            btnApplyChanges.Enabled     = false;

            if (listBreakpoints.SelectedItems.Count > 0)
            {
                Types.Breakpoint bp = (Types.Breakpoint)listBreakpoints.SelectedItems[0].Tag;

                editBPAddress.Text        = bp.Address.ToString("x");
                checkTriggerExec.Checked  = bp.TriggerOnExec;
                checkTriggerLoad.Checked  = bp.TriggerOnLoad;
                checkTriggerStore.Checked = bp.TriggerOnStore;
            }
        }
Example #13
0
        private void UpdateApplyButton()
        {
            if (listBreakpoints.SelectedItems.Count > 0)
            {
                Types.Breakpoint bp = (Types.Breakpoint)listBreakpoints.SelectedItems[0].Tag;

                if ((bp.Address != GR.Convert.ToI32(editBPAddress.Text, 16)) ||
                    (bp.Conditions != editTriggerConditions.Text) ||
                    (bp.TriggerOnExec != checkTriggerExec.Checked) ||
                    (bp.TriggerOnLoad != checkTriggerLoad.Checked) ||
                    (bp.TriggerOnStore != checkTriggerStore.Checked))
                {
                    btnApplyChanges.Enabled = true;
                }
                else
                {
                    btnApplyChanges.Enabled = false;
                }
            }
            else
            {
                btnApplyChanges.Enabled = false;
            }
        }
Example #14
0
 public DocEvent(Type EventType, Types.Breakpoint Breakpoint, int LineIndex)
 {
     this.EventType  = EventType;
     this.Breakpoint = Breakpoint;
     this.LineIndex  = LineIndex;
 }
Example #15
0
 public DocEvent(Type EventType, Types.Breakpoint Breakpoint)
 {
     this.EventType  = EventType;
     this.Breakpoint = Breakpoint;
 }
Example #16
0
        private void AdjustItemText(ListViewItem Item, Types.Breakpoint Breakpoint)
        {
            if (Breakpoint.RemoteIndex == -1)
            {
                Item.Text = "-";
            }
            else
            {
                Item.Text = Breakpoint.RemoteIndex.ToString();
            }

            if (Breakpoint.DocumentFilename != "C64Studio.DebugBreakpoints")
            {
                Item.SubItems[1].Text = Breakpoint.DocumentFilename;
            }
            else
            {
                Item.SubItems[1].Text = "---";
            }

            if (Breakpoint.LineIndex == -1)
            {
                Item.SubItems[2].Text = "-";
            }
            else
            {
                Item.SubItems[2].Text = (Breakpoint.LineIndex + 1).ToString();
            }

            string triggerDesc = "";

            if (Breakpoint.TriggerOnExec)
            {
                triggerDesc += "X";
            }
            if (Breakpoint.TriggerOnStore)
            {
                triggerDesc += "S";
            }
            if (Breakpoint.TriggerOnLoad)
            {
                triggerDesc += "L";
            }
            Item.SubItems[3].Text = triggerDesc;

            Item.SubItems[4].Text = Breakpoint.Conditions;

            if (Breakpoint.AddressSource != null)
            {
                if (Breakpoint.Address != -1)
                {
                    Item.SubItems[5].Text = Breakpoint.AddressSource + " ($" + Breakpoint.Address.ToString("x4") + ")";
                }
                else
                {
                    Item.SubItems[5].Text = Breakpoint.AddressSource;
                }
            }
            else if (Breakpoint.Address != -1)
            {
                Item.SubItems[5].Text = "$" + Breakpoint.Address.ToString("x4");
            }
            else
            {
                Item.SubItems[5].Text = "----";
            }
        }
Example #17
0
        public RequestData RefreshTraceMemory(int StartAddress, int Size, string Info, Types.Breakpoint VirtualBP, Types.Breakpoint TraceBP)
        {
            RequestData requData = new RequestData(DebugRequestType.TRACE_MEM_DUMP);

            requData.Parameter1     = StartAddress;
            requData.Parameter2     = StartAddress + Size - 1;
            requData.MemDumpOffsetX = false; //watchEntry.IndexedX;
            requData.MemDumpOffsetY = false; //watchEntry.IndexedY;
            requData.Info           = VirtualBP.Expression;
            requData.Breakpoint     = TraceBP;

            QueueRequest(requData);

            return(requData);
        }