diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -192,17 +192,18 @@ Optional DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const { - if (IsDWO) { + if (!AddrOffsetSectionBase) { auto R = Context.info_section_units(); // Surprising if a DWO file has more than one skeleton unit in it - this // probably shouldn't be valid, but if a use case is found, here's where to // support it (probably have to linearly search for the matching skeleton CU // here) - if (hasSingleElement(R)) + if (IsDWO && hasSingleElement(R)) return (*R.begin())->getAddrOffsetSectionItem(Index); - } - if (!AddrOffsetSectionBase) + return None; + } + uint64_t Offset = *AddrOffsetSectionBase + Index * getAddressByteSize(); if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize()) return None; diff --git a/llvm/test/DebugInfo/X86/symbolize-debug-fission-single.test b/llvm/test/DebugInfo/X86/symbolize-debug-fission-single.test new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/X86/symbolize-debug-fission-single.test @@ -0,0 +1,304 @@ +# Binary and .o was generated by: +# 1) clang++ -g -gsplit-dwarf=single splitdwarf-single-issue.cpp -O3 -o splitdwarf-single-issue.s -S +# 2) Split in to two .s by making a copy and removing .dwo sections from skeleton .s. +# +# Input .cpp file +# __attribute__((nodebug)) __attribute__((optnone)) void f1() { +# } +# +# __attribute__((always_inline)) inline void f2() { +# +# f1(); +# } +# +# int main() { +# +# f2(); +# } + +# RUN: rm -rf %t +# RUN: mkdir -p %t +# RUN: llvm-mc --filetype=obj --triple=x86_64-pc-linux %s -o %t/symbolize-debug-fission-single -g +# RUN: llvm-mc --filetype=obj --triple=x86_64-pc-linux %s --defsym INCDWO=1 -o %t/symbolize-debug-fission-single.o -g +# RUN: cd %t +# RUN: llvm-symbolizer 0x0000000000000011 -a --obj=%t/symbolize-debug-fission-single \ +# RUN: | FileCheck %s + +# CHECK: 0x11 +# CHECK-NEXT: f2() +# CHECK-NEXT: ././splitdwarf-single-issue.cpp:7:3 +# CHECK-NEXT: main +# CHECK-NEXT: ././splitdwarf-single-issue.cpp:13:3 + + .text + .file "splitdwarf-single-issue.cpp" + .globl _Z2f1v # -- Begin function _Z2f1v + .p2align 4, 0x90 + .type _Z2f1v,@function +_Z2f1v: # @_Z2f1v +.Lfunc_begin0: + .cfi_startproc +# %bb.0: # %entry + retq +.Lfunc_end0: + .size _Z2f1v, .Lfunc_end0-_Z2f1v + .cfi_endproc + # -- End function + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .file 1 "." "splitdwarf-single-issue.cpp" + .loc 1 11 0 # splitdwarf-single-issue.cpp:11:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rax + .cfi_def_cfa_offset 16 +.Ltmp0: + .loc 1 7 3 prologue_end # splitdwarf-single-issue.cpp:7:3 + callq _Z2f1v +.Ltmp1: + .loc 1 15 1 # splitdwarf-single-issue.cpp:15:1 + xorl %eax, %eax + popq %rcx + .cfi_def_cfa_offset 8 + retq +.Ltmp2: +.Lfunc_end1: + .size main, .Lfunc_end1-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .ascii "\264B" # DW_AT_GNU_pubnames + .byte 25 # DW_FORM_flag_present + .ascii "\260B" # DW_AT_GNU_dwo_name + .byte 14 # DW_FORM_strp + .ascii "\261B" # DW_AT_GNU_dwo_id + .byte 7 # DW_FORM_data8 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .ascii "\263B" # DW_AT_GNU_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x25 DW_TAG_compile_unit + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Lskel_string0 # DW_AT_comp_dir + # DW_AT_GNU_pubnames + .long .Lskel_string1 # DW_AT_GNU_dwo_name + .quad -4321749769762995760 # DW_AT_GNU_dwo_id + .quad .Lfunc_begin1 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .long .Laddr_table_base0 # DW_AT_GNU_addr_base +.Ldebug_info_end0: + .section .debug_str,"MS",@progbits,1 +.Lskel_string0: + .asciz "." # string offset=0 +.Lskel_string1: + .asciz "symbolize-debug-fission-single.o" # string offset=37 + .section .debug_addr,"",@progbits +.Laddr_table_base0: + .quad .Lfunc_begin1 + .quad .Ltmp0 + .section .debug_gnu_pubnames,"",@progbits + .long .LpubNames_end0-.LpubNames_start0 # Length of Public Names Info +.LpubNames_start0: + .short 2 # DWARF Version + .long .Lcu_begin0 # Offset of Compilation Unit Info + .long 48 # Compilation Unit Length + .long 31 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "main" # External Name + .long 25 # DIE offset + .byte 48 # Attributes: FUNCTION, EXTERNAL + .asciz "f2" # External Name + .long 0 # End Mark +.LpubNames_end0: + .section .debug_gnu_pubtypes,"",@progbits + .long .LpubTypes_end0-.LpubTypes_start0 # Length of Public Types Info +.LpubTypes_start0: + .short 2 # DWARF Version + .long .Lcu_begin0 # Offset of Compilation Unit Info + .long 48 # Compilation Unit Length + .long 60 # DIE offset + .byte 144 # Attributes: TYPE, STATIC + .asciz "int" # External Name + .long 0 # End Mark +.LpubTypes_end0: + .ident "clang version 13.0.0 (https://github.com/llvm/llvm-project.git f0363d3d38b9a3b831b1bb6fa602eff54ac928fa)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: +.ifdef INCDWO + .section .debug_str.dwo,"eMS",@progbits,1 +.Linfo_string0: + .asciz "_Z2f2v" # string offset=0 +.Linfo_string1: + .asciz "f2" # string offset=7 +.Linfo_string2: + .asciz "main" # string offset=10 +.Linfo_string3: + .asciz "int" # string offset=15 +.Linfo_string4: + .asciz "clang version 13.0.0 (https://github.com/llvm/llvm-project.git f0363d3d38b9a3b831b1bb6fa602eff54ac928fa)" # string offset=19 +.Linfo_string5: + .asciz "splitdwarf-single-issue.cpp" # string offset=124 +.Linfo_string6: + .asciz "symbolize-debug-fission-single.o" # string offset=152 + .section .debug_str_offsets.dwo,"e",@progbits + .long 0 + .long 7 + .long 10 + .long 15 + .long 19 + .long 124 + .long 152 + .section .debug_info.dwo,"e",@progbits + .long .Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit +.Ldebug_info_dwo_start0: + .short 4 # DWARF version number + .long 0 # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x36 DW_TAG_compile_unit + .byte 4 # DW_AT_producer + .short 33 # DW_AT_language + .byte 5 # DW_AT_name + .byte 6 # DW_AT_GNU_dwo_name + .quad -4321749769762995760 # DW_AT_GNU_dwo_id + .byte 2 # Abbrev [2] 0x19:0x6 DW_TAG_subprogram + .byte 0 # DW_AT_linkage_name + .byte 1 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 5 # DW_AT_decl_line + # DW_AT_external + .byte 1 # DW_AT_inline + .byte 3 # Abbrev [3] 0x1f:0x1d DW_TAG_subprogram + .byte 0 # DW_AT_low_pc + .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 87 + # DW_AT_GNU_all_call_sites + .byte 2 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 11 # DW_AT_decl_line + .long 60 # DW_AT_type + # DW_AT_external + .byte 4 # Abbrev [4] 0x2e:0xd DW_TAG_inlined_subroutine + .long 25 # DW_AT_abstract_origin + .byte 1 # DW_AT_low_pc + .long .Ltmp1-.Ltmp0 # DW_AT_high_pc + .byte 1 # DW_AT_call_file + .byte 13 # DW_AT_call_line + .byte 3 # DW_AT_call_column + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x3c:0x4 DW_TAG_base_type + .byte 3 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_dwo_end0: + .section .debug_abbrev.dwo,"e",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .ascii "\260B" # DW_AT_GNU_dwo_name + .ascii "\202>" # DW_FORM_GNU_str_index + .ascii "\261B" # DW_AT_GNU_dwo_id + .byte 7 # DW_FORM_data8 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 110 # DW_AT_linkage_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 32 # DW_AT_inline + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .ascii "\201>" # DW_FORM_GNU_addr_index + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .ascii "\227B" # DW_AT_GNU_all_call_sites + .byte 25 # DW_FORM_flag_present + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .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 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 29 # DW_TAG_inlined_subroutine + .byte 0 # DW_CHILDREN_no + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 17 # DW_AT_low_pc + .ascii "\201>" # DW_FORM_GNU_addr_index + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 88 # DW_AT_call_file + .byte 11 # DW_FORM_data1 + .byte 89 # DW_AT_call_line + .byte 11 # DW_FORM_data1 + .byte 87 # DW_AT_call_column + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .ascii "\202>" # DW_FORM_GNU_str_index + .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 0 # EOM(3) +.endif