[Lldb-commits] [lldb] [lldb-dap][vscode][windows] check if Python is installed properly before starting lldb-dap (PR #181124)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 29 04:24:02 PDT 2026
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/181124
>From 0a348776b7fda66d3de2ae1e0fc62ce15e5db173 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 12 Feb 2026 13:01:36 +0100
Subject: [PATCH 1/3] [lldb-dap][vscode][windows] check if Python is installed
properly before starting lldb-dap
---
lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts b/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts
index deacdea145a41..53eaac92d1286 100644
--- a/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts
+++ b/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts
@@ -2,6 +2,7 @@ import { FSWatcher, watch as chokidarWatch } from "chokidar";
import * as child_process from "node:child_process";
import { isDeepStrictEqual } from "util";
import * as vscode from "vscode";
+import * as os from "os";
/**
* Represents a running lldb-dap process that is accepting connections (i.e. in "server mode").
@@ -60,6 +61,15 @@ export class LLDBDapServer implements vscode.Disposable {
}
this.serverInfo = new Promise((resolve, reject) => {
+ if (os.platform() === "win32") {
+ const pythonCheckProcess = child_process.spawnSync(dapPath, ["--check-python"]);
+ if (pythonCheckProcess.stderr) {
+ vscode.window.showErrorMessage(
+ `Python is not installed correctly. Please install it to use lldb-dap.\n${pythonCheckProcess.stderr}`
+ );
+ return;
+ }
+ }
const process = child_process.spawn(dapPath, dapArgs, options);
process.on("error", (error) => {
reject(error);
>From 4cab18e1a610bf650510a0dd2e5f7d92baa8489d Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 29 Apr 2026 12:12:24 +0100
Subject: [PATCH 2/3] fixup! [lldb-dap][vscode][windows] check if Python is
installed properly before starting lldb-dap
---
.../lldb-dap/extension/src/lldb-dap-server.ts | 25 ++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts b/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts
index 53eaac92d1286..0e9edd44eb76b 100644
--- a/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts
+++ b/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts
@@ -60,16 +60,23 @@ export class LLDBDapServer implements vscode.Disposable {
return this.serverInfo;
}
- this.serverInfo = new Promise((resolve, reject) => {
- if (os.platform() === "win32") {
- const pythonCheckProcess = child_process.spawnSync(dapPath, ["--check-python"]);
- if (pythonCheckProcess.stderr) {
- vscode.window.showErrorMessage(
- `Python is not installed correctly. Please install it to use lldb-dap.\n${pythonCheckProcess.stderr}`
- );
- return;
- }
+ if (os.platform() === "win32") {
+ const pythonCheckProcess = child_process.spawnSync(dapPath, [
+ "--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;
}
+ }
+
+ this.serverInfo = new Promise((resolve, reject) => {
const process = child_process.spawn(dapPath, dapArgs, options);
process.on("error", (error) => {
reject(error);
>From 8dc0101e9bc6a22f8992b2f06fa2a5ee49a8ad22 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 29 Apr 2026 12:22:53 +0100
Subject: [PATCH 3/3] exit with 0 if lldb-dap was not built with Python support
---
lldb/tools/lldb-dap/tool/lldb-dap.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index 61d42ed49ffa1..f91004dcf78ce 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -668,6 +668,10 @@ int main(int argc, char *argv[]) {
#ifdef _WIN32
if (input_args.hasArg(OPT_check_python)) {
+#ifndef LLDB_ENABLE_PYTHON
+ llvm::outs() << "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