Skip to content

Commit 92c61ff

Browse files
committed
Improvements to multi-processing
Apparently there have been some improvements to the debug adapter protocol specification to get some assumptions out of the way but they are not implemented in VSCode. Momentarily this is the best support I think is possible for multi-processing without needing DAP v1.51.x. When resuming and stepping some assumptions had to be made about which thread group needed to be continued/stepped, the reason being is that it is indistinguishable if the command came from the top-ribbon or the process/threads window.
1 parent 5ccec73 commit 92c61ff

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

src/backend/backend.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ export interface IBackend {
6464
start(runToStart: boolean): Thenable<boolean>;
6565
stop(): void;
6666
detach(): void;
67-
interrupt(all: boolean): Thenable<boolean>;
68-
continue(): Thenable<boolean>;
67+
interrupt(threadId?: number): Thenable<boolean>;
68+
continue(reverse?: boolean, threadId?: number): Thenable<boolean>;
6969
next(): Thenable<boolean>;
7070
step(): Thenable<boolean>;
7171
stepOut(): Thenable<boolean>;

src/backend/mi2/mi2.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export class MI2 extends EventEmitter implements IBackend {
250250
target = debuggerPath.join(cwd, target);
251251

252252
const cmds = [
253-
this.sendCommand("gdb-set target-async on", true),
253+
this.sendCommand("gdb-set mi-async on", true),
254254
new Promise(resolve => {
255255
this.sendCommand("list-features").then(done => {
256256
this.features = done.result("features");
@@ -560,21 +560,21 @@ export class MI2 extends EventEmitter implements IBackend {
560560
this.sendRaw("-target-detach");
561561
}
562562

563-
interrupt(all: boolean = true): Thenable<boolean> {
563+
interrupt(threadId?: number): Thenable<boolean> {
564564
if (trace)
565-
this.log("stderr", "interrupt");
565+
this.log("stderr", "interrupt" + (threadId ? " --thread-group i" + threadId : ""));
566566
return new Promise((resolve, reject) => {
567-
this.sendCommand("exec-interrupt" + (all ? " --all" : "")).then((info) => {
567+
this.sendCommand("exec-interrupt" + (threadId ? " --thread-group i" + threadId : "")).then((info) => {
568568
resolve(info.resultRecords.resultClass === "done");
569569
}, reject);
570570
});
571571
}
572572

573-
continue(reverse: boolean = false, all: boolean = true): Thenable<boolean> {
573+
continue(reverse: boolean = false, threadId?: number): Thenable<boolean> {
574574
if (trace)
575-
this.log("stderr", "continue");
575+
this.log("stderr", "continue" + (reverse ? " --reverse" : "") + (threadId ? " --thread-group i" + threadId : ""));
576576
return new Promise((resolve, reject) => {
577-
this.sendCommand("exec-continue" + (reverse ? " --reverse" : "") + (all ? " --all" : "")).then((info) => {
577+
this.sendCommand("exec-continue" + (reverse ? " --reverse" : "") + (threadId ? " --thread-group i" + threadId : "")).then((info) => {
578578
resolve(info.resultRecords.resultClass === "running");
579579
}, reject);
580580
});

src/mibase.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -692,26 +692,35 @@ export class MI2DebugSession extends DebugSession {
692692
}
693693
}
694694

695-
protected override pauseRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments): void {
696-
this.miDebugger.interrupt().then(done => {
695+
protected override pauseRequest(response: DebugProtocol.PauseResponse, args: DebugProtocol.PauseArguments): void {
696+
this.miDebugger.interrupt(args.threadId).then(done => {
697697
this.sendResponse(response);
698698
}, msg => {
699699
this.sendErrorResponse(response, 3, `Could not pause: ${msg}`);
700700
});
701701
}
702702

703703
protected override reverseContinueRequest(response: DebugProtocol.ReverseContinueResponse, args: DebugProtocol.ReverseContinueArguments): void {
704-
this.miDebugger.continue(true).then(done => {
705-
response.body.allThreadsContinued = true;
704+
this.miDebugger.continue(true, args.threadId).then(done => {
705+
if (!response.hasOwnProperty("body")) {
706+
response.body = Object();
707+
}
708+
709+
response.body.allThreadsContinued = false;
706710
this.sendResponse(response);
707711
}, msg => {
708712
this.sendErrorResponse(response, 2, `Could not continue: ${msg}`);
709713
});
710714
}
711715

712716
protected override continueRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments): void {
713-
this.miDebugger.continue().then(done => {
714-
response.body.allThreadsContinued = true;
717+
this.miDebugger.continue(false, args.threadId).then(done => {
718+
if (!response.hasOwnProperty("body")) {
719+
response.body = Object();
720+
}
721+
722+
response.body.allThreadsContinued = false;
723+
715724
this.sendResponse(response);
716725
}, msg => {
717726
this.sendErrorResponse(response, 2, `Could not continue: ${msg}`);
@@ -726,15 +735,15 @@ export class MI2DebugSession extends DebugSession {
726735
});
727736
}
728737

729-
protected override stepInRequest(response: DebugProtocol.NextResponse, args: DebugProtocol.NextArguments): void {
738+
protected override stepInRequest(response: DebugProtocol.StepInResponse, args: DebugProtocol.StepInArguments): void {
730739
this.miDebugger.step().then(done => {
731740
this.sendResponse(response);
732741
}, msg => {
733742
this.sendErrorResponse(response, 4, `Could not step in: ${msg}`);
734743
});
735744
}
736745

737-
protected override stepOutRequest(response: DebugProtocol.NextResponse, args: DebugProtocol.NextArguments): void {
746+
protected override stepOutRequest(response: DebugProtocol.StepOutResponse, args: DebugProtocol.StepOutArguments): void {
738747
this.miDebugger.stepOut().then(done => {
739748
this.sendResponse(response);
740749
}, msg => {

0 commit comments

Comments
 (0)