Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -867,8 +867,9 @@ continue; // Verify prologue. + bool isDWARF5 = LineTable->Prologue.getVersion() >= 5; uint32_t MaxDirIndex = LineTable->Prologue.IncludeDirectories.size(); - uint32_t FileIndex = 1; + uint32_t FileIndex = isDWARF5 ? 0 : 1; StringMap FullPathMap; for (const auto &FileName : LineTable->Prologue.FileNames) { // Verify directory index. @@ -926,7 +927,6 @@ // 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))) Index: llvm/test/tools/llvm-dwarfdump/X86/verify_dwarf5_debug_line.s =================================================================== --- /dev/null +++ llvm/test/tools/llvm-dwarfdump/X86/verify_dwarf5_debug_line.s @@ -0,0 +1,228 @@ +# RUN: llvm-mc %s -filetype obj -triple arm64-apple-macosx -o %t.out +# RUN: llvm-dwarfdump --verbose -verify %t.out | FileCheck %s + +# CHECK: Verifying .debug_line... + + .section __TEXT,__text,regular,pure_instructions + .build_version macos, 13, 0 + .globl _main ; -- Begin function main + .p2align 2 +_main: ; @main +Lfunc_begin0: + .file 0 "/tmp" "dwarf5.c" md5 0xa6f6c381b31c93c579beac58181f5d01 + .loc 0 1 0 ; dwarf5.c:1:0 + .cfi_startproc +; %bb.0: ; %entry + sub sp, sp, #16 + .cfi_def_cfa_offset 16 + mov x8, x0 + mov w0, #0 ; =0x0 + str wzr, [sp, #12] + str w8, [sp, #8] + str x1, [sp] +Ltmp1: + .loc 0 2 3 prologue_end epilogue_begin ; dwarf5.c:2:3 + add sp, sp, #16 + ret +Ltmp2: +Lfunc_end0: + .cfi_endproc + ; -- End function + .section __DWARF,__debug_abbrev,regular,debug +Lsection_abbrev: + .byte 1 ; Abbreviation Code + .byte 17 ; DW_TAG_compile_unit + .byte 1 ; DW_CHILDREN_yes + .byte 37 ; DW_AT_producer + .byte 37 ; DW_FORM_strx1 + .byte 19 ; DW_AT_language + .byte 5 ; DW_FORM_data2 + .byte 3 ; DW_AT_name + .byte 37 ; DW_FORM_strx1 + .ascii "\202|" ; DW_AT_LLVM_sysroot + .byte 37 ; DW_FORM_strx1 + .byte 114 ; DW_AT_str_offsets_base + .byte 23 ; DW_FORM_sec_offset + .byte 16 ; DW_AT_stmt_list + .byte 23 ; DW_FORM_sec_offset + .byte 27 ; DW_AT_comp_dir + .byte 37 ; DW_FORM_strx1 + .byte 17 ; DW_AT_low_pc + .byte 27 ; DW_FORM_addrx + .byte 18 ; DW_AT_high_pc + .byte 6 ; DW_FORM_data4 + .byte 115 ; DW_AT_addr_base + .byte 23 ; DW_FORM_sec_offset + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 2 ; Abbreviation Code + .byte 46 ; DW_TAG_subprogram + .byte 1 ; DW_CHILDREN_yes + .byte 17 ; DW_AT_low_pc + .byte 27 ; DW_FORM_addrx + .byte 18 ; DW_AT_high_pc + .byte 6 ; DW_FORM_data4 + .ascii "\347\177" ; DW_AT_APPLE_omit_frame_ptr + .byte 25 ; DW_FORM_flag_present + .byte 64 ; DW_AT_frame_base + .byte 24 ; DW_FORM_exprloc + .byte 3 ; DW_AT_name + .byte 37 ; DW_FORM_strx1 + .byte 58 ; DW_AT_decl_file + .byte 11 ; DW_FORM_data1 + .byte 59 ; DW_AT_decl_line + .byte 11 ; DW_FORM_data1 + .byte 39 ; DW_AT_prototyped + .byte 25 ; DW_FORM_flag_present + .byte 73 ; DW_AT_type + .byte 19 ; DW_FORM_ref4 + .byte 63 ; DW_AT_external + .byte 25 ; DW_FORM_flag_present + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 3 ; Abbreviation Code + .byte 5 ; DW_TAG_formal_parameter + .byte 0 ; DW_CHILDREN_no + .byte 2 ; DW_AT_location + .byte 24 ; DW_FORM_exprloc + .byte 3 ; DW_AT_name + .byte 37 ; DW_FORM_strx1 + .byte 58 ; DW_AT_decl_file + .byte 11 ; DW_FORM_data1 + .byte 59 ; DW_AT_decl_line + .byte 11 ; DW_FORM_data1 + .byte 73 ; DW_AT_type + .byte 19 ; DW_FORM_ref4 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 4 ; Abbreviation Code + .byte 36 ; DW_TAG_base_type + .byte 0 ; DW_CHILDREN_no + .byte 3 ; DW_AT_name + .byte 37 ; DW_FORM_strx1 + .byte 62 ; DW_AT_encoding + .byte 11 ; DW_FORM_data1 + .byte 11 ; DW_AT_byte_size + .byte 11 ; DW_FORM_data1 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 5 ; Abbreviation Code + .byte 15 ; DW_TAG_pointer_type + .byte 0 ; DW_CHILDREN_no + .byte 73 ; DW_AT_type + .byte 19 ; DW_FORM_ref4 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 0 ; EOM(3) + .section __DWARF,__debug_info,regular,debug +Lsection_info: +Lcu_begin0: +.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ; Length of Unit + .long Lset0 +Ldebug_info_start0: + .short 5 ; DWARF version number + .byte 1 ; DWARF Unit Type + .byte 8 ; Address Size (in bytes) +.set Lset1, Lsection_abbrev-Lsection_abbrev ; Offset Into Abbrev. Section + .long Lset1 + .byte 1 ; Abbrev [1] 0xc:0x51 DW_TAG_compile_unit + .byte 0 ; DW_AT_producer + .short 29 ; DW_AT_language + .byte 1 ; DW_AT_name + .byte 2 ; DW_AT_LLVM_sysroot +.set Lset2, Lstr_offsets_base0-Lsection_str_off ; DW_AT_str_offsets_base + .long Lset2 +.set Lset3, Lline_table_start0-Lsection_line ; DW_AT_stmt_list + .long Lset3 + .byte 3 ; DW_AT_comp_dir + .byte 0 ; DW_AT_low_pc +.set Lset4, Lfunc_end0-Lfunc_begin0 ; DW_AT_high_pc + .long Lset4 +.set Lset5, Laddr_table_base0-Lsection_info0 ; DW_AT_addr_base + .long Lset5 + .byte 2 ; Abbrev [2] 0x24:0x26 DW_TAG_subprogram + .byte 0 ; DW_AT_low_pc +.set Lset6, Lfunc_end0-Lfunc_begin0 ; DW_AT_high_pc + .long Lset6 + ; DW_AT_APPLE_omit_frame_ptr + .byte 1 ; DW_AT_frame_base + .byte 111 + .byte 4 ; DW_AT_name + .byte 0 ; DW_AT_decl_file + .byte 1 ; DW_AT_decl_line + ; DW_AT_prototyped + .long 74 ; DW_AT_type + ; DW_AT_external + .byte 3 ; Abbrev [3] 0x33:0xb DW_TAG_formal_parameter + .byte 2 ; DW_AT_location + .byte 145 + .byte 8 + .byte 6 ; DW_AT_name + .byte 0 ; DW_AT_decl_file + .byte 1 ; DW_AT_decl_line + .long 74 ; DW_AT_type + .byte 3 ; Abbrev [3] 0x3e:0xb DW_TAG_formal_parameter + .byte 2 ; DW_AT_location + .byte 145 + .byte 0 + .byte 7 ; DW_AT_name + .byte 0 ; DW_AT_decl_file + .byte 1 ; DW_AT_decl_line + .long 78 ; DW_AT_type + .byte 0 ; End Of Children Mark + .byte 4 ; Abbrev [4] 0x4a:0x4 DW_TAG_base_type + .byte 5 ; DW_AT_name + .byte 5 ; DW_AT_encoding + .byte 4 ; DW_AT_byte_size + .byte 5 ; Abbrev [5] 0x4e:0x5 DW_TAG_pointer_type + .long 83 ; DW_AT_type + .byte 5 ; Abbrev [5] 0x53:0x5 DW_TAG_pointer_type + .long 88 ; DW_AT_type + .byte 4 ; Abbrev [4] 0x58:0x4 DW_TAG_base_type + .byte 8 ; DW_AT_name + .byte 6 ; DW_AT_encoding + .byte 1 ; DW_AT_byte_size + .byte 0 ; End Of Children Mark +Ldebug_info_end0: + .section __DWARF,__debug_str_offs,regular,debug +Lsection_str_off: + .long 40 ; Length of String Offsets Set + .short 5 + .short 0 +Lstr_offsets_base0: + .section __DWARF,__debug_str,regular,debug +Linfo_string: + .asciz "clang version 17.0.0 (git@github.com:llvm/llvm-project.git f1f6ca582e2295465e27a79662d6807342abd9dd)" ; string offset=0 + .asciz "dwarf5.c" ; string offset=101 + .asciz "/" ; string offset=110 + .asciz "/tmp" ; string offset=112 + .asciz "main" ; string offset=117 + .asciz "int" ; string offset=122 + .asciz "argc" ; string offset=126 + .asciz "argv" ; string offset=131 + .asciz "char" ; string offset=136 + .section __DWARF,__debug_str_offs,regular,debug + .long 0 + .long 101 + .long 110 + .long 112 + .long 117 + .long 122 + .long 126 + .long 131 + .long 136 + .section __DWARF,__debug_addr,regular,debug +Lsection_info0: +.set Lset7, Ldebug_addr_end0-Ldebug_addr_start0 ; Length of contribution + .long Lset7 +Ldebug_addr_start0: + .short 5 ; DWARF version number + .byte 8 ; Address size + .byte 0 ; Segment selector size +Laddr_table_base0: + .quad Lfunc_begin0 +Ldebug_addr_end0: +.subsections_via_symbols + .section __DWARF,__debug_line,regular,debug +Lsection_line: +Lline_table_start0: