Skip to content

Commit a469ca2

Browse files
authored
Merge pull request #6508 from augusto2112/1013-get-langs-comp-unit
[lldb] Introduce SymbolFile::ParseAllLanguages
2 parents af865ac + 11b92f5 commit a469ca2

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>
@@ -149,6 +150,17 @@ class SymbolFile : public PluginInterface {
149150
virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0;
150151
/// Return the Xcode SDK comp_unit was compiled against.
151152
virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; }
153+
154+
/// This function exists because SymbolFileDWARFDebugMap may extra compile
155+
/// units which aren't exposed as "real" compile units. In every other
156+
/// case this function should behave identically as ParseLanguage.
157+
virtual llvm::SmallSet<lldb::LanguageType, 4>
158+
ParseAllLanguages(CompileUnit &comp_unit) {
159+
llvm::SmallSet<lldb::LanguageType, 4> langs;
160+
langs.insert(ParseLanguage(comp_unit));
161+
return langs;
162+
}
163+
152164
virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
153165
virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
154166
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
@@ -688,6 +688,17 @@ XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
688688
return {};
689689
}
690690

691+
llvm::SmallSet<lldb::LanguageType, 4>
692+
SymbolFileDWARFDebugMap::ParseAllLanguages(
693+
lldb_private::CompileUnit &comp_unit) {
694+
llvm::SmallSet<lldb::LanguageType, 4> langs;
695+
auto *info = GetCompUnitInfo(comp_unit);
696+
for (auto &comp_unit : info->compile_units_sps) {
697+
langs.insert(comp_unit->GetLanguage());
698+
}
699+
return langs;
700+
}
701+
691702
size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) {
692703
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
693704
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
@@ -63,6 +63,8 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFileCommon {
6363
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
6464
lldb_private::XcodeSDK
6565
ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
66+
llvm::SmallSet<lldb::LanguageType, 4>
67+
ParseAllLanguages(lldb_private::CompileUnit &comp_unit) override;
6668
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
6769
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
6870
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;

0 commit comments

Comments
 (0)