[Lldb-commits] [lldb] [lldb-dap] show dialog when executable is not found (PR #104711)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 21 18:53:14 PDT 2024


================
@@ -14,10 +14,52 @@ export class LLDBDapDescriptorFactory
     this.lldbDapOptions = lldbDapOptions;
   }
 
+  public static async validateDebugAdapterPath(pathUri: vscode.Uri) {
+    try {
+      const fileStats = await vscode.workspace.fs.stat(pathUri);
+      if (!(fileStats.type & vscode.FileType.File)) {
+        this.showErrorMessage(pathUri.path);
+      }
+    } catch (err) {
+      this.showErrorMessage(pathUri.path);
+    }
+  }
+
   async createDebugAdapterDescriptor(
     session: vscode.DebugSession,
     executable: vscode.DebugAdapterExecutable | undefined,
   ): Promise<vscode.DebugAdapterDescriptor | undefined> {
+    const config = vscode.workspace.getConfiguration(
+      "lldb-dap",
+      session.workspaceFolder,
+    );
+    const customPath = config.get<string>("executable-path");
+    const path: string = customPath ? customPath : executable!!.command;
+
+    await LLDBDapDescriptorFactory.validateDebugAdapterPath(
+      vscode.Uri.file(path),
+    );
     return this.lldbDapOptions.createDapExecutableCommand(session, executable);
   }
+
+  /**
+   * Shows a message box when the debug adapter's path is not found
+   */
+  private static showErrorMessage(path: string) {
+    const openSettingsAction = "Open Settings";
+    vscode.window
+      .showErrorMessage(
+        `Debug adapter path: ${path} is not a valid file`,
+        { modal: false },
----------------
vogelsgesang wrote:

we aren't using modals in the current code. I am just proposing to be less epxlicit here. And not set "modal: false" as this is the default in the VS Code API, anyway

https://github.com/llvm/llvm-project/pull/104711


More information about the lldb-commits mailing list