Improved debugger messages for bus and memory accesses

This commit is contained in:
Jeff 2016-10-04 10:45:18 -07:00 committed by Jeff Parsons
commit 7923529aee
7 changed files with 457 additions and 391 deletions

View file

@ -187,30 +187,38 @@ BusPDP11.IOController = {
*/
readByte: function(off, addr)
{
var b = -1;
var bus = this.controller;
var afn = bus.aIOHandlers[off];
if (afn) {
if (bus.messageEnabled()) bus.printMessage(afn[5] + ".readByte(" + str.toOct(addr) + ")", 0, true);
if (afn[0]) {
return afn[0](addr);
b = afn[0](addr);
} else if (afn[2]) {
if (!(addr & 0x1)) {
return afn[2](addr) & 0xff;
b = afn[2](addr) & 0xff;
} else {
return afn[2](addr & ~0x1) >> 8;
b = afn[2](addr & ~0x1) >> 8;
}
}
} else if (addr & 0x1) {
afn = bus.aIOHandlers[off & ~0x1];
if (afn) {
if (bus.messageEnabled()) bus.printMessage(afn[5] + ".readByte(" + str.toOct(addr) + ")", 0, true);
if (afn[2]) {
return afn[2](addr & ~0x1) >> 8;
b = afn[2](addr & ~0x1) >> 8;
}
}
}
bus.println("warning: unconverted read access to byte @" + str.toOct(addr));
return bus.fnAccess(addr, -1, 1);
if (b >= 0) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message(afn[5] + ".readByte(" + this.dbg.toStrBase(addr) + "): " + this.dbg.toStrBase(b), true);
}
return b;
}
b = bus.fnAccess(addr, -1, 1);
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message("warning: unconverted read access to byte @" + this.dbg.toStrBase(addr) + ": " + this.dbg.toStrBase(b));
}
return b;
},
/**
@ -224,29 +232,30 @@ BusPDP11.IOController = {
writeByte: function(off, b, addr)
{
var w;
var fWrite = false;
var bus = this.controller;
var afn = bus.aIOHandlers[off];
if (afn) {
if (bus.messageEnabled()) bus.printMessage(afn[5] + ".writeByte(" + str.toOct(addr) + "," + str.toOct(b) + ")", 0, true);
/*
* If a writeByte() handler exists, call it; we're done
*/
if (afn[1]) {
afn[1](b, addr);
return;
fWrite = true;
}
/*
* If a writeWord() handler exists, call the readWord() handler first to get the original data,
* then call writeWord() with the new data pre-inserted into the original data.
*/
if (afn[3]) {
else if (afn[3]) {
w = afn[2]? afn[2](addr) : 0;
if (!(addr & 0x1)) {
afn[3]((w & ~0xff) | b, addr)
afn[3]((w & ~0xff) | b, addr);
fWrite = true;
} else {
afn[3]((w & 0xff) | (b << 8), addr & ~0x1);
fWrite = true;
}
return;
}
} else if (addr & 0x1) {
/*
@ -256,17 +265,24 @@ BusPDP11.IOController = {
*/
afn = bus.aIOHandlers[off & ~0x1];
if (afn) {
if (bus.messageEnabled()) bus.printMessage(afn[5] + ".writeByte(" + str.toOct(addr) + "," + str.toOct(b) + ")", 0, true);
if (afn[3]) {
addr &= ~0x1;
w = afn[2]? afn[2](addr) : 0;
afn[3]((w & 0xff) | (b << 8), addr);
return;
fWrite = true;
}
}
}
bus.println("warning: unconverted write access to byte @" + str.toOct(addr));
if (fWrite) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message(afn[5] + ".writeByte(" + this.dbg.toStrBase(addr) + "," + this.dbg.toStrBase(b) + ")", true);
}
return;
}
bus.fnAccess(addr, b, 1);
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message("warning: unconverted write access to byte @" + this.dbg.toStrBase(addr) + ": " + this.dbg.toStrBase(b));
}
},
/**
@ -279,19 +295,28 @@ BusPDP11.IOController = {
*/
readWord: function(off, addr)
{
var w = -1;
var bus = this.controller;
Component.assert(!(addr & 1)); // unaligned addresses should be getting trapped at a higher level
var afn = bus.aIOHandlers[off];
if (afn) {
if (bus.messageEnabled()) bus.printMessage(afn[5] + ".readWord(" + str.toOct(addr) + ")", 0, true);
if (afn[2]) {
return afn[2](addr);
w = afn[2](addr);
} else if (afn[0]) {
return afn[0](addr) | (afn[0](addr + 1) << 8);
w = afn[0](addr) | (afn[0](addr + 1) << 8);
}
}
bus.println("warning: unconverted read access to word @" + str.toOct(addr));
return bus.fnAccess(addr, -1, 0);
if (w >= 0) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message(afn[5] + ".readWord(" + this.dbg.toStrBase(addr) + "): " + this.dbg.toStrBase(w), true);
}
return w;
}
w = bus.fnAccess(addr, -1, 0);
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message("warning: unconverted read access to word @" + this.dbg.toStrBase(addr) + ": " + this.dbg.toStrBase(w));
}
return w;
},
/**
@ -304,22 +329,30 @@ BusPDP11.IOController = {
*/
writeWord: function(off, w, addr)
{
var fWrite = false;
var bus = this.controller;
Component.assert(!(addr & 1)); // unaligned addresses should be getting trapped at a higher level
var afn = bus.aIOHandlers[off];
if (afn) {
if (bus.messageEnabled()) bus.printMessage(afn[5] + ".writeWord(" + str.toOct(addr) + "," + str.toOct(w) + ")", 0, true);
if (afn[3]) {
afn[3](w, addr);
return;
fWrite = true;
} else if (afn[1]) {
afn[1](w & 0xff, addr);
afn[1](w >> 8, addr + 1);
return;
fWrite = true;
}
}
bus.println("warning: unconverted write access to word @" + str.toOct(addr));
if (fWrite) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message(afn[5] + ".writeWord(" + this.dbg.toStrBase(addr) + "," + this.dbg.toStrBase(w) + ")", true);
}
return;
}
bus.fnAccess(addr, w, 0);
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.BUS)) {
this.dbg.message("warning: unconverted write access to word @" + this.dbg.toStrBase(addr) + ": " + this.dbg.toStrBase(w));
}
}
};

View file

@ -588,7 +588,9 @@ if (DEBUGGER) {
var b = 0xff;
var addr = this.getAddr(dbgAddr, false, 1);
if (addr !== PDP11.ADDR_INVALID) {
this.nDisableMessages++;
b = this.bus.getByteDirect(addr);
this.nDisableMessages--;
if (inc) this.incAddr(dbgAddr, inc);
}
return b;
@ -607,7 +609,9 @@ if (DEBUGGER) {
var w = 0xffff;
var addr = this.getAddr(dbgAddr, false, 2);
if (addr !== PDP11.ADDR_INVALID) {
this.nDisableMessages++;
w = this.bus.getWordDirect(addr);
this.nDisableMessages--;
if (inc) this.incAddr(dbgAddr, inc);
}
return w;
@ -625,7 +629,9 @@ if (DEBUGGER) {
{
var addr = this.getAddr(dbgAddr, true, 1);
if (addr !== PDP11.ADDR_INVALID) {
this.nDisableMessages++;
this.bus.setByteDirect(addr, b);
this.nDisableMessages--;
if (inc) this.incAddr(dbgAddr, inc);
this.cpu.updateCPU(true); // we set fForce to true in case video memory was the target
}
@ -643,7 +649,9 @@ if (DEBUGGER) {
{
var addr = this.getAddr(dbgAddr, true, 2);
if (addr !== PDP11.ADDR_INVALID) {
this.nDisableMessages++;
this.bus.setWordDirect(addr, w);
this.nDisableMessages--;
if (inc) this.incAddr(dbgAddr, inc);
this.cpu.updateCPU(true); // we set fForce to true in case video memory was the target
}
@ -1007,6 +1015,7 @@ if (DEBUGGER) {
this.bitsMessage = this.bitsWarning = MessagesPDP11.WARN;
this.sMessagePrev = null;
this.aMessageBuffer = [];
this.nDisableMessages = 0;
/*
* Internally, we use "key" instead of "keys", since the latter is a method on JavasScript objects,
* but externally, we allow the user to specify "keys"; "kbd" is also allowed as shorthand for "keyboard".
@ -1135,6 +1144,8 @@ if (DEBUGGER) {
*/
DebuggerPDP11.prototype.message = function(sMessage, fAddress)
{
if (this.nDisableMessages) return;
if (fAddress) {
sMessage += " at " + this.toStrAddr(this.newAddr(this.cpu.getPC()));
}
@ -1582,7 +1593,9 @@ if (DEBUGGER) {
*/
if (nState >= 0 && this.aaOpcodeCounts.length) {
this.cOpcodes++;
this.nDisableMessages++;
var opCode = this.bus.getWordDirect(addr);
this.nDisableMessages--;
if (opCode != null) {
var dbgAddr = this.aOpcodeHistory[this.iOpcodeHistory];
this.setAddr(dbgAddr, cpu.getPC());

View file

@ -556,7 +556,7 @@ MemoryPDP11.prototype = {
* @return {number}
*/
readNone: function readNone(off, addr) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.CPU | MessagesPDP11.MEM) /* && !off */) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.MEM) /* && !off */) {
this.dbg.message("attempt to read invalid block %" + str.toHex(this.addr), true);
}
return 0xff;
@ -570,7 +570,7 @@ MemoryPDP11.prototype = {
* @param {number} addr
*/
writeNone: function writeNone(off, v, addr) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.CPU | MessagesPDP11.MEM) /* && !off */) {
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.MEM) /* && !off */) {
this.dbg.message("attempt to write " + str.toHexWord(v) + " to invalid block %" + str.toHex(this.addr), true);
}
},
@ -753,7 +753,11 @@ MemoryPDP11.prototype = {
* @return {number}
*/
readByteLE: function readByteLE(off, addr) {
return this.ab[off];
var b = this.ab[off];
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.MEM)) {
this.dbg.message("Memory.readByteLE(" + this.dbg.toStrBase(addr) + "): " + this.dbg.toStrBase(b), true);
}
return b;
},
/**
* readWordBE(off, addr)
@ -779,7 +783,11 @@ MemoryPDP11.prototype = {
* TODO: It remains to be seen if there's any advantage to checking the offset for an aligned read
* vs. always reading the bytes separately.
*/
return (off & 0x1)? (this.ab[off] | (this.ab[off+1] << 8)) : this.aw[off >> 1];
var w = (off & 0x1)? (this.ab[off] | (this.ab[off+1] << 8)) : this.aw[off >> 1];
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.MEM)) {
this.dbg.message("Memory.readWordLE(" + this.dbg.toStrBase(addr) + "): " + this.dbg.toStrBase(w), true);
}
return w;
},
/**
* writeByteBE(off, b, addr)
@ -804,6 +812,9 @@ MemoryPDP11.prototype = {
writeByteLE: function writeByteLE(off, b, addr) {
this.ab[off] = b;
this.fDirty = true;
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.MEM)) {
this.dbg.message("Memory.writeByteLE(" + this.dbg.toStrBase(addr) + "," + this.dbg.toStrBase(b) + ")", true);
}
},
/**
* writeWordBE(off, w, addr)
@ -837,6 +848,9 @@ MemoryPDP11.prototype = {
this.aw[off >> 1] = w;
}
this.fDirty = true;
if (DEBUGGER && this.dbg && this.dbg.messageEnabled(MessagesPDP11.MEM)) {
this.dbg.message("Memory.writeWordLE(" + this.dbg.toStrBase(addr) + "," + this.dbg.toStrBase(w) + ")", true);
}
}
};