[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/87550 >From 7a0af7b0b5699abe4ac5fe5415c849ffe81aa2ee Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Wed, 3 Apr 2024 16:14:40 -0400 Subject: [PATCH] [lldb][lldb-dap] Cleanup breakpoint filters. Details: - remove Swift breakpoint filter because this version of LLDB does not support Swift. - only return objc filters when working on macos. --- lldb/tools/lldb-dap/DAP.cpp | 4 +--- lldb/tools/lldb-dap/lldb-dap.cpp | 7 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index b254ddfef0d5f..52e607350407a 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -36,9 +36,7 @@ DAP::DAP() {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), + {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}), focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false), stop_at_entry(false), is_attach(false), enable_auto_variable_summaries(false), diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index 55f8c920e6001..5f5014eaab90f 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -1628,7 +1628,14 @@ void request_initialize(const llvm::json::Object &request) { body.try_emplace("supportsEvaluateForHovers", true); // Available filters or options for the setExceptionBreakpoints request. llvm::json::Array filters; + std::string triple = + std::string(g_dap.debugger.GetSelectedPlatform().GetTriple()); for (const auto &exc_bp : g_dap.exception_breakpoints) { +// Skipping objc breakpoint filters if not working on macos. +if (exc_bp.language == lldb::eLanguageTypeObjC && +triple.find("macos") == std::string::npos) { + continue; +} filters.emplace_back(CreateExceptionBreakpointFilter(exc_bp)); } body.try_emplace("exceptionBreakpointFilters", std::move(filters)); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo reopened https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/87550 >From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Fri, 24 May 2024 09:19:12 -0400 Subject: [PATCH] [lldb]Clean up breakpoint filters - added util function for querying whether a language is supported by the type system - populate the breakpoint filters table based on the supported language(s) --- lldb/include/lldb/API/SBDebugger.h| 2 ++ lldb/include/lldb/Symbol/TypeSystem.h | 1 + lldb/source/API/SBDebugger.cpp| 4 +++ lldb/source/Symbol/TypeSystem.cpp | 11 lldb/tools/lldb-dap/DAP.cpp | 36 +-- lldb/tools/lldb-dap/DAP.h | 3 +++ lldb/tools/lldb-dap/lldb-dap.cpp | 1 + 7 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index af19b1faf3bf5..84ea9c0f772e1 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -57,6 +57,8 @@ class LLDB_API SBDebugger { static const char *GetBroadcasterClass(); + static bool SupportsLanguage(lldb::LanguageType language); + lldb::SBBroadcaster GetBroadcaster(); /// Get progress data from a SBEvent whose type is eBroadcastBitProgress. diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index b4025c173a186..7d48f9b316138 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface, // TypeSystems can support more than one language virtual bool SupportsLanguage(lldb::LanguageType language) = 0; + static bool SupportsLanguageStatic(lldb::LanguageType language); // Type Completion virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 7ef0d6efd4aaa..29da7d33dd80b 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested() { return m_opaque_sp->InterruptRequested(); return false; } + +bool SBDebugger::SupportsLanguage(lldb::LanguageType language) { + return TypeSystem::SupportsLanguageStatic(language); +} diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 4956f10a0b0a7..f7d14420fba69 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, } return GetTypeSystemForLanguage(language); } + +bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) { + if (language == eLanguageTypeUnknown) +return false; + + LanguageSet plugins = + PluginManager::GetAllTypeSystemSupportedLanguagesForTypes(); + if (plugins.Empty()) +return false; + return plugins[language]; +} diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index c7eb3db4304a9..81aabc55b08da 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -32,14 +32,7 @@ namespace lldb_dap { DAP g_dap; DAP::DAP() -: broadcaster("lldb-dap"), - exception_breakpoints( - {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, - {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, - {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), +: broadcaster("lldb-dap"), exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false), enable_auto_variable_summaries(false), enable_synthetic_child_debugging(false), @@ -61,11 +54,37 @@ DAP::DAP() #endif if (log_file_path) log.reset(new std::ofstream(log_file_path)); + + bp_initted = false; } DAP::~DAP() = default; +void DAP::PopulateExceptionBreakpoints() { + if (debugger.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 (debugger.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 (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) { +exception_breakpoints.emplace_back( +{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}); +exception_breakpoints.emplace_back(
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
oontvoo wrote: > I would be nice if we can detect if we support Swift dynamically. Internally > in LLDB, we can ask for a TypeSystem by language using: > > ``` > llvm::Expected > TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, > Module *module, bool can_create); > llvm::Expected > TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, > Target *target, bool can_create); > ``` > > These functions will return respectively: > > ``` > TypeSystem::CreateInstance(language, module); > TypeSystem::CreateInstance(language, target); > ``` > > We should be able to add a new static method to the TypeSystem.h/.cpp that > can answer if a language is supported with something like: > > ``` > static bool TypeSystem::SupportsLanguage(lldb::LanguageType language); > ``` > > Each TypeSystem plugin can register a new callback that can answer if they > support a language. Then we can add a static function on SBDebugger that > would expose this function with something like: > > ``` > static bool SBDebugger::SupportsLanguage(lldb::LanguageType language); > ``` > > I will make comments in the DAP.cpp where this would be used. Done! https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo closed https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo reopened https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, } return GetTypeSystemForLanguage(language); } + +bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) { + if (language == eLanguageTypeUnknown) +return false; + + LanguageSet plugins = + PluginManager::GetAllTypeSystemSupportedLanguagesForTypes(); JDevlieghere wrote: `s/plugins/languages/` https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -331,6 +333,7 @@ struct DAP { // "Content-Length:" field followed by the length, followed by the raw // JSON bytes. void SendJSON(const std::string &json_str); + bool bp_initted; JDevlieghere wrote: This should be next to `exception_breakpoints`, but I wouldn't bother with the boolean and instead make `exception_breakpoints` a `std::optional<...>` and initialize it in `PopulateExceptionBreakpoints` so that the two are inherently tied together. https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/87550 >From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Fri, 24 May 2024 09:19:12 -0400 Subject: [PATCH 1/2] [lldb]Clean up breakpoint filters - added util function for querying whether a language is supported by the type system - populate the breakpoint filters table based on the supported language(s) --- lldb/include/lldb/API/SBDebugger.h| 2 ++ lldb/include/lldb/Symbol/TypeSystem.h | 1 + lldb/source/API/SBDebugger.cpp| 4 +++ lldb/source/Symbol/TypeSystem.cpp | 11 lldb/tools/lldb-dap/DAP.cpp | 36 +-- lldb/tools/lldb-dap/DAP.h | 3 +++ lldb/tools/lldb-dap/lldb-dap.cpp | 1 + 7 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index af19b1faf3bf5..84ea9c0f772e1 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -57,6 +57,8 @@ class LLDB_API SBDebugger { static const char *GetBroadcasterClass(); + static bool SupportsLanguage(lldb::LanguageType language); + lldb::SBBroadcaster GetBroadcaster(); /// Get progress data from a SBEvent whose type is eBroadcastBitProgress. diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index b4025c173a186..7d48f9b316138 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface, // TypeSystems can support more than one language virtual bool SupportsLanguage(lldb::LanguageType language) = 0; + static bool SupportsLanguageStatic(lldb::LanguageType language); // Type Completion virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 7ef0d6efd4aaa..29da7d33dd80b 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested() { return m_opaque_sp->InterruptRequested(); return false; } + +bool SBDebugger::SupportsLanguage(lldb::LanguageType language) { + return TypeSystem::SupportsLanguageStatic(language); +} diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 4956f10a0b0a7..f7d14420fba69 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, } return GetTypeSystemForLanguage(language); } + +bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) { + if (language == eLanguageTypeUnknown) +return false; + + LanguageSet plugins = + PluginManager::GetAllTypeSystemSupportedLanguagesForTypes(); + if (plugins.Empty()) +return false; + return plugins[language]; +} diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index c7eb3db4304a9..81aabc55b08da 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -32,14 +32,7 @@ namespace lldb_dap { DAP g_dap; DAP::DAP() -: broadcaster("lldb-dap"), - exception_breakpoints( - {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, - {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, - {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), +: broadcaster("lldb-dap"), exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false), enable_auto_variable_summaries(false), enable_synthetic_child_debugging(false), @@ -61,11 +54,37 @@ DAP::DAP() #endif if (log_file_path) log.reset(new std::ofstream(log_file_path)); + + bp_initted = false; } DAP::~DAP() = default; +void DAP::PopulateExceptionBreakpoints() { + if (debugger.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 (debugger.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 (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) { +exception_breakpoints.emplace_back( +{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}); +exception_breakpoints.emplace_ba
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/JDevlieghere approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -61,40 +61,37 @@ DAP::DAP() DAP::~DAP() = default; void DAP::PopulateExceptionBreakpoints() { + exception_breakpoints = {}; if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) { -exception_breakpoints.emplace_back( +exception_breakpoints->emplace_back( {"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}); -exception_breakpoints.emplace_back( +exception_breakpoints->emplace_back( {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}); } if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) { -exception_breakpoints.emplace_back( +exception_breakpoints->emplace_back( {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}); -exception_breakpoints.emplace_back( +exception_breakpoints->emplace_back( {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}); } if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) { -exception_breakpoints.emplace_back( +exception_breakpoints->emplace_back( {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}); -exception_breakpoints.emplace_back( +exception_breakpoints->emplace_back( {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}); } - - bp_initted = true; } ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) { - assert(bp_initted); - for (auto &bp : exception_breakpoints) { + for (auto &bp : *exception_breakpoints) { JDevlieghere wrote: You could keep the assert: ``` assert(exception_breakpoints.has_value() && "PopulateExceptionBreakpoints must be called first") ``` https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/87550 >From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Fri, 24 May 2024 09:19:12 -0400 Subject: [PATCH 1/2] [lldb]Clean up breakpoint filters - added util function for querying whether a language is supported by the type system - populate the breakpoint filters table based on the supported language(s) --- lldb/include/lldb/API/SBDebugger.h| 2 ++ lldb/include/lldb/Symbol/TypeSystem.h | 1 + lldb/source/API/SBDebugger.cpp| 4 +++ lldb/source/Symbol/TypeSystem.cpp | 11 lldb/tools/lldb-dap/DAP.cpp | 36 +-- lldb/tools/lldb-dap/DAP.h | 3 +++ lldb/tools/lldb-dap/lldb-dap.cpp | 1 + 7 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index af19b1faf3bf5..84ea9c0f772e1 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -57,6 +57,8 @@ class LLDB_API SBDebugger { static const char *GetBroadcasterClass(); + static bool SupportsLanguage(lldb::LanguageType language); + lldb::SBBroadcaster GetBroadcaster(); /// Get progress data from a SBEvent whose type is eBroadcastBitProgress. diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index b4025c173a186..7d48f9b316138 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface, // TypeSystems can support more than one language virtual bool SupportsLanguage(lldb::LanguageType language) = 0; + static bool SupportsLanguageStatic(lldb::LanguageType language); // Type Completion virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 7ef0d6efd4aaa..29da7d33dd80b 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested() { return m_opaque_sp->InterruptRequested(); return false; } + +bool SBDebugger::SupportsLanguage(lldb::LanguageType language) { + return TypeSystem::SupportsLanguageStatic(language); +} diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 4956f10a0b0a7..f7d14420fba69 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, } return GetTypeSystemForLanguage(language); } + +bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) { + if (language == eLanguageTypeUnknown) +return false; + + LanguageSet plugins = + PluginManager::GetAllTypeSystemSupportedLanguagesForTypes(); + if (plugins.Empty()) +return false; + return plugins[language]; +} diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index c7eb3db4304a9..81aabc55b08da 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -32,14 +32,7 @@ namespace lldb_dap { DAP g_dap; DAP::DAP() -: broadcaster("lldb-dap"), - exception_breakpoints( - {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, - {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, - {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), +: broadcaster("lldb-dap"), exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false), enable_auto_variable_summaries(false), enable_synthetic_child_debugging(false), @@ -61,11 +54,37 @@ DAP::DAP() #endif if (log_file_path) log.reset(new std::ofstream(log_file_path)); + + bp_initted = false; } DAP::~DAP() = default; +void DAP::PopulateExceptionBreakpoints() { + if (debugger.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 (debugger.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 (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) { +exception_breakpoints.emplace_back( +{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}); +exception_breakpoints.emplace_ba
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/87550 >From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Fri, 24 May 2024 09:19:12 -0400 Subject: [PATCH 1/3] [lldb]Clean up breakpoint filters - added util function for querying whether a language is supported by the type system - populate the breakpoint filters table based on the supported language(s) --- lldb/include/lldb/API/SBDebugger.h| 2 ++ lldb/include/lldb/Symbol/TypeSystem.h | 1 + lldb/source/API/SBDebugger.cpp| 4 +++ lldb/source/Symbol/TypeSystem.cpp | 11 lldb/tools/lldb-dap/DAP.cpp | 36 +-- lldb/tools/lldb-dap/DAP.h | 3 +++ lldb/tools/lldb-dap/lldb-dap.cpp | 1 + 7 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index af19b1faf3bf5..84ea9c0f772e1 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -57,6 +57,8 @@ class LLDB_API SBDebugger { static const char *GetBroadcasterClass(); + static bool SupportsLanguage(lldb::LanguageType language); + lldb::SBBroadcaster GetBroadcaster(); /// Get progress data from a SBEvent whose type is eBroadcastBitProgress. diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index b4025c173a186..7d48f9b316138 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface, // TypeSystems can support more than one language virtual bool SupportsLanguage(lldb::LanguageType language) = 0; + static bool SupportsLanguageStatic(lldb::LanguageType language); // Type Completion virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 7ef0d6efd4aaa..29da7d33dd80b 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested() { return m_opaque_sp->InterruptRequested(); return false; } + +bool SBDebugger::SupportsLanguage(lldb::LanguageType language) { + return TypeSystem::SupportsLanguageStatic(language); +} diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 4956f10a0b0a7..f7d14420fba69 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, } return GetTypeSystemForLanguage(language); } + +bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) { + if (language == eLanguageTypeUnknown) +return false; + + LanguageSet plugins = + PluginManager::GetAllTypeSystemSupportedLanguagesForTypes(); + if (plugins.Empty()) +return false; + return plugins[language]; +} diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index c7eb3db4304a9..81aabc55b08da 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -32,14 +32,7 @@ namespace lldb_dap { DAP g_dap; DAP::DAP() -: broadcaster("lldb-dap"), - exception_breakpoints( - {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, - {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, - {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), +: broadcaster("lldb-dap"), exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false), enable_auto_variable_summaries(false), enable_synthetic_child_debugging(false), @@ -61,11 +54,37 @@ DAP::DAP() #endif if (log_file_path) log.reset(new std::ofstream(log_file_path)); + + bp_initted = false; } DAP::~DAP() = default; +void DAP::PopulateExceptionBreakpoints() { + if (debugger.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 (debugger.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 (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) { +exception_breakpoints.emplace_back( +{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}); +exception_breakpoints.emplace_ba
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
oontvoo wrote: @clayborg Hi, do you have any further comments/feedback on this? Thanks! (If not, I plan to merge this in the next few days) https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
https://github.com/oontvoo closed https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
gulfemsavrun wrote: We started seeing lldb test failures in `TestDAP*`. ``` == FAIL: test_commands (TestDAP_launch.TestDAP_launch.test_commands) Tests the "initCommands", "preRunCommands", "stopCommands", -- Traceback (most recent call last): File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 150, in wrapper return func(*args, **kwargs) ^ File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py", line 324, in test_commands self.continue_to_breakpoints(breakpoint_ids) File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py", line 245, in continue_to_breakpoints self.verify_breakpoint_hit(breakpoint_ids) File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py", line 99, in verify_breakpoint_hit self.assertTrue(False, "breakpoint not hit") AssertionError: False is not true : breakpoint not hit ``` https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
felipepiovezan wrote: @oontvoo I think this broke the bots again: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/5341/console https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
felipepiovezan wrote: Would you mind reverting it until you have a chance to look at the failures? https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -36,9 +36,7 @@ DAP::DAP() {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), + {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}), oontvoo wrote: Thanks for the detailed suggestions! Makes sense! For ObjC, just to clarify, the intention of hiding the filters was NOT because the debugger didn't support it - the intention was to avoid clustering/confusing users - that is, if they're not debugging ObjC, there's no reason to show the objc filters. (And we infer this by checking if they're debugging on a mac - it's theoretically possible they're cross debugging objc from a non-mac but in practice I don't think it's likely ) Does this seem reasonable? https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -36,9 +36,7 @@ DAP::DAP() {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), + {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}), jimingham wrote: The ObjC Language runtime is able to detect whether ObjC is loaded into the program. It runs that detector on each library load, so it keeps an accurate notion of this. Ditto for the swift language runtime. It would be better to consult that than guess based on platform. There may not currently be a way to ask that from the SB API's but we can certainly make one... https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -36,9 +36,7 @@ DAP::DAP() {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), + {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}), oontvoo wrote: > The ObjC Language runtime is able to detect whether ObjC is loaded into the > program. It runs that detector on each library load, so it keeps an accurate > notion of this. Ditto for the swift language runtime. It would be better to > consult that than guess based on platform. This code runs before the runtimes (objc/swift) so it probably won't be able to query that, though? https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -36,9 +36,7 @@ DAP::DAP() {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), + {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}), oontvoo wrote: P.S: it was pointed out to me that changed capabilities can be pushed as an event. So I guess we could init the list of filters based on whether the languages are supported. Then when the runtime(s) become available, we can update the list after querying for which language is being debugged. WDYT? https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
adrian-prantl wrote: > I would be nice if we can detect if we support Swift dynamically. Internally > in LLDB, we can ask for a TypeSystem by language using: See also how lldb/test/Shell/Process/UnsupportedLanguage.test works https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -1628,7 +1628,14 @@ void request_initialize(const llvm::json::Object &request) { body.try_emplace("supportsEvaluateForHovers", true); // Available filters or options for the setExceptionBreakpoints request. llvm::json::Array filters; + std::string triple = + std::string(g_dap.debugger.GetSelectedPlatform().GetTriple()); for (const auto &exc_bp : g_dap.exception_breakpoints) { +// Skipping objc breakpoint filters if not working on macos. +if (exc_bp.language == lldb::eLanguageTypeObjC && +triple.find("macos") == std::string::npos) { bulbazord wrote: In addition to what Jim said above, this might not always work. For example, there are more apple triples (e.g. `arm64-apple-ios`) https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -36,9 +36,7 @@ DAP::DAP() {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), + {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}), jimingham wrote: ObjC tends to only use exceptions for error reporting, not for message passing, so a lot of ObjC developers leave this breakpoint on all the time. Having to wait till the first load event that brings in ObjC would make that tedious. https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)
@@ -36,9 +36,7 @@ DAP::DAP() {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), + {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}), walter-erquinigo wrote: Btw, it's possible to register typesystems/languages at initialization via runtime plugins. I think it would be ideal if the breakpoint list could get updated/refreshed after the target has been loaded (maybe at the first stop point) https://github.com/llvm/llvm-project/pull/87550 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits