[PATCH] D147202: [dwarfdump] Fix .debug_line verification for DWARF 5
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 31 09:29:44 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG031e4e53e88c: [dwarfdump] Fix .debug_line verification for DWARF 5 (authored by JDevlieghere).
Changed prior to commit:
https://reviews.llvm.org/D147202?vs=509678&id=510063#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147202/new/
https://reviews.llvm.org/D147202
Files:
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/test/tools/llvm-dwarfdump/X86/verify_dwarf5_debug_line.yaml
Index: llvm/test/tools/llvm-dwarfdump/X86/verify_dwarf5_debug_line.yaml
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-dwarfdump/X86/verify_dwarf5_debug_line.yaml
@@ -0,0 +1,48 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64-unknown-linux-gnu -o %t.out
+# RUN: llvm-dwarfdump --verbose -verify %t.out | FileCheck %s
+
+# CHECK: Verifying .debug_line...
+
+ .text
+ .file "dwarf5.c"
+ .globl main # -- Begin function main
+ .p2align 4, 0x90
+ .type main, at function
+main: # @main
+.Lfunc_begin0:
+ .file 0 "/tmp" "dwarf5.c" md5 0xa6f6c381b31c93c579beac58181f5d01
+ .loc 0 1 0 # dwarf5.c:1:0
+ .cfi_startproc
+# %bb.0: # %entry
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ movl $0, -4(%rbp)
+ movl %edi, -8(%rbp)
+ movq %rsi, -16(%rbp)
+.Ltmp0:
+ .loc 0 2 3 prologue_end # dwarf5.c:2:3
+ xorl %eax, %eax
+ .loc 0 2 3 epilogue_begin is_stmt 0 # dwarf5.c:2:3
+ popq %rbp
+ .cfi_def_cfa %rsp, 8
+ retq
+.Ltmp1:
+.Lfunc_end0:
+ .size main, .Lfunc_end0-main
+ .cfi_endproc
+ # -- End function
+.Linfo_string0:
+ .asciz "clang version 17.0.0" # string offset=0
+.Linfo_string1:
+ .asciz "dwarf5.c" # string offset=101
+.Linfo_string2:
+ .asciz "/tmp" # string offset=110
+ .section .debug_str_offsets,"", at progbits
+ .long .Linfo_string0
+ .long .Linfo_string1
+ .long .Linfo_string2
+ .ident "clang version 17.0.0"
+.Lline_table_start0:
Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -868,8 +868,10 @@
continue;
// Verify prologue.
+ bool isDWARF5 = LineTable->Prologue.getVersion() >= 5;
uint32_t MaxDirIndex = LineTable->Prologue.IncludeDirectories.size();
- uint32_t FileIndex = 1;
+ uint32_t MinFileIndex = isDWARF5 ? 0 : 1;
+ uint32_t FileIndex = MinFileIndex;
StringMap<uint16_t> FullPathMap;
for (const auto &FileName : LineTable->Prologue.FileNames) {
// Verify directory index.
@@ -927,12 +929,11 @@
// Verify file index.
if (!LineTable->hasFileAtIndex(Row.File)) {
++NumDebugLineErrors;
- bool isDWARF5 = LineTable->Prologue.getVersion() >= 5;
error() << ".debug_line["
<< format("0x%08" PRIx64,
*toSectionOffset(Die.find(DW_AT_stmt_list)))
<< "][" << RowIndex << "] has invalid file index " << Row.File
- << " (valid values are [" << (isDWARF5 ? "0," : "1,")
+ << " (valid values are [" << MinFileIndex << ','
<< LineTable->Prologue.FileNames.size()
<< (isDWARF5 ? ")" : "]") << "):\n";
DWARFDebugLine::Row::dumpTableHeader(OS, 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147202.510063.patch
Type: text/x-patch
Size: 3069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230331/42e1ad4c/attachment-0001.bin>
More information about the llvm-commits
mailing list