[Lldb-commits] [lldb] f93fc5e - [lldb-dap][vscode][windows] check if Python is installed properly before starting lldb-dap (#181124)
via lldb-commits
lldb-commits at lists.llvm.org
Thu May 7 02:54:44 PDT 2026
Author: Charles Zablit
Date: 2026-05-07T10:54:38+01:00
New Revision: f93fc5ef3f0e95da24e1391fb013bbd05e2bfd74
URL: https://github.com/llvm/llvm-project/commit/f93fc5ef3f0e95da24e1391fb013bbd05e2bfd74
DIFF: https://github.com/llvm/llvm-project/commit/f93fc5ef3f0e95da24e1391fb013bbd05e2bfd74.diff
LOG: [lldb-dap][vscode][windows] check if Python is installed properly before starting lldb-dap (#181124)
Added:
Modified:
lldb/tools/lldb-dap/extension/src/debug-configuration-provider.ts
lldb/tools/lldb-dap/tool/lldb-dap.cpp
Removed:
################################################################################
diff --git a/lldb/tools/lldb-dap/extension/src/debug-configuration-provider.ts b/lldb/tools/lldb-dap/extension/src/debug-configuration-provider.ts
index a3925ecfdfa58..66a42820ec4cf 100644
--- a/lldb/tools/lldb-dap/extension/src/debug-configuration-provider.ts
+++ b/lldb/tools/lldb-dap/extension/src/debug-configuration-provider.ts
@@ -1,6 +1,7 @@
import * as child_process from "child_process";
import * as util from "util";
import * as vscode from "vscode";
+import * as os from "os";
import { createDebugAdapterExecutable } from "./debug-adapter-factory";
import { LLDBDapServer } from "./lldb-dap-server";
import { LogFilePathProvider } from "./logging";
@@ -76,8 +77,7 @@ export function getDefaultConfigKey(
}
export class LLDBDapConfigurationProvider
- implements vscode.DebugConfigurationProvider
-{
+ implements vscode.DebugConfigurationProvider {
constructor(
private readonly server: LLDBDapServer,
private readonly logger: vscode.LogOutputChannel,
@@ -116,7 +116,7 @@ export class LLDBDapConfigurationProvider
);
this.logger.debug(
"Initial debug configuration:\n" +
- JSON.stringify(debugConfiguration, undefined, 2),
+ JSON.stringify(debugConfiguration, undefined, 2),
);
let config = vscode.workspace.getConfiguration("lldb-dap");
for (const [key, cfg] of Object.entries(configurations)) {
@@ -201,6 +201,22 @@ export class LLDBDapConfigurationProvider
return undefined;
}
+ if (os.platform() === "win32") {
+ const pythonCheckProcess = child_process.spawnSync(executable.command, [
+ "--check-python",
+ ]);
+ if (pythonCheckProcess.status !== 0) {
+ await vscode.window.showErrorMessage(
+ "Python is not installed correctly. Please install it to use lldb-dap.",
+ {
+ modal: true,
+ detail: pythonCheckProcess.stderr?.toString() ?? "",
+ },
+ );
+ return undefined;
+ }
+ }
+
// Server mode needs to be handled here since DebugAdapterDescriptorFactory
// will show an unhelpful error if it returns undefined. We'd rather show a
// nicer error message here and allow stopping the debug session gracefully.
@@ -233,7 +249,7 @@ export class LLDBDapConfigurationProvider
this.logger.info(
"Resolved debug configuration:\n" +
- JSON.stringify(debugConfiguration, undefined, 2),
+ JSON.stringify(debugConfiguration, undefined, 2),
);
return debugConfiguration;
diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index b09e0c7dc9aa9..f9a97563e394c 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -671,6 +671,10 @@ int main(int argc, char *argv[]) {
#ifdef _WIN32
if (input_args.hasArg(OPT_check_python)) {
+#ifndef LLDB_ENABLE_PYTHON
+ llvm::errs() << "lldb-dap was not built with Python support" << '\n';
+ return EXIT_SUCCESS;
+#endif
auto python_path_or_err = SetupPythonRuntimeLibrary();
if (!python_path_or_err) {
llvm::WithColor::error()
More information about the lldb-commits
mailing list