[Lldb-commits] [PATCH] D99702: [lldb-vscode] Use LLVM's ScopeExit to ensure we always terminate the debugger
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 31 21:29:39 PDT 2021
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99702.334586.patch
Type: text/x-patch
Size: 943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210401/0ffbe1ed/attachment.bin>
More information about the lldb-commits
mailing list