Removed old traceLog() support (being replaced by tests in /tests/pc that dump results to a COM port)

This commit is contained in:
Jeff Parsons 2015-10-21 13:40:43 -07:00
commit 645241b634
3 changed files with 5 additions and 268 deletions

View file

@ -213,16 +213,6 @@ function Debugger(parmsDbg)
*/
this.messageInit(parmsDbg['messages']);
/*
* The instruction trace buffer is a lightweight logging mechanism with minimal impact
* on the browser (unlike printing to either console.log or an HTML control, which can
* make the browser unusable if printing is too frequent). The Debugger's info command
* ("n dump [#]") dumps this buffer. Note that dumping too much at once can also bog
* things down, but by that point, you've presumably already captured the info you need
* and are willing to wait.
*/
if (DEBUG) this.traceInit();
this.sInitCommands = parmsDbg['commands'];
/*
@ -614,39 +604,6 @@ if (DEBUGGER) {
"halt": Messages.HALT
};
/*
* Instruction trace categories supported by the traceLog() function. The Debugger's info
* command ("n") is used to turn trace categories on and off, like so:
*
* n shl on
* n shl off
* ...
*
* Note that there are usually multiple entries for each category (one for each supported operand size);
* all matching entries are enabled or disabled as a group.
*/
Debugger.TRACE = {
ROLB: {ins: Debugger.INS.ROL, size: 8},
ROLW: {ins: Debugger.INS.ROL, size: 16},
RORB: {ins: Debugger.INS.ROR, size: 8},
RORW: {ins: Debugger.INS.ROR, size: 16},
RCLB: {ins: Debugger.INS.RCL, size: 8},
RCLW: {ins: Debugger.INS.RCL, size: 16},
RCRB: {ins: Debugger.INS.RCR, size: 8},
RCRW: {ins: Debugger.INS.RCR, size: 16},
SHLB: {ins: Debugger.INS.SHL, size: 8},
SHLW: {ins: Debugger.INS.SHL, size: 16},
MULB: {ins: Debugger.INS.MUL, size: 16}, // dst is 8-bit (AL), src is 8-bit (operand), result is 16-bit (AH:AL)
IMULB: {ins: Debugger.INS.IMUL, size: 16}, // dst is 8-bit (AL), src is 8-bit (operand), result is 16-bit (AH:AL)
DIVB: {ins: Debugger.INS.DIV, size: 16}, // dst is 16-bit (AX), src is 8-bit (operand), result is 16-bit (AH:AL, remainder:quotient)
IDIVB: {ins: Debugger.INS.IDIV, size: 16}, // dst is 16-bit (AX), src is 8-bit (operand), result is 16-bit (AH:AL, remainder:quotient)
MULW: {ins: Debugger.INS.MUL, size: 32}, // dst is 16-bit (AX), src is 16-bit (operand), result is 32-bit (DX:AX)
IMULW: {ins: Debugger.INS.IMUL, size: 32}, // dst is 16-bit (AX), src is 16-bit (operand), result is 32-bit (DX:AX)
DIVW: {ins: Debugger.INS.DIV, size: 32}, // dst is 32-bit (DX:AX), src is 16-bit (operand), result is 32-bit (DX:AX, remainder:quotient)
IDIVW: {ins: Debugger.INS.IDIV, size: 32} // dst is 32-bit (DX:AX), src is 16-bit (operand), result is 32-bit (DX:AX, remainder:quotient)
};
Debugger.TRACE_LIMIT = 100000;
Debugger.HISTORY_LIMIT = DEBUG? 100000 : 1000;
/*
@ -3545,59 +3502,6 @@ if (DEBUGGER) {
}
};
/**
* traceInit()
*
* @this {Debugger}
*/
Debugger.prototype.traceInit = function()
{
if (DEBUG) {
this.traceEnabled = {};
for (var prop in Debugger.TRACE) {
this.traceEnabled[prop] = false;
}
this.iTraceBuffer = 0;
this.aTraceBuffer = []; // we now defer TRACE_LIMIT allocation until the first traceLog() call
}
};
/**
* traceLog(prop, dst, src, flagsIn, flagsOut, resultLo, resultHi)
*
* @this {Debugger}
* @param {string} prop
* @param {number} dst
* @param {number} src
* @param {number|null} flagsIn
* @param {number|null} flagsOut
* @param {number} resultLo
* @param {number} [resultHi]
*/
Debugger.prototype.traceLog = function(prop, dst, src, flagsIn, flagsOut, resultLo, resultHi)
{
if (DEBUG) {
if (this.traceEnabled !== undefined && this.traceEnabled[prop]) {
var trace = Debugger.TRACE[prop];
var len = (trace.size >> 2);
var s = this.toHexOffset(this.cpu.opLIP - this.cpu.segCS.base, this.cpu.getCS()) + ' ' + Debugger.INS_NAMES[trace.ins] + '(' + str.toHex(dst, len) + ',' + str.toHex(src, len) + ',' + (flagsIn === null? '-' : str.toHexWord(flagsIn)) + ") " + str.toHex(resultLo, len) + ',' + (flagsOut === null? '-' : str.toHexWord(flagsOut));
if (!this.aTraceBuffer.length) this.aTraceBuffer = new Array(Debugger.TRACE_LIMIT);
this.aTraceBuffer[this.iTraceBuffer++] = s;
if (this.iTraceBuffer >= this.aTraceBuffer.length) {
/*
* Instead of wrapping the buffer, we're going to turn all tracing off.
*
* this.iTraceBuffer = 0;
*/
for (prop in this.traceEnabled) {
this.traceEnabled[prop] = false;
}
this.println("trace buffer full");
}
}
}
};
/**
* init()
*
@ -6306,15 +6210,6 @@ if (DEBUGGER) {
/**
* doInfo(asArgs)
*
* Prints the contents of the Debugger's instruction trace buffer.
*
* Examples:
*
* n shl
* n shl on
* n shl off
* n dump 100
*
* @this {Debugger}
* @param {Array.<string>} asArgs
* @return {boolean} true only if the instruction info command ("n") is supported
@ -6322,51 +6217,11 @@ if (DEBUGGER) {
Debugger.prototype.doInfo = function(asArgs)
{
if (DEBUG) {
var sCategory = asArgs[1];
if (sCategory !== undefined) {
sCategory = sCategory.toUpperCase();
}
var sEnable = asArgs[2];
var fPrint = false;
if (sCategory == "DUMP") {
var sDump = "";
var cLines = (sEnable === undefined? -1 : +sEnable); // warning: decimal instead of hex conversion
var i = this.iTraceBuffer;
do {
var s = this.aTraceBuffer[i++];
if (s !== undefined) {
/*
* The browser is MUCH happier if we buffer all the lines for one single enormous print
*
* this.println(s);
*/
sDump += (sDump? '\n' : "") + s;
cLines--;
}
if (i >= this.aTraceBuffer.length)
i = 0;
} while (cLines && i != this.iTraceBuffer);
if (!sDump) sDump = "nothing to dump";
this.println(sDump);
this.println("msPerYield: " + this.cpu.aCounts.msPerYield);
this.println("nCyclesPerBurst: " + this.cpu.aCounts.nCyclesPerBurst);
this.println("nCyclesPerYield: " + this.cpu.aCounts.nCyclesPerYield);
this.println("nCyclesPerVideoUpdate: " + this.cpu.aCounts.nCyclesPerVideoUpdate);
this.println("nCyclesPerStatusUpdate: " + this.cpu.aCounts.nCyclesPerStatusUpdate);
} else {
var fEnable = (sEnable == "on");
for (var prop in this.traceEnabled) {
var trace = Debugger.TRACE[prop];
if (sCategory === undefined || sCategory == "ALL" || sCategory == Debugger.INS_NAMES[trace.ins]) {
if (fEnable !== undefined) {
this.traceEnabled[prop] = fEnable;
}
this.println(Debugger.INS_NAMES[trace.ins] + trace.size + ": " + (this.traceEnabled[prop]? "on" : "off"));
fPrint = true;
}
}
if (!fPrint) this.println("no match");
}
this.println("msPerYield: " + this.cpu.aCounts.msPerYield);
this.println("nCyclesPerBurst: " + this.cpu.aCounts.nCyclesPerBurst);
this.println("nCyclesPerYield: " + this.cpu.aCounts.nCyclesPerYield);
this.println("nCyclesPerVideoUpdate: " + this.cpu.aCounts.nCyclesPerVideoUpdate);
this.println("nCyclesPerStatusUpdate: " + this.cpu.aCounts.nCyclesPerStatusUpdate);
return true;
}
return false;

View file

@ -3136,25 +3136,6 @@ X86CPU.prototype.checkIOPM = function(port, nPorts, fInput)
return true;
};
/**
* traceLog(prop, dst, src, flagsIn, flagsOut, resultLo, resultHi)
*
* @this {X86CPU}
* @param {string} prop
* @param {number} dst
* @param {number} src
* @param {number|null} flagsIn
* @param {number|null} flagsOut
* @param {number} resultLo
* @param {number} [resultHi]
*/
X86CPU.prototype.traceLog = function(prop, dst, src, flagsIn, flagsOut, resultLo, resultHi)
{
if (DEBUG && this.dbg) {
this.dbg.traceLog(prop, dst, src, flagsIn, flagsOut, resultLo, resultHi);
}
};
/**
* setBinding(sHTMLType, sBinding, control)
*

View file

@ -871,13 +871,6 @@ X86.fnDIVb = function(dst, src)
this.fMDSet = true;
this.regMDLo = (result & 0xff) | (((src % dst) & 0xff) << 8);
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) this.traceLog('DIVb', src, dst, null, this.getPS(), this.regMDLo);
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesDivBR : this.cycleCounts.nOpCyclesDivBM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -928,19 +921,6 @@ X86.fnDIVw = function(dst, src)
this.regMDHi |= 0;
}
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) {
if (this.sizeData == 2) {
this.traceLog('DIVw', src, dst, null, this.getPS(), this.regMDLo | (this.regMDHi << 16));
} else {
this.traceLog('DIVd', src, dst, null, this.getPS(), this.regMDLo, this.regMDHi);
}
}
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesDivWR : this.cycleCounts.nOpCyclesDivWM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -1000,13 +980,6 @@ X86.fnIDIVb = function(dst, src)
this.fMDSet = true;
this.regMDLo = (result & 0xff) | (((src % div) & 0xff) << 8);
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) this.traceLog('IDIVb', src, dst, null, this.getPS(), this.regMDLo);
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesIDivBR : this.cycleCounts.nOpCyclesIDivBM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -1065,19 +1038,6 @@ X86.fnIDIVw = function(dst, src)
this.regMDHi |= 0;
}
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) {
if (this.sizeData == 2) {
this.traceLog('IDIVw', src, dst, null, this.getPS(), this.regMDLo | (this.regMDHi << 16));
} else {
this.traceLog('IDIVd', src, dst, null, this.getPS(), this.regMDLo, this.regMDHi);
}
}
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesIDivWR : this.cycleCounts.nOpCyclesIDivWM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -1112,7 +1072,6 @@ X86.fnIMUL8 = function(dst, src)
}
result &= 0xffff;
if (DEBUG && DEBUGGER) this.traceLog('IMUL8', dst, src, null, this.getPS(), result);
/*
* NOTE: These are the cycle counts for the 80286; the 80186/80188 have slightly different values (ranges):
@ -1154,14 +1113,6 @@ X86.fnIMULb = function(dst, src)
this.clearCF(); this.clearOF();
}
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) this.traceLog('IMULb', src, dst, null, this.getPS(), this.regMDLo);
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesIMulBR : this.cycleCounts.nOpCyclesIMulBM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -1205,7 +1156,6 @@ X86.fnIMULn = function(dst, src)
}
result &= this.maskData;
if (DEBUG && DEBUGGER) this.traceLog('IMULn', dst, src, null, this.getPS(), result);
/*
* NOTE: These are the cycle counts for the 80286; the 80186/80188 have slightly different values (ranges):
@ -1284,19 +1234,6 @@ X86.fnIMULw = function(dst, src)
this.clearCF(); this.clearOF();
}
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) {
if (this.sizeData == 2) {
this.traceLog('IMULw', src, dst, null, this.getPS(), this.regMDLo | (this.regMDHi << 16));
} else {
this.traceLog('IMULd', src, dst, null, this.getPS(), this.regMDLo, this.regMDHi);
}
}
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesIMulWR : this.cycleCounts.nOpCyclesIMulWM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -2047,14 +1984,6 @@ X86.fnMULb = function(dst, src)
this.clearCF(); this.clearOF();
}
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) this.traceLog('MULb', src, dst, null, this.getPS(), this.regMDLo);
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesMulBR : this.cycleCounts.nOpCyclesMulBM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -2122,19 +2051,6 @@ X86.fnMULw = function(dst, src)
this.clearCF(); this.clearOF();
}
/*
* Multiply/divide instructions specify only a single operand, which the decoders pass to us
* via the dst parameter, so we set src to the other implied operand (either AX or DX:AX).
* However, src is technically an output, and dst is merely an input (which is why we must return
* dst unchanged). So, to make traceLog() more consistent, we reverse the order of dst and src.
*/
if (DEBUG && DEBUGGER) {
if (this.sizeData == 2) {
this.traceLog('MULw', src, dst, null, this.getPS(), this.regMDLo | (this.regMDHi << 16));
} else {
this.traceLog('MULd', src, dst, null, this.getPS(), this.regMDLo, this.regMDHi);
}
}
this.nStepCycles -= (this.regEA === X86.ADDR_INVALID? this.cycleCounts.nOpCyclesMulWR : this.cycleCounts.nOpCyclesMulWM);
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -2298,7 +2214,6 @@ X86.fnRCLb = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.BYTE);
}
if (DEBUG && DEBUGGER) this.traceLog('RCLb', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2326,7 +2241,6 @@ X86.fnRCLw = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.WORD);
}
if (DEBUG && DEBUGGER) this.traceLog('RCLw', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2354,7 +2268,6 @@ X86.fnRCLd = function(dst, src)
carry = dst << (count - 1);
this.setRotateResult(result, carry, X86.RESULT.DWORD);
}
if (DEBUG && DEBUGGER) this.traceLog('RCLd', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2382,7 +2295,6 @@ X86.fnRCRb = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.BYTE);
}
if (DEBUG && DEBUGGER) this.traceLog('RCRb', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2410,7 +2322,6 @@ X86.fnRCRw = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.WORD);
}
if (DEBUG && DEBUGGER) this.traceLog('RCRw', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2438,7 +2349,6 @@ X86.fnRCRd = function(dst, src)
carry = dst << (32 - count);
this.setRotateResult(result, carry, X86.RESULT.DWORD);
}
if (DEBUG && DEBUGGER) this.traceLog('RCRd', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2520,7 +2430,6 @@ X86.fnROLb = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.BYTE);
}
if (DEBUG && DEBUGGER) this.traceLog('ROLb', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2548,7 +2457,6 @@ X86.fnROLw = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.WORD);
}
if (DEBUG && DEBUGGER) this.traceLog('ROLw', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2570,7 +2478,6 @@ X86.fnROLd = function(dst, src)
result = (dst << count) | (dst >>> (32 - count));
this.setRotateResult(result, carry, X86.RESULT.DWORD);
}
if (DEBUG && DEBUGGER) this.traceLog('ROLd', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2598,7 +2505,6 @@ X86.fnRORb = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.BYTE);
}
if (DEBUG && DEBUGGER) this.traceLog('RORb', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2626,7 +2532,6 @@ X86.fnRORw = function(dst, src)
}
this.setRotateResult(result, carry, X86.RESULT.WORD);
}
if (DEBUG && DEBUGGER) this.traceLog('RORw', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -2648,7 +2553,6 @@ X86.fnRORd = function(dst, src)
result = (dst >>> count) | carry;
this.setRotateResult(result, carry, X86.RESULT.DWORD);
}
if (DEBUG && DEBUGGER) this.traceLog('RORd', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -3063,7 +2967,6 @@ X86.fnSHLb = function(dst, src)
}
this.setLogicResult(result, X86.RESULT.BYTE, carry & X86.RESULT.BYTE, (result ^ carry) & X86.RESULT.BYTE);
}
if (DEBUG && DEBUGGER) this.traceLog('SHLb', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -3090,7 +2993,6 @@ X86.fnSHLw = function(dst, src)
}
this.setLogicResult(result, X86.RESULT.WORD, carry & X86.RESULT.WORD, (result ^ carry) & X86.RESULT.WORD);
}
if (DEBUG && DEBUGGER) this.traceLog('SHLw', dst, src, flagsIn, this.getPS(), result);
return result;
};
@ -3112,7 +3014,6 @@ X86.fnSHLd = function(dst, src)
result = (carry << 1);
this.setLogicResult(result, X86.RESULT.DWORD, carry & X86.RESULT.DWORD, (result ^ carry) & X86.RESULT.DWORD);
}
if (DEBUG && DEBUGGER) this.traceLog('SHLd', dst, src, flagsIn, this.getPS(), result);
return result;
};