Make breakpoints behave better

This commit is contained in:
Will Scullin 2021-03-13 16:08:24 -08:00
parent b4d6e95ec2
commit e83fdd999e
No known key found for this signature in database
GPG Key ID: 26DCD1042C6638CD
4 changed files with 32 additions and 12 deletions

View File

@ -114,6 +114,7 @@ export class Apple2 implements Restorable<State>, DebuggerContainer {
* `runAnimationFrame` will be non-null.
*/
run() {
this.paused = false;
if (this.runTimer || this.runAnimationFrame) {
return; // already running
}
@ -170,6 +171,7 @@ export class Apple2 implements Restorable<State>, DebuggerContainer {
}
stop() {
this.paused = true;
if (this.runTimer) {
clearInterval(this.runTimer);
}

View File

@ -113,8 +113,8 @@ export default class SmartPort implements Card, Restorable<SmartPortState> {
debug('DumbPort card');
} else {
debug('SmartPort card');
this.rom = smartPortRom;
}
this.rom = smartPortRom;
}
private decodeDisk(unit: number, disk: BlockDevice) {

View File

@ -1012,7 +1012,9 @@ export default class CPU6502 {
this.sync = false;
op.op(op.modeFn);
cb?.(this);
if (cb?.(this)) {
return;
}
}
}
@ -1036,7 +1038,9 @@ export default class CPU6502 {
this.sync = false;
op.op(op.modeFn);
cb?.(this);
if (cb?.(this)) {
return;
}
}
}

View File

@ -33,19 +33,28 @@ export default class Debugger {
if (this.breakpoints.get(info.pc)?.(info)) {
debug('breakpoint', this.printDebugInfo(info));
this.container.stop();
return;
return true;
}
if (this.verbose) {
debug(this.printDebugInfo(info));
} else {
this.trace.push(info);
if (this.trace.length > this.maxTrace) {
this.trace.shift();
}
this.updateTrace(info);
}
});
}
break = () => {
this.container.stop();
}
step = () => {
this.cpu.step(() => {
const info = this.cpu.getDebugInfo();
debug(this.printDebugInfo(info));
this.updateTrace(info);
});
}
continue = () => {
this.container.run();
}
@ -121,10 +130,8 @@ export default class Debugger {
if (debugInfo === undefined) {
debugInfo = this.cpu.getDebugInfo();
}
const { pc, ar, xr, yr, sr, sp } = debugInfo;
const { ar, xr, yr, sr, sp } = debugInfo;
return [
toHex(pc, 4),
'- ',
' A=' + toHex(ar),
' X=' + toHex(xr),
' Y=' + toHex(yr),
@ -180,6 +187,13 @@ export default class Debugger {
return results;
}
private updateTrace(info: DebugInfo) {
this.trace.push(info);
if (this.trace.length > this.maxTrace) {
this.trace.shift();
}
}
private padWithSymbol(pc: word): string {
const padding = ' ';
const symbol = this.symbols[pc];
@ -233,7 +247,7 @@ export default class Debugger {
if (off > 127) {
off -= 256;
}
pc += off + 1;
pc += off + 2;
result += '' + toHexOrSymbol(pc, 4) + ' (' + off + ')';
}
break;