@@ -32,14 +32,7 @@ namespace lldb_dap {
3232DAP g_dap;
3333
3434DAP::DAP ()
35- : broadcaster(" lldb-dap" ),
36- exception_breakpoints (
37- {{" cpp_catch" , " C++ Catch" , lldb::eLanguageTypeC_plus_plus},
38- {" cpp_throw" , " C++ Throw" , lldb::eLanguageTypeC_plus_plus},
39- {" objc_catch" , " Objective-C Catch" , lldb::eLanguageTypeObjC},
40- {" objc_throw" , " Objective-C Throw" , lldb::eLanguageTypeObjC},
41- {" swift_catch" , " Swift Catch" , lldb::eLanguageTypeSwift},
42- {" swift_throw" , " Swift Throw" , lldb::eLanguageTypeSwift}}),
35+ : broadcaster(" lldb-dap" ), exception_breakpoints(),
4336 focus_tid (LLDB_INVALID_THREAD_ID), stop_at_entry(false ), is_attach(false ),
4437 enable_auto_variable_summaries(false ),
4538 enable_synthetic_child_debugging(false ),
@@ -65,16 +58,42 @@ DAP::DAP()
6558
6659DAP::~DAP () = default ;
6760
61+ void DAP::PopulateExceptionBreakpoints () {
62+ exception_breakpoints = {};
63+ if (debugger.SupportsLanguage (lldb::eLanguageTypeC_plus_plus)) {
64+ exception_breakpoints->emplace_back (" cpp_catch" , " C++ Catch" ,
65+ lldb::eLanguageTypeC_plus_plus);
66+ exception_breakpoints->emplace_back (" cpp_throw" , " C++ Throw" ,
67+ lldb::eLanguageTypeC_plus_plus);
68+ }
69+ if (debugger.SupportsLanguage (lldb::eLanguageTypeObjC)) {
70+ exception_breakpoints->emplace_back (" objc_catch" , " Objective-C Catch" ,
71+ lldb::eLanguageTypeObjC);
72+ exception_breakpoints->emplace_back (" objc_throw" , " Objective-C Throw" ,
73+ lldb::eLanguageTypeObjC);
74+ }
75+ if (debugger.SupportsLanguage (lldb::eLanguageTypeSwift)) {
76+ exception_breakpoints->emplace_back (" swift_catch" , " Swift Catch" ,
77+ lldb::eLanguageTypeSwift);
78+ exception_breakpoints->emplace_back (" swift_throw" , " Swift Throw" ,
79+ lldb::eLanguageTypeSwift);
80+ }
81+ }
82+
6883ExceptionBreakpoint *DAP::GetExceptionBreakpoint (const std::string &filter) {
69- for (auto &bp : exception_breakpoints) {
84+ assert (exception_breakpoints.has_value () &&
85+ " PopulateExceptionBreakpoints must be called first" );
86+ for (auto &bp : *exception_breakpoints) {
7087 if (bp.filter == filter)
7188 return &bp;
7289 }
7390 return nullptr ;
7491}
7592
7693ExceptionBreakpoint *DAP::GetExceptionBreakpoint (const lldb::break_id_t bp_id) {
77- for (auto &bp : exception_breakpoints) {
94+ assert (exception_breakpoints.has_value () &&
95+ " PopulateExceptionBreakpoints must be called first" );
96+ for (auto &bp : *exception_breakpoints) {
7897 if (bp.bp .GetID () == bp_id)
7998 return &bp;
8099 }
0 commit comments