JDevlieghere created this revision. JDevlieghere added reviewers: wallace, clayborg. JDevlieghere requested review of this revision.
Make sure we always terminate the debugger by using a RAII object. https://reviews.llvm.org/D99702 Files: lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp =================================================================== --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -44,6 +44,7 @@ #include <vector> #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" @@ -3112,6 +3113,10 @@ // Initialize LLDB first before we do anything. lldb::SBDebugger::Initialize(); + // Terminate the debugger before the C++ destructor chain kicks in. + auto terminate_debugger = + llvm::make_scope_exit([] { lldb::SBDebugger::Terminate(); }); + RegisterRequestCallbacks(); int portno = -1; @@ -3165,8 +3170,5 @@ ++packet_idx; } - // We must terminate the debugger in a thread before the C++ destructor - // chain messes everything up. - lldb::SBDebugger::Terminate(); return 0; }
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp =================================================================== --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -44,6 +44,7 @@ #include <vector> #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" @@ -3112,6 +3113,10 @@ // Initialize LLDB first before we do anything. lldb::SBDebugger::Initialize(); + // Terminate the debugger before the C++ destructor chain kicks in. + auto terminate_debugger = + llvm::make_scope_exit([] { lldb::SBDebugger::Terminate(); }); + RegisterRequestCallbacks(); int portno = -1; @@ -3165,8 +3170,5 @@ ++packet_idx; } - // We must terminate the debugger in a thread before the C++ destructor - // chain messes everything up. - lldb::SBDebugger::Terminate(); return 0; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits