DWARFDebugNames: Implement last GetGlobalVariables overload

This function implements the search for all global variables within a
given compilation unit.

llvm-svn: 334500
This commit is contained in:
Pavel Labath 2018-06-12 13:11:25 +00:00
parent 0782881161
commit dc4bd2e441
3 changed files with 33 additions and 3 deletions

View File

@ -1,7 +1,15 @@
// REQUIRES: lld
// RUN: clang -g -c -o %t-1.o --target=x86_64-pc-linux %s
// RUN: clang -g -c -o %t-2.o --target=x86_64-pc-linux %S/Inputs/find-variable-file-2.cpp
// RUN: clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %s
// RUN: clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %S/Inputs/find-variable-file-2.cpp
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=ONE %s
// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=TWO %s
// RUN: clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
// RUN: clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=ONE %s

View File

@ -123,6 +123,28 @@ void DebugNamesDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
}
}
void DebugNamesDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
DIEArray &offsets) {
m_fallback.GetGlobalVariables(cu, offsets);
uint64_t cu_offset = cu.GetOffset();
for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
for (DebugNames::NameTableEntry nte: ni) {
uint32_t entry_offset = nte.getEntryOffset();
llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
if (entry_or->tag() != DW_TAG_variable)
continue;
if (entry_or->getCUOffset() != cu_offset)
continue;
Append(*entry_or, offsets);
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
}
}
}
void DebugNamesDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
m_fallback.GetTypes(name, offsets);

View File

@ -28,7 +28,7 @@ public:
void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
void GetGlobalVariables(const RegularExpression &regex,
DIEArray &offsets) override;
void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override {}
void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override;
void GetObjCMethods(ConstString class_name, DIEArray &offsets) override {}
void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
DIEArray &offsets) override {}