Exemple #1
0
        public void DeleteBreakpoint(int RemoteIndex, Types.Breakpoint bp)
        {
            RequestData requData = new RequestData(DebugRequestType.DELETE_BREAKPOINT, bp.RemoteIndex);

            requData.Breakpoint = bp;
            QueueRequest(requData);
        }
Exemple #2
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;
             }
         }
     }
 }
Exemple #3
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, Core.Compiling.ParserASM.m_TextCodeMappingRaw);
                if (Core.Compiling.ParserASM.HasError())
                {
                    Core.AddToOutput("Failed to ParseTokenInfo" + System.Environment.NewLine);
                    continue;
                }
                int result = -1;
                if (!Core.Compiling.ParserASM.EvaluateTokens(-1, tokenInfos, Core.Compiling.ParserASM.m_TextCodeMappingRaw, out SymbolInfo resultSymbol))
                {
                    Core.AddToOutput("Failed to evaluate " + virtualBP.Expression + System.Environment.NewLine);
                    continue;
                }
                result = resultSymbol.ToInt32();
                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, traceSize, 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);
        }
        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)
                    {
                        RetroDevStudio.Types.Breakpoint bp = new RetroDevStudio.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("RetroDevStudio.DebugBreakpoints"))
                        {
                            BreakPoints.Add("RetroDevStudio.DebugBreakpoints", new List <RetroDevStudio.Types.Breakpoint>());
                        }
                        BreakPoints["RetroDevStudio.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);
                }
            }
        }
        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 RetroDevStudio.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);
        }
Exemple #7
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);
        }