Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Fixed stepCPU() so that, if a Debugger is present, it always calls ch…
Browse files Browse the repository at this point in the history
…eckInstruction() on at least the first instruction of a run, so that Debugger features like skipping over an initial HALT opcode works properly
  • Loading branch information
jeffpar committed Oct 22, 2016
1 parent 1a484a8 commit 446e60c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 43 deletions.
17 changes: 11 additions & 6 deletions modules/pdp11/lib/cpustate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2073,21 +2073,25 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
* so stopCPU() would have no effect as far as the Debugger is concerned.
*/
this.flags.complete = true;
this.flags.debugCheck = (DEBUGGER && this.dbg && this.dbg.checksEnabled());

/*
* fDebugCheck is true if we need to "check" every instruction with the Debugger.
* nDebugCheck is 1 if we want to "check" every instruction with the Debugger, and -1 if we only
* want to check the first instruction.
*/
var fDebugCheck = this.flags.debugCheck = (DEBUGGER && this.dbg && this.dbg.checksEnabled());
var nDebugCheck = this.flags.debugCheck? 1 : -1;

/*
* nDebugState is checked only when fDebugCheck is true, and its sole purpose is to tell the first call
* nDebugState is checked only when nDebugCheck is set, and its sole purpose is to tell the first call
* to checkInstruction() that it can skip breakpoint checks, and that will be true ONLY when fStarting is
* true OR nMinCycles is zero (the latter means the Debugger is single-stepping).
*
*/
var nDebugState = (!nMinCycles)? -1 : (this.flags.starting? 0 : 1);

/*
* Once we snap fStarting, we clear it, because technically, we've moved beyond "starting" and have
* officially "started" now.
*/
var nDebugState = (!nMinCycles)? -1 : (this.flags.starting? 0 : 1);
this.flags.starting = false;

/*
Expand All @@ -2098,12 +2102,13 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
this.nBurstCycles = this.nStepCycles = nMinCycles;

do {
if (DEBUGGER && fDebugCheck) {
if (DEBUGGER && nDebugCheck) {
if (this.dbg.checkInstruction(this.getPC(), nDebugState)) {
this.stopCPU();
break;
}
nDebugState = 1;
nDebugCheck++;
}

if (this.opFlags) {
Expand Down
Loading

0 comments on commit 446e60c

Please sign in to comment.