[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 27 07:17:59 PST 2024
================
@@ -5028,48 +5021,128 @@ 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);
+ auto HandleClient = [=](int out_fd, int err_fd, StreamDescriptor input,
+ StreamDescriptor output) {
+ DAP dap = DAP(program_path, log, default_repl_mode, pre_init_commands);
+ dap.input.descriptor = std::move(input);
+ dap.output.descriptor = std::move(output);
+ RegisterRequestCallbacks(dap);
+
+ if (auto Err = dap.ConfigureIO(out_fd, err_fd)) {
+ if (log)
+ *log << "configureIO failed: " << llvm::toStringWithoutConsuming(Err)
+ << "\n";
+ std::cerr << "failed to configureIO: " << llvm::toString(std::move(Err))
----------------
labath wrote:
let's choose whether to use llvm::errs() or std::cerr.
cerr is [effectively banned](https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden), so I'd prefer the former, but I could be convinced to stick to it if everything else uses that.
https://github.com/llvm/llvm-project/pull/116392
More information about the lldb-commits
mailing list