Skip to content

Commit 1fa4f67

Browse files
authored
Stop falling back to a /usr/bin debugger on Windows, show an error when a non-existent miDebuggerPath is used, and stop showing "unknown error" (#6705)
Fix for #6511 and #6608 * Stop falling back to a /usr/bin debugger on Windows. * Add error message. * Fix unknown error.
1 parent 6254bb6 commit 1fa4f67

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

Extension/src/Debugger/configurationProvider.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,23 @@ export class QuickPickConfigurationProvider implements vscode.DebugConfiguration
7171

7272
const selection: MenuItem | undefined = await vscode.window.showQuickPick(items, {placeHolder: localize("select.configuration", "Select a configuration")});
7373
if (!selection) {
74-
throw new Error(); // User canceled it.
74+
return []; // User canceled it.
7575
}
7676
if (selection.label.startsWith("cl.exe")) {
7777
if (!process.env.DevEnvDir) {
7878
vscode.window.showErrorMessage(localize("cl.exe.not.available", "{0} build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.", "cl.exe"));
79-
throw new Error();
79+
return [selection.configuration];
8080
}
8181
}
8282
if (selection.label.indexOf(buildAndDebugActiveFileStr()) !== -1 && selection.configuration.preLaunchTask) {
8383
try {
8484
await cppBuildTaskProvider.ensureBuildTaskExists(selection.configuration.preLaunchTask);
85+
if (selection.configuration.miDebuggerPath) {
86+
if (!fs.existsSync(selection.configuration.miDebuggerPath)) {
87+
vscode.window.showErrorMessage(localize("miDebuggerPath.not.available", "miDebuggerPath does not exist: {0}. Has a debugger been installed?", selection.configuration.miDebuggerPath));
88+
throw new Error();
89+
}
90+
}
8591
await vscode.debug.startDebugging(folder, selection.configuration);
8692
Telemetry.logDebuggerEvent("buildAndDebug", { "success": "true" });
8793
} catch (e) {
@@ -210,15 +216,19 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
210216

211217
const compilerDirname: string = path.dirname(compilerPath);
212218
const debuggerPath: string = path.join(compilerDirname, debuggerName);
213-
fs.stat(debuggerPath, (err, stats: fs.Stats) => {
214-
if (!err && stats && stats.isFile) {
215-
newConfig.miDebuggerPath = debuggerPath;
216-
} else {
217-
// TODO should probably resolve a missing debugger in a more graceful fashion for win32.
218-
newConfig.miDebuggerPath = path.join("/usr", "bin", debuggerName);
219-
}
219+
if (isWindows) {
220+
newConfig.miDebuggerPath = debuggerPath;
220221
return resolve(newConfig);
221-
});
222+
} else {
223+
fs.stat(debuggerPath, (err, stats: fs.Stats) => {
224+
if (!err && stats && stats.isFile) {
225+
newConfig.miDebuggerPath = debuggerPath;
226+
} else {
227+
newConfig.miDebuggerPath = path.join("/usr", "bin", debuggerName);
228+
}
229+
return resolve(newConfig);
230+
});
231+
}
222232
}
223233
});
224234
}));

0 commit comments

Comments
 (0)