From 51d969dc27a80704038b653537fc12a31f4c31f0 Mon Sep 17 00:00:00 2001 From: Soham Dixit Date: Tue, 29 Jun 2021 09:18:21 +0100 Subject: [PATCH] [DebugInfo] Bug 41152 - Improve dumping of empty location expressions Fixes PR41152 (https://bugs.llvm.org/show_bug.cgi?id=41152). Reviewed by: jhenderson, dblaikie, SouraVX Differential Revision: https://reviews.llvm.org/D103502 --- llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp | 3 +++ .../DebugInfo/X86/dwarf-empty-expression.s | 23 +++++++++++++++++++ .../MC/X86/dwarf-size-field-overflow.test | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 llvm/test/DebugInfo/X86/dwarf-empty-expression.s diff --git a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp index d5015f00f1cf..4b9be85f6885 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -326,6 +326,9 @@ void DWARFExpression::print(raw_ostream &OS, DIDumpOptions DumpOpts, bool IsEH) const { uint32_t EntryValExprSize = 0; uint64_t EntryValStartOffset = 0; + if (Data.getData().empty()) + OS << ""; + for (auto &Op : *this) { if (!Op.print(OS, DumpOpts, this, RegInfo, U, IsEH)) { uint64_t FailOffset = Op.getEndOffset(); diff --git a/llvm/test/DebugInfo/X86/dwarf-empty-expression.s b/llvm/test/DebugInfo/X86/dwarf-empty-expression.s new file mode 100644 index 000000000000..7af0187827d8 --- /dev/null +++ b/llvm/test/DebugInfo/X86/dwarf-empty-expression.s @@ -0,0 +1,23 @@ +# RUN: llvm-mc -triple x86_64-unknown-linux -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o --debug-loclists | FileCheck %s + +# CHECK: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000000): + +.Lfunc_begin0: +.Ltmp1: +.section .debug_loclists, "",@progbits + .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length +.Ldebug_list_header_start0: + .short 5 # Version + .byte 8 # Address size + .byte 0 # Segment selector size + .long 1 # Offset entry count +.Lloclists_table_base0: + .long .Ldebug_loc0-.Lloclists_table_base0 +.Ldebug_loc0: + .byte 4 # DW_LLE_offset_pair + .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset + .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset + .byte 0 ### empty + .byte 0 # DW_LLE_end_of_list +.Ldebug_list_header_end0: diff --git a/llvm/test/MC/X86/dwarf-size-field-overflow.test b/llvm/test/MC/X86/dwarf-size-field-overflow.test index 807de9aead27..1a0fb0b6f8fa 100644 --- a/llvm/test/MC/X86/dwarf-size-field-overflow.test +++ b/llvm/test/MC/X86/dwarf-size-field-overflow.test @@ -6,7 +6,7 @@ # # CHECK: 0x0000004d: DW_TAG_formal_parameter # CHECK-NEXT: DW_AT_location (0x00000000 -# CHECK-NEXT: [0x0000000000000000, 0x0000000000000008): ) +# CHECK-NEXT: [0x0000000000000000, 0x0000000000000008): ) # CHECK-NEXT: DW_AT_name ("self") import sys