[Lldb-commits] [lldb] b7e2c2a - [lldb-vscode] Use LLVM's ScopeExit to ensure we always terminate the debugger
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 31 21:42:09 PDT 2021
Author: Jonas Devlieghere
Date: 2021-03-31T21:41:59-07:00
New Revision: b7e2c2acb8eea471d0960f01d4c75d45156bd9ae
URL: https://github.com/llvm/llvm-project/commit/b7e2c2acb8eea471d0960f01d4c75d45156bd9ae
DIFF: https://github.com/llvm/llvm-project/commit/b7e2c2acb8eea471d0960f01d4c75d45156bd9ae.diff
LOG: [lldb-vscode] Use LLVM's ScopeExit to ensure we always terminate the debugger
Make sure we always terminate the debugger by using a RAII object.
Differential revision: https://reviews.llvm.org/D99702
Added:
Modified:
lldb/tools/lldb-vscode/lldb-vscode.cpp
Removed:
################################################################################
diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp
index 896ea61f9742..cf68386f7432 100644
--- a/lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ b/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 @@ int main(int argc, char *argv[]) {
// 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 @@ int main(int argc, char *argv[]) {
++packet_idx;
}
- // We must terminate the debugger in a thread before the C++ destructor
- // chain messes everything up.
- lldb::SBDebugger::Terminate();
return EXIT_SUCCESS;
}
More information about the lldb-commits
mailing list