[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 9 10:24:13 PDT 2024


================
@@ -80,6 +87,45 @@ void DAP::PopulateExceptionBreakpoints() {
       exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
                                           lldb::eLanguageTypeSwift);
     }
+    // Besides handling the hardcoded list of languages from above, we try to
+    // find any other languages that support exception breakpoints using the
+    // SB API.
+    for (int raw_lang = lldb::eLanguageTypeUnknown;
+         raw_lang < lldb::eNumLanguageTypes; ++raw_lang) {
+      lldb::LanguageType lang = static_cast<lldb::LanguageType>(raw_lang);
+
+      // We first discard any languages already handled above.
+      if (lldb::SBLanguageRuntime::LanguageIsCFamily(lang) ||
+          lang == lldb::eLanguageTypeSwift)
+        continue;
+
+      if (!lldb::SBDebugger::SupportsLanguage(lang))
+        continue;
+
+      const char *name = lldb::SBLanguageRuntime::GetNameForLanguageType(lang);
+      if (!name)
+        continue;
+      std::string raw_lang_name = name;
+      std::string capitalized_lang_name = capitalize(name);
+      const char *raw_throw_keyword =
+          lldb::SBLanguageRuntime::GetThrowKeywordForLanguage(lang);
+      const char *raw_catch_keyword =
+          lldb::SBLanguageRuntime::GetCatchKeywordForLanguage(lang);
+      std::string throw_keyword =
+          raw_throw_keyword ? raw_throw_keyword : "throw";
+      std::string catch_keyword =
+          raw_catch_keyword ? raw_catch_keyword : "catch";
----------------
bulbazord wrote:

Suggestion: Instead of always calculating the keywords, why not calculate them conditionally below?

https://github.com/llvm/llvm-project/pull/97871


More information about the lldb-commits mailing list