[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)
Vy Nguyen via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 7 08:20:51 PDT 2024
================
@@ -65,16 +58,60 @@ DAP::DAP()
DAP::~DAP() = default;
+void DAP::PopulateExceptionBreakpoints() {
+ exception_breakpoints = {};
+ if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+ exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+ lldb::eLanguageTypeC_plus_plus);
+ exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+ lldb::eLanguageTypeC_plus_plus);
+ }
+ if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+ exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+ lldb::eLanguageTypeObjC);
+ exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+ lldb::eLanguageTypeObjC);
+ }
+ if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+ exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+ lldb::eLanguageTypeSwift);
+ exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
+ lldb::eLanguageTypeSwift);
+ }
+}
+
ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) {
- for (auto &bp : exception_breakpoints) {
+ // PopulateExceptionBreakpoints() is called after g_dap.debugger is created
+ // in a request-initialize.
+ //
+ // But this GetExceptionBreakpoint() method may be called before attaching, in
+ // which case, we may not have populated the filter yet.
+ //
+ // We also cannot call PopulateExceptionBreakpoints() in DAP::DAP() because
+ // we need SBDebugger::Initialize() to have been called before this.
+ //
+ // So just checking the filter list and do lazy-populating seems easiest.
+ // Two other options include:
+ // + call g_dap.PopulateExceptionBreakpoints() in lldb-dap.cpp::main()
+ // right after the call to SBDebugger::Initialize()
+ // + Just call PopulateExceptionBreakpoints() to get a fresh list everytime
+ // we query (a bit overkill since it's not likely to change?)
+ if (!exception_breakpoints.has_value())
----------------
oontvoo wrote:
Thanks! I've removed the `if()` check and wrap the block of code that populates `exception_breakpoints` in a call_once so the callers of `PopulateExceptionBreakpoints` don't have to do that
https://github.com/llvm/llvm-project/pull/94625
More information about the lldb-commits
mailing list