aboutsummaryrefslogtreecommitdiffgithub
diff options
context:
space:
mode:
authorAustin Adams <git@austinjadams.com>2019-02-03 16:31:12 -0500
committerAustin Adams <git@austinjadams.com>2019-02-03 16:31:12 -0500
commit54bff2c53cc9db4c8cf421c1a3fa4487450ac36d (patch)
tree8f2d797b76f9d5c479ed80a3aba69451187e9938
parentc53c83df5fbfec93d8d45bbda8e391fbc590121a (diff)
downloadnovice-54bff2c53cc9db4c8cf421c1a3fa4487450ac36d.tar.gz
novice-54bff2c53cc9db4c8cf421c1a3fa4487450ac36d.tar.xz
Make debugger unstep from halts more intuitively
-rw-r--r--novice/simulator/cli-debugger.test.ts14
-rw-r--r--novice/simulator/cli-debugger.ts7
2 files changed, 21 insertions, 0 deletions
diff --git a/novice/simulator/cli-debugger.test.ts b/novice/simulator/cli-debugger.test.ts
index 86eb0b6..e2b50af 100644
--- a/novice/simulator/cli-debugger.test.ts
+++ b/novice/simulator/cli-debugger.test.ts
@@ -227,6 +227,20 @@ describe('cli debugger', () => {
});
});
+ it('does not double unstep for halts', () => {
+ dbg.store(0x3000, 0x0000); // nop
+ dbg.store(0x3001, 0xf025); // halt
+
+ runCmd('c');
+ runCmd('u');
+ runCmd('q');
+
+ return dbg.run().then(() => {
+ expect(stdoutActual).toMatch(/==> 0x3000[^]+==> 0x3001[^]+==> 0x3000/);
+ expect(stdoutActual).not.toMatch(/==> 0x3001[^]+==> 0x3001/);
+ });
+ });
+
it('puts works', () => {
dbg.store(0x3000, 0xe002); // lea r0, message
dbg.store(0x3001, 0xf022); // puts
diff --git a/novice/simulator/cli-debugger.ts b/novice/simulator/cli-debugger.ts
index 03d861d..c23384a 100644
--- a/novice/simulator/cli-debugger.ts
+++ b/novice/simulator/cli-debugger.ts
@@ -218,6 +218,13 @@ class CliDebugger extends Debugger {
}
private async unstepCmd(): Promise<void> {
+ // Maintain the lie that the debugger "freezes" on a halt by
+ // double-unstepping on halts. Without this, after executing a
+ // halt, it seems like nothing happened.
+ if (this.halted && this.log.length > 1) {
+ this.unstep();
+ }
+
this.unstep();
}