Skip to content

Commit

Permalink
fix: prevent exception with stopOnEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
grahambates committed Nov 17, 2023
1 parent eb42fbb commit 9bbb72f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Prevent exception with stopOnEntry

## [1.0.5] - 2023-11-15

### Fixed

- Force kill emulator if SIGKILL doesn't work
- Handle unsupported message types 'S' for stop codes and 'O' for output
- Special case to handle S05 as exception. Ideally the emulator would return appropriate codes for each exception type,
Expand Down
14 changes: 10 additions & 4 deletions src/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class UAEDebugSession extends LoggingDebugSession {
protected trace = false;
protected stopOnEntry = false;
protected exceptionMask = defaultArgs.exceptionMask;
protected awaitingStopOnEntry = false;

protected breakpoints?: BreakpointManager;
protected variables?: VariableManager;
Expand Down Expand Up @@ -158,11 +159,13 @@ export class UAEDebugSession extends LoggingDebugSession {

const mutex = new Mutex();
this.gdb.on("stop", (haltStatus) => {
mutex.runExclusive(async () => {
return this.handleStop(haltStatus).catch((err) => {
logger.error(this.errorString(err));
if (!this.awaitingStopOnEntry) {
mutex.runExclusive(async () => {
return this.handleStop(haltStatus).catch((err) => {
logger.error(this.errorString(err));
});
});
});
}
});
this.gdb.on("end", this.shutdown.bind(this));
this.gdb.on("output", (msg) =>
Expand Down Expand Up @@ -343,8 +346,11 @@ export class UAEDebugSession extends LoggingDebugSession {

if (args.stopOnEntry) {
logger.log("[LAUNCH] Stopping on entry");
// Tell the standard stop hander to ignore
this.awaitingStopOnEntry = true;
await this.gdb.stepIn(Threads.CPU);
this.sendStoppedEvent(Threads.CPU, "entry");
this.awaitingStopOnEntry = false;
}

// Tell client that we can now handle breakpoints etc.
Expand Down

0 comments on commit 9bbb72f

Please sign in to comment.