[Lldb-commits] [lldb] [lldb-dap] expand tilde in dap executable path (PR #162635)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 9 04:10:30 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Ebuka Ezike (da-viper)
<details>
<summary>Changes</summary>
Users may have multiple devices and would like to resolve the homepath based on the machine they are on.
---
Full diff: https://github.com/llvm/llvm-project/pull/162635.diff
1 Files Affected:
- (modified) lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts (+14-2)
``````````diff
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 7060638a94864..c34f8866fb2e3 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -1,3 +1,4 @@
+import * as os from "os";
import * as path from "path";
import * as util from "util";
import * as vscode from "vscode";
@@ -9,6 +10,16 @@ import { LogFilePathProvider, LogType } from "./logging";
const exec = util.promisify(child_process.execFile);
+/**
+ * Expands the character `~` to the user's home directory
+ */
+function expandUser(file_path: string): string {
+ if (file_path.startsWith("~")) {
+ return os.homedir() + file_path.slice(1);
+ }
+ return file_path;
+}
+
async function isExecutable(path: string): Promise<Boolean> {
try {
await fs.access(path, fs.constants.X_OK);
@@ -116,8 +127,9 @@ async function getDAPExecutable(
configuration: vscode.DebugConfiguration,
): Promise<string> {
// Check if the executable was provided in the launch configuration.
- const launchConfigPath = configuration["debugAdapterExecutable"];
+ let launchConfigPath = configuration["debugAdapterExecutable"];
if (typeof launchConfigPath === "string" && launchConfigPath.length !== 0) {
+ launchConfigPath = expandUser(launchConfigPath);
if (!(await isExecutable(launchConfigPath))) {
throw new ErrorWithNotification(
`Debug adapter path "${launchConfigPath}" is not a valid file. The path comes from your launch configuration.`,
@@ -129,7 +141,7 @@ async function getDAPExecutable(
// Check if the executable was provided in the extension's configuration.
const config = vscode.workspace.getConfiguration("lldb-dap", workspaceFolder);
- const configPath = config.get<string>("executable-path");
+ const configPath = expandUser(config.get<string>("executable-path") ?? "");
if (configPath && configPath.length !== 0) {
if (!(await isExecutable(configPath))) {
throw new ErrorWithNotification(
``````````
</details>
https://github.com/llvm/llvm-project/pull/162635
More information about the lldb-commits
mailing list