[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 26 15:06:18 PST 2024


================
@@ -5028,36 +5218,52 @@ int main(int argc, char *argv[]) {
 #endif
 
   // Initialize LLDB first before we do anything.
-  lldb::SBDebugger::Initialize();
+  lldb::SBError error = lldb::SBDebugger::InitializeWithErrorHandling();
+  if (error.Fail()) {
+    llvm::errs() << "Failed to initialize LLDB: " << error.GetCString() << "\n";
+    return EXIT_FAILURE;
+  }
 
   // Terminate the debugger before the C++ destructor chain kicks in.
   auto terminate_debugger =
       llvm::make_scope_exit([] { lldb::SBDebugger::Terminate(); });
 
-  DAP dap = DAP(program_path.str(), default_repl_mode);
+  if (portno != -1) {
+    llvm::errs() << llvm::format("Listening on port %i...\n", portno);
+    return AcceptConnection(program_path.str(), pre_init_commands, log,
+                            default_repl_mode, portno);
+  }
+
+  if (!unix_socket_path.empty()) {
+    return AcceptConnection(program_path.str(), pre_init_commands, log,
+                            default_repl_mode, unix_socket_path);
+  }
+
+  DAP dap = DAP(program_path.str(), log, default_repl_mode, pre_init_commands);
----------------
ashgti wrote:

Done, made this a uniform callback for both stdin/stdout and connections.

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


More information about the lldb-commits mailing list