コード例 #1
0
        public void addBreakpoint(int lineNumber, string fileName)
        {
            GlobalClass.WabbitcodeBreakpoint newBreakpoint = new GlobalClass.WabbitcodeBreakpoint();
            if (!this.debugging)
            {
                newBreakpoint.IsRam = false;
                newBreakpoint.Address = 0;
                newBreakpoint.Page = 0;
            }
            else
            {
                string breakLocInfo = this.debugTableReverse[fileName.ToLower() + ":" + (lineNumber + 1)].ToString();
                newBreakpoint.Address = UInt16.Parse(breakLocInfo.Substring(3, 4), NumberStyles.HexNumber);
                newBreakpoint.Page = byte.Parse(breakLocInfo.Substring(0, 2), NumberStyles.HexNumber);
                if (this.isAnApp)
                {
                    newBreakpoint.Page = (byte)(this.apppage - newBreakpoint.Page);
                }
                newBreakpoint.IsRam = newBreakpoint.Address > 0x8000;
                GlobalClass.emulator.SetBreakpoint(GlobalClass.mainForm.Handle, newBreakpoint.IsRam, newBreakpoint.Page, newBreakpoint.Address);
            }

            newBreakpoint.file = fileName;
            newBreakpoint.lineNumber = lineNumber;
            newBreakpoint.Enabled = true;
            GlobalClass.breakpoints.Add(newBreakpoint);
        }
コード例 #2
0
        public void removeBreakpoint(int lineNumber, string fileName)
        {
            int breakNum = GlobalClass.findBreakpoint(fileName, lineNumber);
            if (breakNum == -1)
            {
                return;
            }
            GlobalClass.WabbitcodeBreakpoint newBreakpoint = GlobalClass.breakpoints[breakNum];
            if (GlobalClass.debugger.debugging)
            {
                // int page = newBreakpoint.Page;
                // if (isAnApp)
                //    page = (byte) (apppage - newBreakpoint.Page);
                GlobalClass.emulator.ClearBreakpoint(newBreakpoint.IsRam, newBreakpoint.Page, newBreakpoint.Address);
            }

            GlobalClass.breakpoints.Remove(newBreakpoint);
        }
コード例 #3
0
        private void HitBreakpoint()
        {
            ushort address = GlobalClass.emulator.GetState().PC;
            string currentPC = address.ToString("X");
            string pagenum = this.getPageNum(currentPC);
            byte page = Convert.ToByte(pagenum);
            if (this.isAnApp)
            {
                page = (byte)(this.apppage - page);
            }
            int breakNum = GlobalClass.findBreakpoint(address, page, address > 0x8000);
            if (breakNum == -1)
            {
                return;
            }
            GlobalClass.WabbitcodeBreakpoint breakpoint = GlobalClass.breakpoints[breakNum];
            breakpoint.numberOfTimesHit = GlobalClass.breakpoints[breakNum].numberOfTimesHit + 1;
            bool conditionsTrue = breakpoint.Enabled;
            switch (breakpoint.hitCountCondition)
            {
            case GlobalClass.HitCountEnum.BreakEqualTo:
                if (breakpoint.numberOfTimesHit != breakpoint.hitCountConditionNumber)
                {
                    conditionsTrue &= false;
                }
                break;
            case GlobalClass.HitCountEnum.BreakGreaterThanEqualTo:
                if (breakpoint.numberOfTimesHit < breakpoint.hitCountConditionNumber)
                {
                    conditionsTrue &= false;
                }
                break;
            case GlobalClass.HitCountEnum.BreakMultipleOf:
                if (breakpoint.numberOfTimesHit % breakpoint.hitCountConditionNumber != 0)
                {
                    conditionsTrue &= false;
                }
                break;
            }

            // breakpoint.breakCondition = new List<GlobalClass.BreakCondition>();
            // GlobalClass.BreakCondition newCondition = new GlobalClass.BreakCondition();
            // newCondition.h = 5 << 16;
            // newCondition.l = 5 << 16;
            // breakpoint.breakCondition.Add(newCondition);
            if (breakpoint.breakCondition != null)
            {
                foreach (GlobalClass.BreakCondition condition in breakpoint.breakCondition)
                }
            {
                conditionsTrue &= this.evalCondition(condition);
            }
            if (conditionsTrue)
            {
                string locInfo = this.debugTable[pagenum + ":" + currentPC].ToString();
                string file = locInfo.Substring(0, locInfo.LastIndexOf(':'));
                string lineNumber = locInfo.Substring(
                                        locInfo.LastIndexOf(':') + 1,
                                        locInfo.Length - locInfo.LastIndexOf(':') - 1);
                GlobalClass.breakpoints[breakNum] = breakpoint;
                GlobalClass.mainForm.gotoLine(file, Convert.ToInt32(lineNumber));
                this.highlightLine(Convert.ToInt32(lineNumber));

                // this reinitiates all the good stuff
                IntPtr calculatorHandle = GlobalClass.mainForm.Handle;

                // switch to back to us
                SetForegroundWindow(calculatorHandle);
                GlobalClass.mainForm.updateDebugStuff(true);
                GlobalClass.trackWindow.updateVars();
                GlobalClass.debugPanel.updateFlags();
                GlobalClass.debugPanel.updateRegisters();
                GlobalClass.debugPanel.updateScreen();
            }
            else
            {
                GlobalClass.emulator.RunCalc();
            }
        }
コード例 #4
0
        public Debugger()
        {
            this.debugging = true;
            GlobalClass.mainForm.updateDebugStuff(true);
            if (GlobalClass.project.projectOpen)
            {
                this.AssembleProject();
            }
            else
            {
                this.AssembleFile();
            }

            // wait for spasm to finish
            this.assembler.Join();

            // if errors, alert the user
            if (!this.debugging || this.assembler.Errors)
            {
                if (
                    MessageBox.Show("There were errors assembling. Would you like to continue and try to debug?",
                                    "Continue",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Error) == DialogResult.No)
                {
                    GlobalClass.mainForm.cancelDebug_Click(null, null);
                    return;
                }
            }

            this.emulatorWindow = new EmulatorWindow();
            this.emulatorWindow.Show(GlobalClass.mainForm.dockPanel);

            GlobalClass.emulator.LoadFile(this.createdName);

            // return;

            this.showToolbar = Settings.Default.debugToolbar;
            Settings.Default.debugToolbar = true;
            if (!this.showToolbar)
            {
                GlobalClass.mainForm.toolBarManager.AddControl(
                    GlobalClass.mainForm.debugToolStrip,
                    DockStyle.Top,
                    GlobalClass.mainForm.mainToolBar,
                    DockStyle.Right);
            }
            GlobalClass.mainForm.debugToolStrip.Height = GlobalClass.mainForm.mainToolBar.Height;
            GlobalClass.mainForm.updateChecks();
            GlobalClass.debugPanel.Show(GlobalClass.mainForm.dockPanel);
            GlobalClass.trackWindow.Show(GlobalClass.mainForm.dockPanel);
            GlobalClass.callStack.Show(GlobalClass.mainForm.dockPanel);

            StreamReader reader = new StreamReader(this.listName);
            string listFileText = reader.ReadToEnd();
            reader = new StreamReader(this.symName);
            string symFileText = reader.ReadToEnd();

            this.debugTable = new Hashtable();
            this.debugTableReverse = new Hashtable();
            this.parseListFile(listFileText, this.fileName, Path.GetDirectoryName(this.fileName), ref this.debugTable, ref this.debugTableReverse);
            this.symTable = new SymbolTableClass();
            this.symTable.parseSymFile(symFileText);

            // updateStack();
            if (this.startAddress == "4080")
            {
                this.isAnApp = true;
                Applist appList = new Applist();

                // TODO: SEARCH FOR APP
                /*foreach (Wabbitemu.AppEntry app in appList)
                {

                }*/
                /*while (appList.count == 0)
                {
                    appList = GlobalClass.emulator.GetApplist();
                    Thread.Sleep(1000);
                }
                apppage = (byte)appList.apps[0].page;*/
                this.apppage = 105;

                TextEditorControl editorBox;
                GlobalClass.mainForm.staticLabelMarkers = new List<TextMarker>();
                foreach (newEditor child in GlobalClass.mainForm.MdiChildren)
                {
                    editorBox = child.editorBox;
                    string breakLocInfo;
                    ReadOnlyCollection<Breakpoint> marks = editorBox.Document.BreakpointManager.Marks;
                    foreach (Breakpoint breakpoint in marks)
                    {
                        int breakNum = GlobalClass.findBreakpoint(editorBox.FileName, breakpoint.LineNumber);
                        if (this.debugTable.ContainsValue(editorBox.FileName.ToLower() + ":" + (breakpoint.LineNumber + 1)) && breakNum != -1)
                        {
                            GlobalClass.WabbitcodeBreakpoint newBreakpoint = GlobalClass.breakpoints[breakNum];
                            breakLocInfo =
                                this.debugTableReverse[editorBox.FileName.ToLower() + ":" + (breakpoint.LineNumber + 1)].ToString();
                            newBreakpoint.Address = UInt16.Parse(breakLocInfo.Substring(3, 4), NumberStyles.HexNumber);
                            if (this.isAnApp)
                            {
                                newBreakpoint.Page = (byte)(this.apppage - byte.Parse(breakLocInfo.Substring(0, 2), NumberStyles.HexNumber));
                            }
                            else
                            {
                                newBreakpoint.Page = byte.Parse(breakLocInfo.Substring(0, 2), NumberStyles.HexNumber);
                            }
                            newBreakpoint.IsRam = newBreakpoint.Address > 0x8000;
                            newBreakpoint.file = editorBox.FileName;
                            newBreakpoint.lineNumber = breakpoint.LineNumber;
                            GlobalClass.breakpoints[breakNum] = newBreakpoint;
                            this.emulatorWindow.emulator.SetBreakpoint(GlobalClass.mainForm.Handle, newBreakpoint.IsRam, newBreakpoint.Page, newBreakpoint.Address);
                        }
                        else
                        {
                            editorBox.Document.BreakpointManager.RemoveMark(breakpoint);
                            break;
                        }
                    }

                    child.setNextStateMenuItem.Visible = true;
                }

                if (!GlobalClass.mainForm.staticLabelsParser.IsBusy && !GlobalClass.mainForm.IsDisposed && !GlobalClass.mainForm.Disposing)
                {
                    GlobalClass.mainForm.staticLabelsParser.RunWorkerAsync();
                }

                // GlobalClass.breakManager.updateManager();
                #region OldDebug
                // Kept for sentimental reasons
                // ((Wabbitcode.newEditor)(ActiveMdiChild)).editorBox.ActiveTextAreaControl.Enabled = false;

                // old stuff?
                // string locInfo = debugTable[page + ":" + startAddress].ToString();
                // string file = locInfo.Substring(0, locInfo.LastIndexOf(':'));
                // string line = locInfo.Substring(locInfo.LastIndexOf(':') + 1, locInfo.Length - locInfo.LastIndexOf(':') - 1);
                /*
                if (Path.GetExtension(createdName) == ".8xk")
                {
                    isAnApp = true;
                    Wabbitemu.AppEntry[] appList = debugger.getAppList();
                    apppage = appList[0].page;
                    debugger.setBreakpoint(false, apppage, 0x4080);
                }
                else
                {
                    debugger.sendKeyPress((int)Keys.F12);
                    debugger.releaseKeyPress((int)Keys.F12);
                    System.Threading.Thread.Sleep(2000);
                    debugger.setBreakpoint(true, 1, 0x9D95);
                }*/
                /*try
                {
                    while (debugging)
                    {
                        Application.DoEvents();
                    }

                        //calcScreen.Image = debugger.DrawScreen();
                        var currentLoc = new Wabbitemu.breakpoint();
                        currentLoc.Address = debugger.getState().PC;
                        currentLoc.Page = byte.Parse(getPageNum(currentLoc.Address.ToString("X")), NumberStyles.HexNumber);
                        currentLoc.IsRam = getRamState(currentLoc.Address.ToString("X"));
                        bool breakpointed = false;
                        foreach (Wabbitemu.breakpoint breakpoint in breakpoints)
                        {
                            if (breakpoint.Page == currentLoc.Page && breakpoint.Address == currentLoc.Address)
                                breakpointed = true;
                        }
                        while (breakpointed)
                        {
                            //updateRegisters();
                            //updateFlags();
                            //updateCPUStatus();
                            //updateInterrupts();
                            if (stepOverClicked)
                                step(debugTable);
                            Application.DoEvents();
                        }
                        debugger.step();
                        //System.Threading.Thread.Sleep(2000);
                        Application.DoEvents();
                    }
                }
                catch (COMException ex)
                {
                    if (ex.ErrorCode != -2147023174)
                        MessageBox.Show(ex.ToString());
                }*/
                #endregion
            }
        }