diff options
| author | Augusto Noronha <augusto2112@me.com> | 2023-03-16 15:51:34 -0700 |
|---|---|---|
| committer | Augusto Noronha <augusto2112@me.com> | 2023-03-18 10:33:14 -0700 |
| commit | f03cd763384bbb67ddfa12957859ed58841d4b34 (patch) | |
| tree | bd50c9c50b9182cf60b230aa9b8b82f20eee800b | |
| parent | 6a6b65a84cd5540e0f445665b064c8e54a07c8e8 (diff) | |
[lldb] Introduce SymbolFile::ParseAllLanguages
SymbolFile::ParseAllLanguages allows collecting the languages of the
extra compile units a SymbolFileDWARFDebugMap may have, which can't
be accessed otherwise. For every other symbol file type, it should
behave exactly the same as ParseLanguage.
rdar://97610458
Differential Revision: https://reviews.llvm.org/D146265
3 files changed, 25 insertions, 0 deletions
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 8548973bad3f..d3e3166ab27f 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -25,6 +25,7 @@ #include "lldb/Utility/XcodeSDK.h" #include "lldb/lldb-private.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/Support/Errc.h" #include <mutex> @@ -146,6 +147,17 @@ public: virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0; /// Return the Xcode SDK comp_unit was compiled against. virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; } + + /// This function exists because SymbolFileDWARFDebugMap may extra compile + /// units which aren't exposed as "real" compile units. In every other + /// case this function should behave identically as ParseLanguage. + virtual llvm::SmallSet<lldb::LanguageType, 4> + ParseAllLanguages(CompileUnit &comp_unit) { + llvm::SmallSet<lldb::LanguageType, 4> langs; + langs.insert(ParseLanguage(comp_unit)); + return langs; + } + virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0; virtual bool ParseLineTable(CompileUnit &comp_unit) = 0; virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index c8140f0f9148..9b22b1b94aae 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -683,6 +683,17 @@ XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) { return {}; } +llvm::SmallSet<lldb::LanguageType, 4> +SymbolFileDWARFDebugMap::ParseAllLanguages( + lldb_private::CompileUnit &comp_unit) { + llvm::SmallSet<lldb::LanguageType, 4> langs; + auto *info = GetCompUnitInfo(comp_unit); + for (auto &comp_unit : info->compile_units_sps) { + langs.insert(comp_unit->GetLanguage()); + } + return langs; +} + size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 485fb5b8f908..84f78d87d64c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -62,6 +62,8 @@ public: ParseLanguage(lldb_private::CompileUnit &comp_unit) override; lldb_private::XcodeSDK ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override; + llvm::SmallSet<lldb::LanguageType, 4> + ParseAllLanguages(lldb_private::CompileUnit &comp_unit) override; size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override; bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override; bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override; |
