public void addBreakpoint(int lineNumber, string fileName) { if (!this.debugging) { return; } this.debugger.getState(); if (!this.debugger.isWabbitOpen) { wabbitClosed(); return; } Wabbitemu.breakpoint newBreakpoint = new Wabbitemu.breakpoint(); string breakLocInfo = this.debugTableReverse[fileName + ":" + (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 ? 0 : 1; this.breakpoints.Add(newBreakpoint); this.debugger.setBreakpoint(Handle, newBreakpoint); if (!this.debugger.isWabbitOpen) { wabbitClosed(); } }
public void removeBreakpoint(int lineNumber, string fileName) { if (!this.debugging) { return; } this.debugger.getState(); if (!this.debugger.isWabbitOpen) { wabbitClosed(); return; } Wabbitemu.breakpoint newBreakpoint = new Wabbitemu.breakpoint(); if (this.debugTableReverse.Contains(fileName + ":" + (lineNumber + 1))) { string breakLocInfo = this.debugTableReverse[fileName + ":" + (lineNumber + 1)].ToString(); newBreakpoint.Address = UInt16.Parse(breakLocInfo.Substring(3, 4), NumberStyles.HexNumber); newBreakpoint.Page = (byte)(this.apppage - byte.Parse(breakLocInfo.Substring(0, 2), NumberStyles.HexNumber)); newBreakpoint.IsRam = newBreakpoint.Address < 0x8000 ? 0 : 1; this.debugger.clearBreakpoint(newBreakpoint); this.breakpoints.Remove(newBreakpoint); } }
private void startDebug(object sender, EventArgs e) { if (this.debugging) { run(); } else { this.debugging = true; string listName; string symName; string fileName = ""; string startAddress; string createdName = ""; bool error = true; if (this.projectOpen) { listName = Path.Combine(projectLoc, projectName + ".lst"); symName = Path.Combine(projectLoc, projectName + ".lab"); fileName = Path.Combine(projectLoc, projectName + ".asm"); NewProject project = new NewProject(this.wcodeProjectFile); int outputType = project.getOutputType(); startAddress = outputType == 5 ? "4080" : "9D95"; XmlNodeList buildConfigs; XmlDocument doc = new XmlDocument(); doc.Load(this.wcodeProjectFile); buildConfigs = doc.ChildNodes[1].ChildNodes[1].ChildNodes; int counter = 0; foreach (XmlNode config in buildConfigs) { if (config.Name.ToLower() == "debug") { Settings.Default.buildConfig = counter; counter = -1; break; } counter++; } if (counter == -1) { createdName = assembleProject(); } else { MessageBox.Show("No build config named Debug was found!"); this.debugging = false; return; } } else { if (ActiveMdiChild != null) { fileName = ((newEditor)ActiveMdiChild).editorBox.FileName; } error &= createListing(fileName, Path.ChangeExtension(fileName, "lst")); // if (error) // MessageBox.Show("Problem creating list file"); error &= createSymTable(fileName, Path.ChangeExtension(fileName, "lab")); // if (error) // MessageBox.Show("Problem creating symtable"); error &= assembleCode(fileName, false, Path.ChangeExtension(fileName, getExtension(Settings.Default.outputFile))); // if (error) // MessageBox.Show("Problem creating 8xp file"); listName = Path.ChangeExtension(fileName, ".lst"); symName = Path.ChangeExtension(fileName, ".lab"); switch (Settings.Default.outputFile) { case 4: startAddress = "9D95"; createdName = Path.ChangeExtension(fileName, "8xp"); break; case 5: startAddress = "4080"; createdName = Path.ChangeExtension(fileName, "8xk"); break; default: MessageBox.Show("You cannont debug a non 83/84 Plus file!"); goto NoMoreDebug; } } if (!this.debugging || !error) { if (MessageBox.Show("There were errors compiling!!! Would you like to continue and try to debug?", "Continue", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No) { cancelDebug_Click(null, null); return; } } // if (!File.Exists(listName)) // createListing(fileName, Path.ChangeExtension(fileName, "lst")); this.debugger = new Wabbitemu(createdName); this.showToolbar = Settings.Default.debugToolbar; Settings.Default.debugToolbar = true; debugToolStrip.Show(); updateChecks(); debugPanel = new DebugPanel(this.debugger); debugPanel.Show(dockPanel, Settings.Default.debugPanelLoc); trackWindow.Show(dockPanel); StreamReader reader = new StreamReader(listName); // StreamReader breakReader = new StreamReader(fileName.Remove(fileName.Length - 3) + "brk"); string listFileText = reader.ReadToEnd(); // string[] listFileLines = listFileText.Split('\n'); reader = new StreamReader(symName); string symFileText = reader.ReadToEnd(); this.debugTable = new Hashtable(); this.debugTableReverse = new Hashtable(); TextEditorControl editorBox; // int CurrentListLine = 0; // while (!listFileLines[currentListLine].Contains("9D95")) // currentListLine++; this.parseListFile(listFileText, fileName, Path.GetDirectoryName(fileName), ref this.debugTable, ref this.debugTableReverse); this.parseSymFile(symFileText); // string[] breakpoints = breakReader.ReadToEnd().Split('\n'); // calcScreen.BackColor = Color.FromArgb(158, 171, 136); this.staticLabelMarkers = new List<TextMarker>(); this.breakpoints = new List<Wabbitemu.breakpoint>(); foreach (newEditor child in MdiChildren) { editorBox = child.editorBox; string breakLocInfo; ReadOnlyCollection<Breakpoint> marks = editorBox.Document.BreakpointManager.Marks; foreach (Breakpoint breakpoint in marks) { var newBreakpoint = new Wabbitemu.breakpoint(); if (this.debugTable.ContainsValue(editorBox.FileName + ":" + (breakpoint.LineNumber + 1))) { breakLocInfo = this.debugTableReverse[editorBox.FileName + ":" + (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 ? 0 : 1; this.breakpoints.Add(newBreakpoint); this.debugger.setBreakpoint(Handle, newBreakpoint); } else { editorBox.Document.BreakpointManager.RemoveMark(breakpoint); } } child.setNextStateMenuItem.Visible = true; this.addStaticLabels(editorBox); } // debugger.setBreakpoint(Handle, true, 1, 0x9D95); Wabbitemu.MEMSTATE test = this.debugger.getMemState(); if (!this.debugger.isWabbitOpen) { wabbitClosed(); } if (startAddress == "4080") { this.isAnApp = true; Wabbitemu.AppEntry[] appList = new Wabbitemu.AppEntry[20]; foreach (Wabbitemu.AppEntry app in appList) { } while (appList[0].page_count == 0) { appList = this.debugger.getAppList(); this.apppage = (byte)appList[0].page; Thread.Sleep(500); } } #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 } NoMoreDebug: ; }