https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/140603

>From 8ca0be7cdd49caa32db43097d9ff9c4060b1d87d Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimy...@gmail.com>
Date: Mon, 19 May 2025 20:44:31 +0100
Subject: [PATCH 1/2] [lldb][lldb-dap] show modules pane if supported by the
 adapter

Fixes #140589
Added logic to dynamically set the `lldb-dap.showModules` context based on the 
presence of modules in the debug session.
---
 lldb/tools/lldb-dap/package.json                    |  2 +-
 lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index d5ca604798799..7f90d5535b54b 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -787,7 +787,7 @@
         {
           "id": "lldb-dap.modules",
           "name": "Modules",
-          "when": "inDebugMode && debugType == 'lldb-dap'",
+          "when": "inDebugMode && debugType == 'lldb-dap' && 
lldb-dap.showModules",
           "icon": "$(symbol-module)"
         }
       ]
diff --git a/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts 
b/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
index 1ce190938d9c7..d9c3c617e6d85 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
@@ -52,6 +52,7 @@ export class DebugSessionTracker
   createDebugAdapterTracker(
     session: vscode.DebugSession,
   ): vscode.ProviderResult<vscode.DebugAdapterTracker> {
+    this.showModulesTreeView(false);
     return {
       onDidSendMessage: (message) => this.onDidSendMessage(session, message),
       onExit: () => this.onExit(session),
@@ -73,6 +74,14 @@ export class DebugSessionTracker
     this.modulesChanged.fire();
   }
 
+  private showModulesTreeView(showModules: boolean) {
+    vscode.commands.executeCommand(
+      "setContext",
+      "lldb-dap.showModules",
+      showModules,
+    );
+  }
+
   private onDidSendMessage(
     session: vscode.DebugSession,
     message: DebugProtocol.ProtocolMessage,
@@ -102,6 +111,8 @@ export class DebugSessionTracker
           console.error("unexpected module event reason");
           break;
       }
+
+      this.showModulesTreeView(modules.length > 0);
       this.modules.set(session, modules);
       this.modulesChanged.fire();
     }

>From 2d98cf6f16a7e554ed7b5f00c7dcabb834774cb1 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimy...@gmail.com>
Date: Mon, 19 May 2025 23:42:15 +0100
Subject: [PATCH 2/2] [lldb][lldb-dap] show modules pane if supported by the
 adapter

Added logic to dynamically set the `lldb-dap.showModules` context based on the 
presence of modules in the debug session.
---
 lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts 
b/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
index d9c3c617e6d85..47311a56b0596 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
@@ -71,6 +71,10 @@ export class DebugSessionTracker
   /** Clear information from the active session. */
   private onExit(session: vscode.DebugSession) {
     this.modules.delete(session);
+    // close when there is no more sessions
+    if (this.modules.size <= 0) {
+      this.showModulesTreeView(false);
+    }
     this.modulesChanged.fire();
   }
 
@@ -98,6 +102,9 @@ export class DebugSessionTracker
           } else {
             modules.push(module);
           }
+          if (modules.length == 1) {
+            this.showModulesTreeView(true);
+          }
           break;
         }
         case "removed": {
@@ -112,7 +119,6 @@ export class DebugSessionTracker
           break;
       }
 
-      this.showModulesTreeView(modules.length > 0);
       this.modules.set(session, modules);
       this.modulesChanged.fire();
     }

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to