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
25 changes: 10 additions & 15 deletions src/backend/mi2/mi2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,12 @@ export class MI2 extends EventEmitter implements IBackend {
this.process.stderr.on("data", this.stderr.bind(this));
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
const commands = [
this.sendCommand("gdb-set target-async on", true),
this.sendCommand("environment-directory \"" + escape(cwd) + "\"", true)
];
const promises = this.initCommands(target, cwd, false, true);
if (isExtendedRemote) {
commands.push(this.sendCommand("target-select " + target));
commands.push(this.sendCommand("file-symbol-file \"" + escape(executable) + "\""));
promises.push(this.sendCommand("target-select " + target));
promises.push(this.sendCommand("file-symbol-file \"" + escape(executable) + "\""));
}
Promise.all(commands).then(() => {
Promise.all(promises).then(() => {
this.emit("debug-ready");
resolve(undefined);
}, reject);
Expand All @@ -251,11 +248,9 @@ export class MI2 extends EventEmitter implements IBackend {
this.process.stderr.on("data", this.stderr.bind(this));
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
Promise.all([
this.sendCommand("gdb-set target-async on", true),
this.sendCommand("environment-directory \"" + escape(cwd) + "\"", true),
this.sendCommand("target-select remote " + target)
]).then(() => {
const promises = this.initCommands(target, cwd, false, true);
promises.push(this.sendCommand("target-select remote " + target));
Promise.all(promises).then(() => {
this.emit("debug-ready");
resolve(undefined);
}, reject);
Expand Down Expand Up @@ -746,7 +741,7 @@ export class MI2 extends EventEmitter implements IBackend {
this.emit("msg", type, msg[msg.length - 1] == '\n' ? msg : (msg + "\n"));
}

sendUserInput(command: string, threadId: number = 0, frameLevel: number = 0): Thenable<any> {
sendUserInput(command: string, threadId: number = 0, frameLevel: number = 0): Thenable<MINode> {
if (command.startsWith("-")) {
return this.sendCommand(command.substr(1));
} else {
Expand All @@ -763,13 +758,13 @@ export class MI2 extends EventEmitter implements IBackend {
this.process.stdin.write(raw + "\n");
}

async sendCliCommand(command: string, threadId: number = 0, frameLevel: number = 0) {
sendCliCommand(command: string, threadId: number = 0, frameLevel: number = 0): Thenable<MINode> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this from async to direct call seems like a bigger change, can we move that to a separate PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I had to change that was to make the sendCliCommand and sendCommand both have the same type signature. This is because sendCliCommand is now used in the MI2_LLDB.initCommands to send the extra commands (i.e., "settings append target.source-map" command). All of the command promises are collected together and thus it seemed to be consistent to combine the commands sent with sendCliCommand together with those sent with sendCommand.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. @WebFreak001 Do you see any issues with that or can we pull?
"Kind of related": Could you include a GH Action to publish the extension? This would allow people with appropriate rights to get an update out of the door without the need for you to join and manually handle that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing from async to returning the Thenable should have no effect other than the return value being returned now, so fine with that.

Publishing automatically sounds like a good idea, debugging the CI if there is a problem will be a pain though

let miCommand = "interpreter-exec ";
if (threadId != 0) {
miCommand += `--thread ${threadId} --frame ${frameLevel} `;
}
miCommand += `console "${command.replace(/[\\"']/g, '\\$&')}"`;
await this.sendCommand(miCommand);
return this.sendCommand(miCommand);
}

sendCommand(command: string, suppressFailure: boolean = false): Thenable<MINode> {
Expand Down
12 changes: 7 additions & 5 deletions src/backend/mi2/mi2lldb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class MI2_LLDB extends MI2 {
];
if (!attach)
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
for (let cmd of this.extraCommands) {
cmds.push(this.sendCliCommand(cmd));
}
return cmds;
}

Expand All @@ -29,11 +32,10 @@ export class MI2_LLDB extends MI2 {
this.process.stderr.on("data", this.stderr.bind(this));
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
Promise.all([
this.sendCommand("gdb-set target-async on"),
this.sendCommand("file-exec-and-symbols \"" + escape(executable) + "\""),
this.sendCommand("target-attach " + target)
]).then(() => {
const promises = this.initCommands(target, cwd, false, true);
promises.push(this.sendCommand("file-exec-and-symbols \"" + escape(executable) + "\""));
promises.push(this.sendCommand("target-attach " + target));
Promise.all(promises).then(() => {
this.emit("debug-ready");
resolve(undefined);
}, reject);
Expand Down
4 changes: 2 additions & 2 deletions src/gdb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MI2DebugSession } from './mibase';
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
import { DebugProtocol } from 'vscode-debugprotocol';
import { MI2 } from "./backend/mi2/mi2";
import { MI2, escape } from "./backend/mi2/mi2";
import { SSHArguments, ValuesFormattingMode } from './backend/backend';

export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
Expand Down Expand Up @@ -186,7 +186,7 @@ class GDBDebugSession extends MI2DebugSession {
protected setPathSubstitutions(substitutions: { [index: string]: string }): void {
if (substitutions) {
Object.keys(substitutions).forEach(source => {
this.miDebugger.extraCommands.push("gdb-set substitute-path " + source + " " + substitutions[source]);
this.miDebugger.extraCommands.push("gdb-set substitute-path \"" + escape(source) + "\" \"" + escape(substitutions[source]) + "\"");
})
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/lldb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
lldbmipath: string;
env: any;
debugger_args: string[];
pathSubstitutions: { [index: string]: string };
arguments: string;
autorun: string[];
ssh: SSHArguments;
Expand All @@ -24,6 +25,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
lldbmipath: string;
env: any;
debugger_args: string[];
pathSubstitutions: { [index: string]: string };
executable: string;
autorun: string[];
valuesFormatting: ValuesFormattingMode;
Expand All @@ -44,6 +46,7 @@ class LLDBDebugSession extends MI2DebugSession {

protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args, args.env);
this.setPathSubstitutions(args.pathSubstitutions);
this.initDebugger();
this.quit = false;
this.attached = false;
Expand Down Expand Up @@ -105,6 +108,7 @@ class LLDBDebugSession extends MI2DebugSession {

protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args, args.env);
this.setPathSubstitutions(args.pathSubstitutions);
this.initDebugger();
this.quit = false;
this.attached = true;
Expand All @@ -127,7 +131,7 @@ class LLDBDebugSession extends MI2DebugSession {
protected setPathSubstitutions(substitutions: { [index: string]: string }): void {
if (substitutions) {
Object.keys(substitutions).forEach(source => {
this.miDebugger.extraCommands.push("settings set target.source-map " + source + " " + substitutions[source]);
this.miDebugger.extraCommands.push("settings append target.source-map " + source + " " + substitutions[source]);
})
}
}
Expand Down