Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,21 @@ static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS,
ArrayRef<uint64_t> Operands,
unsigned Operand) {
assert(Operand < Operands.size() && "operand out of bounds");
auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
OS << " (";
if (DumpOpts.Verbose)
OS << format("0x%08" PRIx64 " -> ", Operands[Operand]);
OS << format("0x%08" PRIx64 ")", U->getOffset() + Operands[Operand]);
if (auto Name = dwarf::toString(Die.find(dwarf::DW_AT_name)))
OS << " \"" << *Name << "\"";
if (U) {
auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
OS << " (";
if (DumpOpts.Verbose)
OS << format("0x%08" PRIx64 " -> ", Operands[Operand]);
OS << format("0x%08" PRIx64 ")", U->getOffset() + Operands[Operand]);
if (auto Name = dwarf::toString(Die.find(dwarf::DW_AT_name)))
OS << " \"" << *Name << "\"";
} else {
OS << format(" <invalid base_type ref: 0x%" PRIx64 ">",
Operands[Operand]);
}
} else {
OS << format(" <invalid base_type ref: 0x%" PRIx64 ">",
Operands[Operand]);
OS << format(" <base_type ref: 0x%" PRIx64 ">", Operands[Operand]);
}
}

Expand Down
Binary file not shown.
17 changes: 17 additions & 0 deletions llvm/test/DebugInfo/dwarfdump-loclist-basetyperef.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#RUN: llvm-dwarfdump %p/Inputs/dwarfdump-loclist-basetyperef.elf-x86-64 --debug-loclists | FileCheck %s

// The .debug-loclists section of the binary contains a base type reference as an argument
// to DW_OP_regval_type that cannot be resolved when only dumping the .debug-loclists
// section. prettyPrintBaseTypeRef must handle this case without crashing by printing reduced information.
//
// The binary was compiled using following command:
// gcc-13 dwarfdump-loclist-basetyperef.c -c -g -Og -o dwarfdump-loclist-basetyperef.elf-x86-64
//
// Contents of dwarfdump-loclist-basetyperef.c:
// extern double foo();
//
// void bar(double arg1, double *arg2) {
// *arg2 = foo(arg1);
// }

#CHECK: (0x0000000000000011, 0x0000000000000018): DW_OP_entry_value(DW_OP_regval_type XMM0 <base_type ref: 0x2e>), DW_OP_stack_value