Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS,
ArrayRef<uint64_t> Operands,
unsigned Operand) {
assert(Operand < Operands.size() && "operand out of bounds");
if (!U) {
OS << format(" <base_type ref: 0x%" PRIx64 ">", Operands[Operand]);
return;
}
auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
OS << " (";
Expand All @@ -249,8 +253,7 @@ static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS,
if (auto Name = dwarf::toString(Die.find(dwarf::DW_AT_name)))
OS << " \"" << *Name << "\"";
} else {
OS << format(" <invalid base_type ref: 0x%" PRIx64 ">",
Operands[Operand]);
OS << format(" <invalid base_type ref: 0x%" PRIx64 ">", Operands[Operand]);
}
}

Expand Down
37 changes: 37 additions & 0 deletions llvm/test/DebugInfo/dwarfdump-loclist-basetyperef.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# REQUIRES: x86-registered-target


# This test checks whether llvm-dwarfdump correctly handles base type
# references when dumping the .debug_loclists section.

# When dumping the .debug_loclists section, the corresponding compile unit
# for a base type reference is not known and therefore it cannot be resolved.

# prettyPrintBaseTypeRef must handle this case by printing only reduced
# information without crashing.


# RUN: llvm-mc %s -filetype=obj -triple=x86_64 -o %t
# RUN: llvm-dwarfdump %t --debug-loclists | FileCheck %s

# CHECK: 0x0000000c:
# CHECK-NEXT: <default>: DW_OP_regval_type XMM0 <base_type ref: 0x2a>, DW_OP_stack_value


.section .debug_loclists,"",@progbits
.long .Ldebug_loc1-.Ldebug_loc0 # Length
.Ldebug_loc0:
.value 0x5 # Version
.byte 0x8 # Address size
.byte 0 # Segmen selector size
.long 0 # Offset entry count

.byte 0x5 # DW_LLE_default_location
.uleb128 0x4 # Loc expr size
.byte 0xa5 # DW_OP_regval_type
.uleb128 0x11 # XMM0
.uleb128 0x2a # <base_type ref: 0x2a>
.byte 0x9f # DW_OP_stack_value

.byte 0 # DW_LLE_end_of_list
.Ldebug_loc1: