added message when emulation stopped (EmuHalt)

This commit is contained in:
Steven Hugg 2019-12-01 11:47:42 -06:00
parent b673ffc1c9
commit cc0cb584a8
4 changed files with 10 additions and 6 deletions

View File

@ -143,7 +143,7 @@ export interface MemoryBus {
export type DebugCondition = () => boolean;
export type DebugEvalCondition = (c:CpuState) => boolean;
export type BreakpointCallback = (s:EmuState) => void;
export type BreakpointCallback = (s:EmuState, msg?:string) => void;
// for composite breakpoints w/ single debug function
export class BreakpointList {
id2bp : {[id:string] : Breakpoint} = {};
@ -283,16 +283,19 @@ export abstract class BaseDebugPlatform extends BasePlatform {
wasBreakpointHit() : boolean {
return this.debugBreakState != null;
}
breakpointHit(targetClock : number) {
breakpointHit(targetClock : number, reason? : string) {
console.log(this.debugTargetClock, targetClock, this.debugClock, this.isStable());
this.debugTargetClock = targetClock;
this.debugBreakState = this.saveState();
console.log("Breakpoint at clk", this.debugClock, "PC", this.debugBreakState.c.PC.toString(16));
this.pause();
if (this.onBreakpointHit) {
this.onBreakpointHit(this.debugBreakState);
this.onBreakpointHit(this.debugBreakState, reason);
}
}
haltAndCatchFire(reason : string) {
this.breakpointHit(this.debugClock, reason);
}
runEval(evalfunc : DebugEvalCondition) {
this.setDebugCondition( () => {
if (++this.debugClock >= this.debugTargetClock && this.isStable()) {

View File

@ -251,7 +251,7 @@ export class AnimationTimer {
} catch (e) {
this.running = false;
this.pulsing = false;
throw e; // TODO: throw EmuHalt hides stack trace
throw e;
}
}
if (this.useReqAnimFrame)

View File

@ -1123,9 +1123,10 @@ function uiDebugCallback(state: EmuState) {
}
function setupDebugCallback(btnid? : string) {
if (platform.setupDebug) platform.setupDebug((state:EmuState) => {
if (platform.setupDebug) platform.setupDebug((state:EmuState, msg:string) => {
uiDebugCallback(state);
setDebugButtonState(btnid||"pause", "stopped");
msg && showErrorAlert([{msg:"STOPPED: " + msg, line:0}]);
});
}

View File

@ -131,7 +131,7 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
//this.nes.ppu.showSpr0Hit = true;
//this.nes.ppu.clipToTvSize = false;
this.nes.stop = () => {
this.breakpointHit(this.debugClock);
this.haltAndCatchFire("Illegal instruction");
throw new EmuHalt("CPU STOPPED");
};
// insert debug hook