https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/181124
>From 63fa481cb2c16dbd5fa0546b370d51b0a5f26a97 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Thu, 12 Feb 2026 13:01:36 +0100 Subject: [PATCH 1/5] [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 acfb8030f9c53762c690e297745a11c47b9dbf16 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Wed, 29 Apr 2026 12:12:24 +0100 Subject: [PATCH 2/5] 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 006008adc9788431f06737afd9f9216c8a7398e7 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Wed, 29 Apr 2026 12:22:53 +0100 Subject: [PATCH 3/5] 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() >From ac5e7f8938f6121c6475edb7310ceaa6233f6f8a Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Fri, 1 May 2026 17:12:16 +0200 Subject: [PATCH 4/5] move check logic --- .../src/debug-configuration-provider.ts | 24 +++++++++++++++---- .../lldb-dap/extension/src/lldb-dap-server.ts | 17 ------------- 2 files changed, 20 insertions(+), 21 deletions(-) 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/extension/src/lldb-dap-server.ts b/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts index 0e9edd44eb76b..deacdea145a41 100644 --- a/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts +++ b/lldb/tools/lldb-dap/extension/src/lldb-dap-server.ts @@ -2,7 +2,6 @@ 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,22 +59,6 @@ export class LLDBDapServer implements vscode.Disposable { return this.serverInfo; } - 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) => { >From ac59c3a1d2e8d34bfa6ce5303c9f99a839b52b9a Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Tue, 5 May 2026 11:06:18 +0100 Subject: [PATCH 5/5] pipe to errs --- lldb/tools/lldb-dap/tool/lldb-dap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp b/lldb/tools/lldb-dap/tool/lldb-dap.cpp index f91004dcf78ce..0d723804bb57e 100644 --- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp @@ -669,7 +669,7 @@ 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'; + llvm::errs() << "lldb-dap was not built with Python support" << '\n'; return EXIT_SUCCESS; #endif auto python_path_or_err = SetupPythonRuntimeLibrary(); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
