Skip to content

Commit f03cd76

Browse files
committed
[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
1 parent 6a6b65a commit f03cd76

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "lldb/Utility/XcodeSDK.h"
2626
#include "lldb/lldb-private.h"
2727
#include "llvm/ADT/DenseSet.h"
28+
#include "llvm/ADT/SmallSet.h"
2829
#include "llvm/Support/Errc.h"
2930

3031
#include <mutex>
@@ -146,6 +147,17 @@ class SymbolFile : public PluginInterface {
146147
virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0;
147148
/// Return the Xcode SDK comp_unit was compiled against.
148149
virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; }
150+
151+
/// This function exists because SymbolFileDWARFDebugMap may extra compile
152+
/// units which aren't exposed as "real" compile units. In every other
153+
/// case this function should behave identically as ParseLanguage.
154+
virtual llvm::SmallSet<lldb::LanguageType, 4>
155+
ParseAllLanguages(CompileUnit &comp_unit) {
156+
llvm::SmallSet<lldb::LanguageType, 4> langs;
157+
langs.insert(ParseLanguage(comp_unit));
158+
return langs;
159+
}
160+
149161
virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
150162
virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
151163
virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0;

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,17 @@ XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
683683
return {};
684684
}
685685

686+
llvm::SmallSet<lldb::LanguageType, 4>
687+
SymbolFileDWARFDebugMap::ParseAllLanguages(
688+
lldb_private::CompileUnit &comp_unit) {
689+
llvm::SmallSet<lldb::LanguageType, 4> langs;
690+
auto *info = GetCompUnitInfo(comp_unit);
691+
for (auto &comp_unit : info->compile_units_sps) {
692+
langs.insert(comp_unit->GetLanguage());
693+
}
694+
return langs;
695+
}
696+
686697
size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) {
687698
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
688699
SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFileCommon {
6262
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
6363
lldb_private::XcodeSDK
6464
ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
65+
llvm::SmallSet<lldb::LanguageType, 4>
66+
ParseAllLanguages(lldb_private::CompileUnit &comp_unit) override;
6567
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
6668
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
6769
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;

0 commit comments

Comments
 (0)