From e71f8c096a9ad175fc938db0d1f0b3ab5b6f0436 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Mon, 1 Feb 2016 14:25:58 -0800 Subject: [PATCH] Debugger refinements --- _config.yml | 2 +- devices/pc/machine/README.md | 2 +- disks/pc/README.md | 6 +- disks/pc/windows/1.03/README.md | 2 +- docs/README.md | 2 +- modules/pcjs/lib/debugger.js | 138 +++++++++++++++++++------------- modules/pcjs/lib/defines.js | 2 +- modules/pcjs/lib/disk.js | 42 +++++++--- modules/pcjs/lib/x86cpu.js | 2 +- 9 files changed, 124 insertions(+), 74 deletions(-) diff --git a/_config.yml b/_config.yml index 97d2033ca..9d3b8d542 100644 --- a/_config.yml +++ b/_config.yml @@ -32,7 +32,7 @@ gems: pcjs: domain: pcjs.org # whereas site.url is used for linking purposes, site.pcjs.domain is used for display purposes version: 1.20.8 # IMPORTANT: keep pcjs.version in sync with package.json:version - compiled: false # by default, the compiled pcjs.version scripts will be used (eg, pc.js or pc-dbg.js) + compiled: true # by default, the compiled pcjs.version scripts will be used (eg, pc.js or pc-dbg.js) pc_scripts: # if pcjs.compiled is false, the following scripts will be included instead, in the order listed - /modules/shared/lib/defines.js - /modules/shared/lib/diskapi.js diff --git a/devices/pc/machine/README.md b/devices/pc/machine/README.md index 7fe4c9ffd..20be221f4 100644 --- a/devices/pc/machine/README.md +++ b/devices/pc/machine/README.md @@ -2,7 +2,7 @@ layout: page title: Machine Configurations menu_title: Machines -menu_order: 5 +menu_order: 6 permalink: /devices/pc/machine/ redirect_from: - /configs/pc/machines/ diff --git a/disks/pc/README.md b/disks/pc/README.md index 5d4600426..cd2901046 100644 --- a/disks/pc/README.md +++ b/disks/pc/README.md @@ -1,14 +1,16 @@ --- layout: page title: IBM PC Disk Archive +menu_title: Disks +menu_order: 4 permalink: /disks/pc/ --- IBM PC Disk Archive --- -This is a list of disks available to any of the [IBM PC Machines](/devices/pc/machine/) that use the -[library.xml](/disks/pc/library.xml) disk configuration file. +This is a list of disks available to any of the [IBM PC Machines](/devices/pc/machine/) that use our +[Library](/disks/pc/library.xml) XML disk configuration file. For some of the disks below, we have provided more information about the software, and in some cases, machines that automatically run the software. diff --git a/disks/pc/windows/1.03/README.md b/disks/pc/windows/1.03/README.md index 98e5e2cb7..5ab46ba55 100644 --- a/disks/pc/windows/1.03/README.md +++ b/disks/pc/windows/1.03/README.md @@ -12,7 +12,7 @@ Windows 1.03 was released in August 1986. Directory listings of the six 360Kb distribution diskettes are provided below. It's been noted on [WinWorld](https://winworldpc.com/product/windows-10/103) that version 1.03 disks have -been found with `USER.EXE` dated either `05-22-86` *or* `08-24-86`. The latter is available as +been found with `USER.EXE` dated either `05-22-86` *or* `08-24-86`. The latter is available here as [Windows 1.03b](../1.03b/). These disks were dumped from the PCjs private collection. Differences include: diff --git a/docs/README.md b/docs/README.md index 893cf5036..db87e7d5a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,7 +2,7 @@ layout: page title: Documentation menu_title: Docs -menu_order: 6 +menu_order: 8 permalink: /docs/ --- diff --git a/modules/pcjs/lib/debugger.js b/modules/pcjs/lib/debugger.js index f26299d74..a9d2a35ba 100644 --- a/modules/pcjs/lib/debugger.js +++ b/modules/pcjs/lib/debugger.js @@ -2731,7 +2731,10 @@ if (DEBUGGER) { Debugger.prototype.toHexAddr = function(dbgAddr) { var ch = this.getAddrPrefix(dbgAddr); - return dbgAddr.sel == null? (ch + str.toHex(dbgAddr.addr)) : (ch + this.toHexOffset(dbgAddr.off, dbgAddr.sel, dbgAddr.fAddr32)); + /* + * TODO: Revisit the decision to check sel == null; I would rather see these decisions based on type. + */ + return (dbgAddr.type >= Debugger.ADDRTYPE.LINEAR || dbgAddr.sel == null)? (ch + str.toHex(dbgAddr.addr)) : (ch + this.toHexOffset(dbgAddr.off, dbgAddr.sel, dbgAddr.fAddr32)); }; /** @@ -2880,40 +2883,6 @@ if (DEBUGGER) { this.dumpBlocks(this.cpu.aMemBlocks, asArgs[0], this.cpu.aMemBlocks !== this.cpu.aBusBlocks); }; - /** - * dumpInfo(asArgs) - * - * @this {Debugger} - * @param {Array.} asArgs - */ - Debugger.prototype.dumpInfo = function(asArgs) - { - var sInfo = "no information"; - if (BACKTRACK) { - var sAddr = asArgs[0]; - var dbgAddr = this.parseAddr(sAddr, true, true, false); - if (dbgAddr) { - var addr = this.getAddr(dbgAddr); - sInfo = '%' + str.toHex(addr) + ": " + (this.bus.getSymbol(addr, true) || sInfo); - } else { - var component, componentPrev = null; - while (component = this.cmp.getMachineComponent("Disk", componentPrev)) { - var aInfo = component.getSymbolInfo(sAddr); - if (aInfo.length) { - sInfo = ""; - for (var i in aInfo) { - var a = aInfo[i]; - if (sInfo) sInfo += '\n'; - sInfo += a[0] + ": " + a[1] + ' ' + str.toHex(a[2], 4) + ':' + str.toHex(a[3], 4) + " len " + str.toHexWord(a[4]); - } - } - componentPrev = component; - } - } - } - return sInfo; - }; - /** * getPageEntry(addrPE, lPE, fPTE) * @@ -2934,6 +2903,77 @@ if (DEBUGGER) { return s; }; + /** + * getPageInfo(addr) + * + * @this {Debugger} + * @param {number} addr + * @return {Object|null} + */ + Debugger.prototype.getPageInfo = function(addr) + { + var pageInfo = null; + if (I386 && this.cpu.model >= X86.MODEL_80386) { + var bus = this.bus; + /* + * Here begins code remarkably similar to mapPageBlock() (with fSuppress set). + */ + pageInfo = {}; + pageInfo.offPDE = (addr & X86.LADDR.PDE.MASK) >>> X86.LADDR.PDE.SHIFT; + pageInfo.addrPDE = this.cpu.regCR3 + pageInfo.offPDE; + pageInfo.blockPDE = bus.aMemBlocks[(pageInfo.addrPDE & bus.nBusMask) >>> bus.nBlockShift]; + pageInfo.lPDE = pageInfo.blockPDE.readLong(pageInfo.offPDE); + pageInfo.offPTE = (addr & X86.LADDR.PTE.MASK) >>> X86.LADDR.PTE.SHIFT; + pageInfo.addrPTE = (pageInfo.lPDE & X86.PTE.FRAME) + pageInfo.offPTE; + pageInfo.blockPTE = bus.aMemBlocks[(pageInfo.addrPTE & bus.nBusMask) >>> bus.nBlockShift]; + pageInfo.lPTE = pageInfo.blockPTE.readLong(pageInfo.offPTE); + pageInfo.addrPhys = (pageInfo.lPTE & X86.PTE.FRAME) + (addr & X86.LADDR.OFFSET); + //var blockPhys = bus.aMemBlocks[(addrPhys & bus.nBusMask) >>> bus.nBlockShift]; + } + return pageInfo; + }; + + /** + * dumpInfo(asArgs) + * + * @this {Debugger} + * @param {Array.} asArgs + */ + Debugger.prototype.dumpInfo = function(asArgs) + { + var sInfo = "no information"; + if (BACKTRACK) { + var sAddr = asArgs[0]; + var dbgAddr = this.parseAddr(sAddr, true, true, false); + if (dbgAddr) { + var addr = this.getAddr(dbgAddr); + if (dbgAddr.type != Debugger.ADDRTYPE.PHYSICAL) { + var pageInfo = this.getPageInfo(addr); + if (pageInfo) { + dbgAddr.addr = pageInfo.addrPhys; + dbgAddr.type = Debugger.ADDRTYPE.PHYSICAL; + } + } + sInfo = this.toHexAddr(dbgAddr) + ": " + (this.bus.getSymbol(addr, true) || sInfo); + } else { + var component, componentPrev = null; + while (component = this.cmp.getMachineComponent("Disk", componentPrev)) { + var aInfo = component.getSymbolInfo(sAddr); + if (aInfo.length) { + sInfo = ""; + for (var i in aInfo) { + var a = aInfo[i]; + if (sInfo) sInfo += '\n'; + sInfo += a[0] + ": " + a[1] + ' ' + str.toHex(a[2], 4) + ':' + str.toHex(a[3], 4) + " len " + str.toHexWord(a[4]); + } + } + componentPrev = component; + } + } + } + return sInfo; + }; + /** * dumpPage(asArgs) * @@ -2956,30 +2996,18 @@ if (DEBUGGER) { return; } - /* - * Here begins the code that is remarkably similar to mapPageBlock(), with fSuppress set. - */ - var bus = this.bus; - var offPDE = (addr & X86.LADDR.PDE.MASK) >>> X86.LADDR.PDE.SHIFT; - var addrPDE = this.cpu.regCR3 + offPDE; - var blockPDE = bus.aMemBlocks[(addrPDE & bus.nBusMask) >>> bus.nBlockShift]; - var lPDE = blockPDE.readLong(offPDE); - var offPTE = (addr & X86.LADDR.PTE.MASK) >>> X86.LADDR.PTE.SHIFT; - var addrPTE = (lPDE & X86.PTE.FRAME) + offPTE; - var blockPTE = bus.aMemBlocks[(addrPTE & bus.nBusMask) >>> bus.nBlockShift]; - var lPTE = blockPTE.readLong(offPTE); - var addrPhys = (lPTE & X86.PTE.FRAME) + (addr & X86.LADDR.OFFSET); - //var blockPhys = bus.aMemBlocks[(addrPhys & bus.nBusMask) >>> bus.nBlockShift]; - /* - * And here ends the code that is remarkably similar to mapPageBlock(), with fSuppress set. - */ + var pageInfo = this.getPageInfo(addr); + if (!pageInfo) { + this.println("unsupported operation"); + return; + } this.println("linear PDE addr PDE PTE addr PTE physical" ); this.println("--------- ---------- -------- ---------- -------- ----------"); var s = '%' + str.toHex(addr); - s += " %%" + this.getPageEntry(addrPDE, lPDE); - s += " %%" + this.getPageEntry(addrPTE, lPTE, true); - s += " %%" + str.toHex(addrPhys); + s += " %%" + this.getPageEntry(pageInfo.addrPDE, pageInfo.lPDE); + s += " %%" + this.getPageEntry(pageInfo.addrPTE, pageInfo.lPTE, true); + s += " %%" + str.toHex(pageInfo.addrPhys); this.println(s); }; diff --git a/modules/pcjs/lib/defines.js b/modules/pcjs/lib/defines.js index 91df7f9f6..587877cf3 100644 --- a/modules/pcjs/lib/defines.js +++ b/modules/pcjs/lib/defines.js @@ -93,7 +93,7 @@ var TYPEDARRAYS = (typeof ArrayBuffer !== 'undefined'); * TODO: BACKTRACK support is currently completely disabled until we have a chance to investigate the problem * discussed in Bus.addBackTrackObject(). */ -var BACKTRACK = false; +var BACKTRACK = !COMPILED; /** * @define {boolean} diff --git a/modules/pcjs/lib/disk.js b/modules/pcjs/lib/disk.js index 465ad3523..402784176 100644 --- a/modules/pcjs/lib/disk.js +++ b/modules/pcjs/lib/disk.js @@ -471,14 +471,18 @@ FileInfo.prototype.loadSegmentTable = function(offEntries, nEntries, nSegOffShif this.aSegments = []; this.aOrdinals = []; // this is an optional array for quick ordinal-to-segment lookup - if (MAXDEBUG) this.disk.println("loadSegmentTable(" + this.sPath + "," + str.toHexLong(offEntries) + "," + str.toHexWord(nEntries) + ")"); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("loadSegmentTable(" + this.sPath + "," + str.toHexLong(offEntries) + "," + str.toHexWord(nEntries) + ")"); + } while (nEntries--) { var offSegment = this.loadValue(offEntries) << nSegOffShift; if (offSegment) { var lenSegment = this.loadValue(offEntries + 2) || 0x10000; // 0 means 64K - if (MAXDEBUG) this.disk.println("segment " + iSegment + ": offStart=" + str.toHexLong(offSegment) + " offEnd=" + str.toHexLong(offSegment + lenSegment)); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("segment " + iSegment + ": offStart=" + str.toHexLong(offSegment) + " offEnd=" + str.toHexLong(offSegment + lenSegment)); + } this.aSegments[iSegment++] = {offStart: offSegment, offEnd: offSegment + lenSegment - 1, aEntries: []}; } @@ -520,7 +524,9 @@ FileInfo.prototype.loadEntryTable = function(offEntries, offEntriesEnd) { var iOrdinal = 1; - if (MAXDEBUG) this.disk.println("loadEntryTable(" + str.toHexLong(offEntries) + "," + str.toHexLong(offEntriesEnd) + ")"); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("loadEntryTable(" + str.toHexLong(offEntries) + "," + str.toHexLong(offEntriesEnd) + ")"); + } while (offEntries < offEntriesEnd) { @@ -529,7 +535,9 @@ FileInfo.prototype.loadEntryTable = function(offEntries, offEntriesEnd) if (!bEntries) break; var bSegment = w >> 8, iSegment; - if (MAXDEBUG) this.disk.println("bundle for segment " + bSegment + ": " + bEntries + " entries @" + str.toHex(offEntries)); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("bundle for segment " + bSegment + ": " + bEntries + " entries @" + str.toHex(offEntries)); + } offEntries += 2; @@ -564,10 +572,14 @@ FileInfo.prototype.loadEntryTable = function(offEntries, offEntriesEnd) offEntries += 6; } if (!this.aSegments[iSegment]) { - if (MAXDEBUG) this.disk.println("invalid segment: " + iSegment); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("invalid segment: " + iSegment); + } } else { this.aSegments[iSegment].aEntries[iOrdinal] = [offEntry]; - if (MAXDEBUG) this.disk.println("ordinal " + iOrdinal + ": segment=" + iSegment + " offset=" + str.toHexLong(offEntry) + " @" + str.toHex(offDebug)); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("ordinal " + iOrdinal + ": segment=" + iSegment + " offset=" + str.toHexLong(offEntry) + " @" + str.toHex(offDebug)); + } } this.aOrdinals[iOrdinal] = [iSegment, offEntry]; iOrdinal++; @@ -590,7 +602,9 @@ FileInfo.prototype.loadNameTable = function(offEntries, offEntriesEnd) { var cNames = 0; - if (MAXDEBUG) this.disk.println("loadNameTable(" + str.toHexLong(offEntries) + (offEntriesEnd? ("," + str.toHexLong(offEntriesEnd)) : "") + ")"); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("loadNameTable(" + str.toHexLong(offEntries) + (offEntriesEnd? ("," + str.toHexLong(offEntriesEnd)) : "") + ")"); + } while (!offEntriesEnd || offEntries < offEntriesEnd) { @@ -618,12 +632,18 @@ FileInfo.prototype.loadNameTable = function(offEntries, offEntriesEnd) var aEntries = this.aSegments[iSegment].aEntries[iOrdinal]; this.disk.assert(aEntries && aEntries.length == 1); aEntries.push(sSymbol); - if (MAXDEBUG) this.disk.println("segment " + iSegment + " offset " + str.toHexWord(aEntries[0]) + " ordinal " + iOrdinal + ": " + sSymbol + " @" + str.toHex(offDebug)); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage("segment " + iSegment + " offset " + str.toHexWord(aEntries[0]) + " ordinal " + iOrdinal + ": " + sSymbol + " @" + str.toHex(offDebug)); + } } else { - if (MAXDEBUG) this.disk.println(this.sPath + ": cannot find segment " + iSegment + " (offset " + str.toHexWord(tuple[1]) + ") for symbol " + sSymbol + " with ordinal " + iOrdinal + " @" + str.toHex(offDebug)); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage(this.sPath + ": cannot find segment " + iSegment + " (offset " + str.toHexWord(tuple[1]) + ") for symbol " + sSymbol + " with ordinal " + iOrdinal + " @" + str.toHex(offDebug)); + } } } else { - if (MAXDEBUG) this.disk.println(this.sPath + ": cannot find ordinal " + iOrdinal + " for symbol " + sSymbol + " @" + str.toHex(offDebug)); + if (DEBUG && this.disk.messageEnabled(Messages.DISK | Messages.DATA)) { + this.disk.printMessage(this.sPath + ": cannot find ordinal " + iOrdinal + " for symbol " + sSymbol + " @" + str.toHex(offDebug)); + } } } offEntries += 2; @@ -1268,7 +1288,7 @@ Disk.prototype.doneLoad = function(sURL, sDiskData, nErrorCode) * conversion to a forward-compatible 'data' array. */ else { - if (MAXDEBUG && this.messageEnabled()) { + if (DEBUG && this.messageEnabled(Messages.DISK | Messages.DATA)) { var sCylinders = aDiskData.length + " track" + (aDiskData.length > 1 ? "s" : ""); var nHeads = aDiskData[0].length; var sHeads = nHeads + " head" + (nHeads > 1 ? "s" : ""); diff --git a/modules/pcjs/lib/x86cpu.js b/modules/pcjs/lib/x86cpu.js index 3059a0532..a3fa348d7 100644 --- a/modules/pcjs/lib/x86cpu.js +++ b/modules/pcjs/lib/x86cpu.js @@ -475,7 +475,7 @@ X86CPU.prototype.enablePageBlocks = function() X86CPU.prototype.flushPageBlocks = function() { if (this.regCR0 & X86.CR0.PG) this.enablePageBlocks(); -} +}; /** * acquirePageBlock(addr)