Skip to content

Commit

Permalink
fix: handle unsupported message types
Browse files Browse the repository at this point in the history
- 'SXX' for stop codes. Previously only 'T' supported
- 'O' for output

Unsupported stop codes are one cause of prb28/vscode-amiga-assembly#263
but at least on FS-UAE there's more to it. The PC address doesn't match
the address of the exception breakpoints for some reason...
  • Loading branch information
grahambates committed Nov 15, 2023
1 parent c31c963 commit b63a8b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Force kill emulator if SIGKILL doesn't work
- Handle unsupported message types 'S' for stop codes and 'O' for output

## [1.0.4] - 2023-11-09

Expand Down
7 changes: 4 additions & 3 deletions src/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export class UAEDebugSession extends LoggingDebugSession {
});
});
this.gdb.on("end", this.shutdown.bind(this));
this.gdb.on("output", (msg) =>
this.sendEvent(new OutputEvent(msg, "console"))
);
}

protected initializeRequest(
Expand Down Expand Up @@ -915,9 +918,7 @@ export class UAEDebugSession extends LoggingDebugSession {
}
if (!ref) {
logger.log(`[STOP] No breakpoint found at address ${formatAddress(pc)}`);
// Copper breakpoints seem to be less precise and don't always stop on the exact address
if (threadId === Threads.COPPER)
this.sendStoppedEvent(threadId, "breakpoint");
this.sendStoppedEvent(threadId, "breakpoint");
return;
}

Expand Down
9 changes: 9 additions & 0 deletions src/gdbClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Socket } from "net";
import { EventEmitter } from "events";
import { logger } from "@vscode/debugadapter";
import { Mutex } from "async-mutex";
import { hexStringToASCII } from "./utils/strings";

export interface HaltEvent {
signal: HaltSignal;
Expand Down Expand Up @@ -30,6 +31,7 @@ export enum BreakpointCode {
type Events = {
stop: (e: HaltEvent) => void;
end: () => void;
output: (message: string) => void;
};

export const DEFAULT_FRAME_INDEX = -1;
Expand Down Expand Up @@ -329,6 +331,7 @@ export class GdbClient {
this.responseCallback(message);
} else {
switch (message[0]) {
case "S":
case "T":
if (!message.startsWith("Te") || !message.includes("tframes")) {
logger.log(`[GDB] STOP: ${message}`);
Expand All @@ -339,6 +342,12 @@ export class GdbClient {
logger.log(`[GDB] END`);
this.sendEvent("end");
break;
case "O":
logger.log(`[GDB] OUTPUT: ${message}`);
this.sendEvent("output", hexStringToASCII(message.substring(1), 2));
break;
default:
logger.log(`[GDB] UNKNOWN: ${message}`);
}
}
}
Expand Down

0 comments on commit b63a8b3

Please sign in to comment.