Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export interface GDBServerController extends EventEmitter {
serverArguments(): string[];
initMatch(): RegExp;
serverLaunchStarted(): void;
serverLaunchCompleted(): void;
serverLaunchCompleted(): Promise<void> | void;
debuggerLaunchStarted(): void;
debuggerLaunchCompleted(): void;
}
Expand Down
5 changes: 2 additions & 3 deletions src/gdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,13 @@ export class GDBDebugSession extends DebugSession {
}, GDBServer.SERVER_TIMEOUT);

this.serverController.serverLaunchStarted();
this.server.init().then((started) => {
this.server.init().then(async (started) => {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}

this.serverController.serverLaunchCompleted();

await this.serverController.serverLaunchCompleted();
let gdbargs = ['-q', '--interpreter=mi2'];
gdbargs = gdbargs.concat(this.args.debuggerArgs || []);

Expand Down
14 changes: 13 additions & 1 deletion src/jlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class JLinkServerController extends EventEmitter implements GDBServerCont
}

public serverLaunchStarted(): void {}
public serverLaunchCompleted(): void {
public serverLaunchCompleted(): Promise<void> {
if (this.args.swoConfig.enabled) {
if ((this.args.swoConfig.source === 'probe') || (this.args.swoConfig.source === 'socket')) {
const swoPortNm = createPortName(this.args.targetProcessor, 'swoPort');
Expand All @@ -200,6 +200,18 @@ export class JLinkServerController extends EventEmitter implements GDBServerCont
}));
}
}

/* The JLink Server will output its initMatch line before it's actually ready to
* process commands from a GDB client. This causes the JLink server's state to fall out of
* sync with the debugger chip from the beginning, and the GDB client will fail to start
* the processor correctly. This typically surfaces as a "Failed to start CPU" line in
* the Adapter output and all registers read as 0xdeadbeee or 0xdeadbeef until the debugger
* chip is reset with "monitor reset".
*
* Sleep for 500ms at the end of the server launch to give the JLink server time to
* settle:
*/
return new Promise(resolve => setTimeout(resolve, 500));
}
public debuggerLaunchStarted(): void {}
public debuggerLaunchCompleted(): void {
Expand Down