Skip to content

Commit 95b1ccd

Browse files
Merge pull request #428 from microsoft/dev/gcampbell/miDebuggerPath
update miDebuggerPath resolution
2 parents f0a69ee + 8c62e56 commit 95b1ccd

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Run the following commands, in a terminal, from the Makefile Tools extension code base root folder:
88
* `yarn install` will install the dependencies needed to build the extension.
99
* **(optional)** `yarn global add vsce` will install `vsce` globally to create a VSIX package that you can install.
10-
* To compile source changes, run from terminal: 'yarn compile'.
10+
* To compile source changes, run from terminal: `yarn compile`.
1111
* This is also done automatically by VSCode when requesting to debug the extension via F5.
1212
* To build a vsix with your changes, run from terminal: 'vsce package'.
1313
* File an [issue](https://github.com/microsoft/vscode-makefile-tools/issues) and a [pull request](https://github.com/microsoft/vscode-makefile-tools/pulls) with the change and we will review it.

src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
233233
await launcher.runCurrentTarget();
234234
}));
235235

236+
237+
/** Start of commands that shouldn't be exposed in package.json, they are used for command substitution in launch.json and tasks.json. */
236238
context.subscriptions.push(vscode.commands.registerCommand('makefile.getLaunchTargetPath', () => {
237239
telemetry.logEvent("getLaunchTargetPath");
238240
return launcher.getLaunchTargetPath();
@@ -272,6 +274,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
272274
telemetry.logEvent("makeBaseDirectory");
273275
return configuration.makeBaseDirectory();
274276
}));
277+
/** End of commands that shouldn't be exposed in package.json, they are used for command substitution in launch.json and tasks.json. */
275278

276279
context.subscriptions.push(vscode.commands.registerCommand('makefile.configure', async () => {
277280
await make.configure(make.TriggeredBy.configure);

src/launch.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export class Launcher implements vscode.Disposable {
150150

151151
// If the first chosen debugger is not installed, try the other one.
152152
if (guessMiDebuggerPath && guessMiMode) {
153-
let debuggerPath: string = path.join(guessMiDebuggerPath, guessMiMode);
153+
// if the guessMiDebuggerPath is already a file, then go with that. Otherwise, append the guessMiMode.
154+
let debuggerPath: string = util.checkFileExistsSync(guessMiDebuggerPath) ? guessMiDebuggerPath : path.join(guessMiDebuggerPath, guessMiMode);
154155
if (process.platform === "win32") {
155156
// On mingw a file is not found if the extension is not part of the path
156157
debuggerPath = debuggerPath + ".exe";
@@ -173,7 +174,9 @@ export class Launcher implements vscode.Disposable {
173174
const cpptoolsExtension: vscode.Extension<any> | undefined = vscode.extensions.getExtension('ms-vscode.cpptools');
174175
miDebuggerPath = cpptoolsExtension ? path.join(cpptoolsExtension.extensionPath, "debugAdapters", "lldb-mi", "bin", "lldb-mi") : undefined;
175176
} else if (miDebuggerPath && miMode) {
176-
miDebuggerPath = path.join(miDebuggerPath, miMode);
177+
// if the miDebuggerPath is already a file, rather than a directory, go with it.
178+
// Otherwise, append the MiMode.
179+
miDebuggerPath = util.checkFileExistsSync(miDebuggerPath) ? miDebuggerPath : path.join(miDebuggerPath, miMode);
177180
if (process.platform === "win32") {
178181
miDebuggerPath = miDebuggerPath + ".exe";
179182
}

0 commit comments

Comments
 (0)