From f822efe1f0fb1bbcc8feee44772cd00d4e72490f Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Thu, 30 Apr 2015 14:08:10 -0700 Subject: [PATCH] TBD function no longer needed --- modules/pcjs/lib/cpu.js | 2 +- modules/pcjs/lib/debugger.js | 24 +++++++++++------------- modules/pcjs/lib/x86func.js | 16 ---------------- modules/shared/lib/component.js | 24 +++++++++++------------- 4 files changed, 23 insertions(+), 43 deletions(-) diff --git a/modules/pcjs/lib/cpu.js b/modules/pcjs/lib/cpu.js index bfa765a92..5f54de85f 100644 --- a/modules/pcjs/lib/cpu.js +++ b/modules/pcjs/lib/cpu.js @@ -1031,7 +1031,7 @@ CPU.prototype.runCPU = function(fOnClick) this.updateCPU(); if (this.cmp) this.cmp.stop(usr.getTime(), this.getCycles()); this.setBusy(false); - this.setError(e.message); + this.setError(e.stack || e.message); return; } setTimeout(this.onRunTimeout, this.calcRemainingTime()); diff --git a/modules/pcjs/lib/debugger.js b/modules/pcjs/lib/debugger.js index 11794e2c4..0fb17ee62 100644 --- a/modules/pcjs/lib/debugger.js +++ b/modules/pcjs/lib/debugger.js @@ -1873,7 +1873,7 @@ if (DEBUGGER) { if (this.cpu) { if (this.bitsMessage & Messages.HALT) { - this.cpu.stopCPU(); + this.stopCPU(); } /* * We have no idea what the frequency of println() calls might be; all we know is that they easily @@ -2121,7 +2121,7 @@ if (DEBUGGER) { } catch (e) { this.nCycles = 0; - this.cpu.setError(e.message || e); + this.cpu.setError(e.stack || e.message); } } while (this.cpu.opFlags & X86.OPFLAG_PREFIXES); @@ -2137,16 +2137,14 @@ if (DEBUGGER) { }; /** - * stopCPU(s) + * stopCPU() * * @this {Debugger} - * @param {string} [s] - * @param {boolean} [fBlockFaults] + * @param {boolean} [fComplete] */ - Debugger.prototype.stopCPU = function(s, fBlockFaults) + Debugger.prototype.stopCPU = function(fComplete) { - if (s) this.println(s); - if (this.cpu) this.cpu.stopCPU(!fBlockFaults); + if (this.cpu) this.cpu.stopCPU(fComplete); }; /** @@ -2461,7 +2459,7 @@ if (DEBUGGER) { Debugger.prototype.checkMemoryRead = function(addr) { if (this.checkBreakpoint(addr, this.aBreakRead)) { - this.cpu.stopCPU(true); + this.stopCPU(true); return true; } return false; @@ -2480,7 +2478,7 @@ if (DEBUGGER) { Debugger.prototype.checkMemoryWrite = function(addr) { if (this.checkBreakpoint(addr, this.aBreakWrite)) { - this.cpu.stopCPU(true); + this.stopCPU(true); return true; } return false; @@ -2502,7 +2500,7 @@ if (DEBUGGER) { * We trust that the Bus component won't call us unless we told it to, so we halt unconditionally */ this.println("break on input from port " + str.toHexWord(port) + ": " + str.toHexByte(bIn)); - this.cpu.stopCPU(true); + this.stopCPU(true); return true; }; @@ -2522,7 +2520,7 @@ if (DEBUGGER) { * We trust that the Bus component won't call us unless we told it to, so we halt unconditionally */ this.println("break on output to port " + str.toHexWord(port) + ": " + str.toHexByte(bOut)); - this.cpu.stopCPU(true); + this.stopCPU(true); return true; }; @@ -4204,7 +4202,7 @@ if (DEBUGGER) { { if (this.aFlags.fRunning && sCount === undefined) { this.println("halting"); - this.cpu.stopCPU(); + this.stopCPU(); return; } var sMore = ""; diff --git a/modules/pcjs/lib/x86func.js b/modules/pcjs/lib/x86func.js index ba9f53608..55864e48e 100644 --- a/modules/pcjs/lib/x86func.js +++ b/modules/pcjs/lib/x86func.js @@ -3379,22 +3379,6 @@ X86.fnXORw = function XORw(dst, src) return this.setLogicResult(dst ^ src, this.dataType); }; -/** - * fnTBD(dst, src) - * - * @this {X86CPU} - * @param {number} dst - * @param {number} src - * @return {number} - */ -X86.fnTBD = function TBD(dst, src) -{ - this.setIP(this.opLIP - this.segCS.base); - this.printMessage("unimplemented 80386 opcode", true); - this.stopCPU(); - return dst; -}; - /** * fnGRPFault(dst, src) * diff --git a/modules/shared/lib/component.js b/modules/shared/lib/component.js index 87528e7aa..dad575bca 100644 --- a/modules/shared/lib/component.js +++ b/modules/shared/lib/component.js @@ -261,7 +261,7 @@ Component.log = function(s, type) * * The Closure Compiler should automatically remove all references to Component.assert() in non-DEBUG builds. * - * TODO: Add a task to the build process that "asserts" there are no occurrences of "assertion failure" in the final code. + * TODO: Add a task to the build process that "asserts" there are no instances of "assertion failure" in RELEASE builds. * * @param {boolean} f is the expression we are asserting to be true * @param {string} [s] is description of the assertion on failure @@ -270,9 +270,6 @@ Component.assert = function(f, s) { if (DEBUG) { if (!f) { - /* - * TODO: An accompanying source file/line number/function call (eg, stack trace) would be nice. - */ if (!s) s = "assertion failure"; Component.log(s); throw new Error(s); @@ -705,7 +702,7 @@ Component.prototype = { * the Closure Compiler can't be sure that this instance method hasn't been overridden, so it refuses to treat it as * dead code in non-DEBUG builds. * - * TODO: Add a task to the build process that "asserts" there are no occurrences of "assertion failure" in the final code. + * TODO: Add a task to the build process that "asserts" there are no instances of "assertion failure" in RELEASE builds. * * @param {boolean} f is the expression we are asserting to be true * @param {string} [s] is description of the assertion on failure @@ -713,28 +710,29 @@ Component.prototype = { assert: function(f, s) { if (DEBUG) { if (!f) { - /* - * TODO: An accompanying source file/line number/function call (eg, stack trace) would be nice. - */ s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : ""); if (DEBUGGER && this.dbg) { - this.dbg.stopCPU(s, true); + this.dbg.stopCPU(); /* * Why do we throw an Error only to immediately catch and ignore it? Simply to give * any IDE the opportunity to inspect the application's state. Even when the IDE has * control, you should still be able to invoke Debugger commands from the IDE's REPL, - * using the '$' global function that the Debugger constructor sets up; eg: + * using the '$' global function that the Debugger constructor defines; eg: * * $('r') * $('dw 0:0') * $('h') * ... * - * If you have no desire to stop on assertions, consider this a no-op. + * If you have no desire to stop on assertions, consider this a no-op. However, another + * potential benefit of creating an Error object is that, for browsers like Chrome, we get + * a stack trace, too. */ try { throw new Error(s); - } catch(e) {} + } catch(e) { + this.println(e.stack || e.message); + } return; } this.log(s); @@ -794,7 +792,7 @@ Component.prototype = { */ setError: function(s) { this.aFlags.fError = true; - this.notice("Fatal error: " + s); + this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "? }, /** * clearError()