[Lldb-commits] [lldb] [lldb-dap] show dialog when executable is not found (PR #104711)
via lldb-commits
lldb-commits at lists.llvm.org
Sun Aug 18 07:29:57 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: None (Da-Viper)
<details>
<summary>Changes</summary>
Fixes #<!-- -->103043
---
Full diff: https://github.com/llvm/llvm-project/pull/104711.diff
1 Files Affected:
- (modified) lldb/tools/lldb-dap/src-ts/extension.ts (+26-3)
``````````diff
diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts b/lldb/tools/lldb-dap/src-ts/extension.ts
index 791175f7b46224..c7802eed2a513b 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -1,4 +1,5 @@
import * as vscode from "vscode";
+import * as fs from "node:fs/promises";
import { LLDBDapOptions } from "./types";
import { DisposableContext } from "./disposable-context";
import { LLDBDapDescriptorFactory } from "./debug-adapter-factory";
@@ -17,10 +18,32 @@ function createDefaultLLDBDapOptions(): LLDBDapOptions {
const path = vscode.workspace
.getConfiguration("lldb-dap", session.workspaceFolder)
.get<string>("executable-path");
- if (path) {
- return new vscode.DebugAdapterExecutable(path, []);
+
+ if (!path) {
+ return packageJSONExecutable;
+ }
+
+ try {
+ const fileStats = await fs.stat(path);
+ if (!fileStats.isFile()) {
+ throw new Error(`Error: ${path} is not a file`);
+ }
+ } catch (err) {
+ const error: Error = err as Error;
+ const openSettingsAction = "Open Settings";
+ const callBackValue = await vscode.window.showErrorMessage(
+ error.message,
+ { modal: true },
+ openSettingsAction,
+ );
+ if (openSettingsAction === callBackValue) {
+ vscode.commands.executeCommand(
+ "workbench.action.openSettings",
+ "lldb-dap.executable-path",
+ );
+ }
}
- return packageJSONExecutable;
+ return new vscode.DebugAdapterExecutable(path, []);
},
};
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/104711
More information about the lldb-commits
mailing list