Skip to content

Commit

Permalink
fix debugger for clang compilers (#7765)
Browse files Browse the repository at this point in the history
  • Loading branch information
elahehrashedi authored Jul 1, 2021
1 parent 29b0b06 commit 3967429
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
return false;
}
if (defaultConfig.name.startsWith("(Windows) ")) {
if (command.includes("cl.exe")) {
if (command.startsWith("cl.exe")) {
return true;
}
} else {
if (!command.includes("cl.exe")) {
if (!command.startsWith("cl.exe")) {
return true;
}
}
Expand Down Expand Up @@ -203,21 +203,26 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
let debuggerName: string;
if (compilerName.startsWith("clang")) {
newConfig.MIMode = "lldb";
const suffixIndex: number = compilerName.indexOf("-");
const suffix: string = suffixIndex === -1 ? "" : compilerName.substr(suffixIndex);
debuggerName = "lldb-mi" + suffix;
debuggerName = "lldb-mi";
// Search for clang-8, clang-10, etc.
if ((compilerName !== "clang-cl.exe") && (compilerName !== "clang-cpp.exe")) {
const suffixIndex: number = compilerName.indexOf("-");
if (suffixIndex !== -1) {
const suffix: string = compilerName.substr(suffixIndex);
debuggerName += suffix;
}
}
newConfig.type = "cppdbg";
} else if (compilerName === "cl.exe") {
newConfig.miDebuggerPath = undefined;
newConfig.type = "cppvsdbg";
return resolve(newConfig);
} else {
debuggerName = "gdb";
}

if (isWindows) {
debuggerName += ".exe";
debuggerName = debuggerName.endsWith(".exe") ? debuggerName : (debuggerName + ".exe");
}

const compilerDirname: string = path.dirname(compilerPath);
const debuggerPath: string = path.join(compilerDirname, debuggerName);
if (isWindows) {
Expand Down

0 comments on commit 3967429

Please sign in to comment.