Add multi-process support · WebFreak001/code-debug@00aafd4 · GitHub
Skip to content

Commit 00aafd4

Browse files
committed
Add multi-process support
1 parent f292348 commit 00aafd4

5 files changed

Lines changed: 72 additions & 19 deletions

File tree

‎package.json‎

Lines changed: 5 additions & 0 deletions

‎src/backend/backend.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface IBackend {
5656
start(): Thenable<boolean>;
5757
stop();
5858
detach();
59-
interrupt(): Thenable<boolean>;
59+
interrupt(all: boolean): Thenable<boolean>;
6060
continue(): Thenable<boolean>;
6161
next(): Thenable<boolean>;
6262
step(): Thenable<boolean>;

‎src/backend/mi2/mi2.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,18 @@ export class MI2 extends EventEmitter implements IBackend {
197197
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
198198
if (this.prettyPrint)
199199
cmds.push(this.sendCommand("enable-pretty-printing"));
200+
if (this.multiProcess) {
201+
cmds.push(
202+
this.sendCommand("gdb-set follow-fork-mode parent"),
203+
this.sendCommand("gdb-set detach-on-fork off"),
204+
this.sendCommand("gdb-set non-stop on"),
205+
this.sendCommand("gdb-set schedule-multiple on"),
206+
207+
this.sendCommand("interpreter-exec console \"handle SIGSYS nostop noprint\"")
208+
);
209+
}
200210
for (let cmd of this.extraCommands) {
201211
cmds.push(this.sendCommand(cmd));
202-
}
203212

204213
return cmds;
205214
}
@@ -357,7 +366,7 @@ export class MI2 extends EventEmitter implements IBackend {
357366
else if (reason == "exited-normally")
358367
this.emit("exited-normally", parsed);
359368
else if (reason == "exited") { // exit with error code != 0
360-
this.log("stderr", "Program exited with code " + parsed.record("exit-code"));
369+
this.log("stderr", "Inferior exited with code " + parsed.record("exit-code"));
361370
this.emit("exited-normally", parsed);
362371
} else {
363372
this.log("console", "Not implemented stop reason (assuming exception): " + reason);
@@ -370,6 +379,10 @@ export class MI2 extends EventEmitter implements IBackend {
370379
this.emit("thread-created", parsed);
371380
} else if (record.asyncClass == "thread-exited") {
372381
this.emit("thread-exited", parsed);
382+
} else if (record.asyncClass == "thread-group-started") {
383+
this.emit("thread-group-started", parsed);
384+
} else if (record.asyncClass == "thread-group-exited") {
385+
this.emit("thread-group-exited", parsed);
373386
}
374387
}
375388
}
@@ -431,21 +444,21 @@ export class MI2 extends EventEmitter implements IBackend {
431444
this.sendRaw("-target-detach");
432445
}
433446

434-
interrupt(): Thenable<boolean> {
447+
interrupt(all: boolean = true): Thenable<boolean> {
435448
if (trace)
436449
this.log("stderr", "interrupt");
437450
return new Promise((resolve, reject) => {
438-
this.sendCommand("exec-interrupt").then((info) => {
451+
this.sendCommand("exec-interrupt" + (all ? " --all" : "")).then((info) => {
439452
resolve(info.resultRecords.resultClass == "done");
440453
}, reject);
441454
});
442455
}
443456

444-
continue(reverse: boolean = false): Thenable<boolean> {
457+
continue(reverse: boolean = false, all: boolean = true): Thenable<boolean> {
445458
if (trace)
446459
this.log("stderr", "continue");
447460
return new Promise((resolve, reject) => {
448-
this.sendCommand("exec-continue" + (reverse ? " --reverse" : "")).then((info) => {
461+
this.sendCommand("exec-continue" + (reverse ? " --reverse" : "") + (all ? " --all" : "")).then((info) => {
449462
resolve(info.resultRecords.resultClass == "running");
450463
}, reject);
451464
});
@@ -794,6 +807,7 @@ export class MI2 extends EventEmitter implements IBackend {
794807
}
795808

796809
prettyPrint: boolean = true;
810+
multiProcess: boolean = false;
797811
printCalls: boolean;
798812
debugOutput: boolean;
799813
public procEnv: any;

‎src/gdb.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
1717
ssh: SSHArguments;
1818
valuesFormatting: ValuesFormattingMode;
1919
printCalls: boolean;
20+
multiProcess: boolean;
2021
showDevDebugOutput: boolean;
2122
}
2223

@@ -33,6 +34,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
3334
ssh: SSHArguments;
3435
valuesFormatting: ValuesFormattingMode;
3536
printCalls: boolean;
37+
multiProcess: boolean;
3638
showDevDebugOutput: boolean;
3739
}
3840

@@ -62,6 +64,7 @@ class GDBDebugSession extends MI2DebugSession {
6264
this.debugReady = false;
6365
this.setValuesFormattingMode(args.valuesFormatting);
6466
this.miDebugger.printCalls = !!args.printCalls;
67+
this.miDebugger.multiProcess = !!args.multiProcess;
6568
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
6669
if (args.ssh !== undefined) {
6770
if (args.ssh.forwardX11 === undefined)
@@ -130,6 +133,7 @@ class GDBDebugSession extends MI2DebugSession {
130133
this.debugReady = false;
131134
this.setValuesFormattingMode(args.valuesFormatting);
132135
this.miDebugger.printCalls = !!args.printCalls;
136+
this.miDebugger.multiProcess = !!args.multiProcess;
133137
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
134138
if (args.ssh !== undefined) {
135139
if (args.ssh.forwardX11 === undefined)

‎src/mibase.ts‎

Lines changed: 42 additions & 12 deletions

0 commit comments

Comments
 (0)