forked from OSchip/llvm-project
[nfc] [lldb] Assertions for D106270 - [DWARF5] Fix offset check when using .debug_names
Skeleton vs. DWO units mismatch has been fixed in D106270. As they both have type DWARFUnit it is a bit difficult to debug. So it is better to make it safe against future changes. Reviewed By: kimanh, clayborg Differential Revision: https://reviews.llvm.org/D107659
This commit is contained in:
parent
b267d3ce8d
commit
f3932b9a0b
|
@ -79,6 +79,7 @@ void AppleDWARFIndex::GetGlobalVariables(
|
|||
if (!m_apple_names_up)
|
||||
return;
|
||||
|
||||
lldbassert(!cu.GetSymbolFileDWARF().GetDwoNum());
|
||||
const DWARFUnit &non_skeleton_cu = cu.GetNonSkeletonUnit();
|
||||
DWARFMappedHash::DIEInfoArray hash_data;
|
||||
m_apple_names_up->AppendAllDIEsInRange(non_skeleton_cu.GetOffset(),
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
virtual void
|
||||
GetGlobalVariables(const RegularExpression ®ex,
|
||||
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
|
||||
/// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
|
||||
virtual void
|
||||
GetGlobalVariables(DWARFUnit &cu,
|
||||
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
|
||||
|
|
|
@ -124,6 +124,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
|
|||
|
||||
void DebugNamesDWARFIndex::GetGlobalVariables(
|
||||
DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) {
|
||||
lldbassert(!cu.GetSymbolFileDWARF().GetDwoNum());
|
||||
uint64_t cu_offset = cu.GetOffset();
|
||||
bool found_entry_for_cu = false;
|
||||
for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
|
||||
|
|
|
@ -359,9 +359,9 @@ void ManualDWARFIndex::GetGlobalVariables(
|
|||
|
||||
void ManualDWARFIndex::GetGlobalVariables(
|
||||
DWARFUnit &unit, llvm::function_ref<bool(DWARFDIE die)> callback) {
|
||||
lldbassert(!unit.GetSymbolFileDWARF().GetDwoNum());
|
||||
Index();
|
||||
m_set.globals.FindAllEntriesForUnit(unit.GetNonSkeletonUnit(),
|
||||
DIERefCallback(callback));
|
||||
m_set.globals.FindAllEntriesForUnit(unit, DIERefCallback(callback));
|
||||
}
|
||||
|
||||
void ManualDWARFIndex::GetObjCMethods(
|
||||
|
|
|
@ -45,15 +45,16 @@ bool NameToDIE::Find(const RegularExpression ®ex,
|
|||
}
|
||||
|
||||
void NameToDIE::FindAllEntriesForUnit(
|
||||
const DWARFUnit &unit,
|
||||
llvm::function_ref<bool(DIERef ref)> callback) const {
|
||||
DWARFUnit &s_unit, llvm::function_ref<bool(DIERef ref)> callback) const {
|
||||
lldbassert(!s_unit.GetSymbolFileDWARF().GetDwoNum());
|
||||
const DWARFUnit &ns_unit = s_unit.GetNonSkeletonUnit();
|
||||
const uint32_t size = m_map.GetSize();
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
|
||||
if (unit.GetSymbolFileDWARF().GetDwoNum() == die_ref.dwo_num() &&
|
||||
unit.GetDebugSection() == die_ref.section() &&
|
||||
unit.GetOffset() <= die_ref.die_offset() &&
|
||||
die_ref.die_offset() < unit.GetNextUnitOffset()) {
|
||||
if (ns_unit.GetSymbolFileDWARF().GetDwoNum() == die_ref.dwo_num() &&
|
||||
ns_unit.GetDebugSection() == die_ref.section() &&
|
||||
ns_unit.GetOffset() <= die_ref.die_offset() &&
|
||||
die_ref.die_offset() < ns_unit.GetNextUnitOffset()) {
|
||||
if (!callback(die_ref))
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ public:
|
|||
bool Find(const lldb_private::RegularExpression ®ex,
|
||||
llvm::function_ref<bool(DIERef ref)> callback) const;
|
||||
|
||||
/// \a unit must be the skeleton unit if possible, not GetNonSkeletonUnit().
|
||||
void
|
||||
FindAllEntriesForUnit(const DWARFUnit &unit,
|
||||
FindAllEntriesForUnit(DWARFUnit &unit,
|
||||
llvm::function_ref<bool(DIERef ref)> callback) const;
|
||||
|
||||
void
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// No variable should exist in this file.
|
||||
void f() {}
|
|
@ -31,12 +31,15 @@
|
|||
// the compile unit using the name index if it is split.
|
||||
// RUN: %clang -c -o %t-1.o --target=x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -gpubnames %s
|
||||
// RUN: %clang -c -o %t-2.o --target=x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -gpubnames %S/Inputs/find-variable-file-2.cpp
|
||||
// RUN: ld.lld %t-1.o %t-2.o -o %t
|
||||
// RUN: %clang -c -o %t-3.o --target=x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -gpubnames %S/Inputs/find-variable-file-3.cpp
|
||||
// RUN: ld.lld %t-1.o %t-2.o %t-3.o -o %t
|
||||
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
|
||||
// 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: lldb-test symbols --file=find-variable-file-3.cpp --find=variable \
|
||||
// RUN: --name=notexists %t
|
||||
|
||||
// NAMES: Name: .debug_names
|
||||
|
||||
|
|
Loading…
Reference in New Issue