Skip to content

Commit d7af47b

Browse files
authored
Treat Windows Swift LLDB setup fail differently (#307)
* Fail silently if windows fails to find Swift LLDB This is most likely due to Swift LLDB not running correctly due to $PYTHONHOME being set incorrectly. * add a return * Improve comment message
1 parent 6546b20 commit d7af47b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/WorkspaceContext.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ export class WorkspaceContext implements vscode.Disposable {
284284
async setLLDBVersion() {
285285
const libPathResult = await getLLDBLibPath(this.toolchain);
286286
if (!libPathResult.success) {
287-
const errorMessage = libPathResult.failure
288-
? `Error: ${getErrorDescription(libPathResult.failure)}`
289-
: "";
287+
// if failure message is undefined then fail silently
288+
if (!libPathResult.failure) {
289+
return;
290+
}
291+
const errorMessage = `Error: ${getErrorDescription(libPathResult.failure)}`;
290292
vscode.window.showErrorMessage(
291293
`Failed to setup CodeLLDB for debugging of Swift code. Debugging may produce unexpected results. ${errorMessage}`
292294
);

src/debugger/lldb.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ export async function getLLDBLibPath(toolchain: SwiftToolchain): Promise<Result<
3838
pathHint = m[1];
3939
}
4040
} catch (error) {
41-
// ignore error
41+
// If we get an error on Windows here we should not attempt to use the fallback path. If it failed
42+
// it is most likely due to lldb failing to run because $PYHTONHOME environment variable is setup
43+
// incorrectly (this is the case in Swift < 5.7). In this situation swift lldb does not work so we
44+
// should just the version of lldb that comes with CodeLLDB. We return a failure with no message
45+
// to indicate we want it to fail silently.
46+
if (process.platform === "win32") {
47+
return Result.makeFailure(undefined);
48+
}
4249
}
4350
const lldbPath = await findLibLLDB(pathHint);
4451
if (lldbPath) {

0 commit comments

Comments
 (0)