[llvm] 7cdd262 - DebugInfo: Fix incorrect line table lookup when resolving decl_file from a split unit
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 4 14:54:34 PDT 2021
Author: David Blaikie
Date: 2021-11-04T14:54:27-07:00
New Revision: 7cdd2623518019c3d3cf162ae9f55f9d72f421d3
URL: https://github.com/llvm/llvm-project/commit/7cdd2623518019c3d3cf162ae9f55f9d72f421d3
DIFF: https://github.com/llvm/llvm-project/commit/7cdd2623518019c3d3cf162ae9f55f9d72f421d3.diff
LOG: DebugInfo: Fix incorrect line table lookup when resolving decl_file from a split unit
Specifically in DWARFv5 the unit for the line table entry was correct
but the context was incorrect - leading to looking up .debug_line_str in
the dwp instead of the executable.
(perhaps we could/should remove the context pointer entirely, and rely
on the one in the unit... I might try that as a separate follow-up
commit)
Added:
llvm/test/DebugInfo/X86/symbolize_function_start_v5.s
Modified:
llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
llvm/test/DebugInfo/X86/symbolize_function_start.s
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index c4e479191a69..cea0f63bbf81 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -767,10 +767,10 @@ Optional<std::string>
DWARFFormValue::getAsFile(DILineInfoSpecifier::FileLineInfoKind Kind) const {
if (U == nullptr || !isFormClass(FC_Constant))
return None;
- DWARFUnit *DU = const_cast<DWARFUnit *>(U);
- if (auto *LT = U->getContext().getLineTableForUnit(DU->getLinkedUnit())) {
+ DWARFUnit *DLU = const_cast<DWARFUnit *>(U)->getLinkedUnit();
+ if (auto *LT = DLU->getContext().getLineTableForUnit(DLU)) {
std::string FileName;
- if (LT->getFileNameByIndex(Value.uval, DU->getCompilationDir(), Kind,
+ if (LT->getFileNameByIndex(Value.uval, DLU->getCompilationDir(), Kind,
FileName))
return FileName;
}
diff --git a/llvm/test/DebugInfo/X86/symbolize_function_start.s b/llvm/test/DebugInfo/X86/symbolize_function_start.s
index fb08c6834988..15862432f24c 100644
--- a/llvm/test/DebugInfo/X86/symbolize_function_start.s
+++ b/llvm/test/DebugInfo/X86/symbolize_function_start.s
@@ -1,12 +1,12 @@
# RUN: rm -rf %t
# RUN: mkdir %t
-# RUN: llvm-mc -filetype=obj -triple=x86_64 -dwarf-version=4 %s -o %t/test.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 -dwarf-version=4 %s -o %t/test.o -split-dwarf-file %t/test.dwo
# RUN: cd %t
# RUN: llvm-symbolizer --verbose 0x0 --obj=test.o | FileCheck --check-prefix=SYM %s
# RUN: llvm-dwarfdump -lookup=0x1 test.o | FileCheck --check-prefix=LOOKUP %s
# SYM: Filename: .{{[/\\]}}.{{[/\\]}}./test.h
-# SYM: Function start filename: .{{[/\\]}}test.cpp
+# SYM: Function start filename: .{{[/\\]}}.{{[/\\]}}test.cpp
# LOOKUP: Line info: line 0, column 0, start file 'test.cpp', start line 1
@@ -75,7 +75,7 @@ _Z2f1v: # @_Z2f1v
.Lskel_string0:
.asciz "." # string offset=0
.Lskel_string1:
- .asciz "test.o" # string offset=2
+ .asciz "test.dwo" # string offset=2
.section .debug_str.dwo,"eMS", at progbits,1
.Linfo_string0:
.asciz "_Z2f1v" # string offset=0
@@ -88,7 +88,7 @@ _Z2f1v: # @_Z2f1v
.Linfo_string4:
.asciz "test.cpp" # string offset=115
.Linfo_string5:
- .asciz "test.o" # string offset=124
+ .asciz "test.dwo" # string offset=124
.section .debug_str_offsets.dwo,"e", at progbits
.long 0
.long 7
diff --git a/llvm/test/DebugInfo/X86/symbolize_function_start_v5.s b/llvm/test/DebugInfo/X86/symbolize_function_start_v5.s
new file mode 100644
index 000000000000..f7c6a6c7ef34
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/symbolize_function_start_v5.s
@@ -0,0 +1,202 @@
+# RUN: rm -rf %t
+# RUN: mkdir %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 -dwarf-version=4 %s -o %t/test.o -split-dwarf-file %t/test.dwo
+# RUN: cd %t
+# RUN: llvm-symbolizer --verbose 0x0 --obj=test.o | FileCheck --check-prefix=SYM %s
+# RUN: llvm-dwarfdump -lookup=0x1 test.o | FileCheck --check-prefix=LOOKUP %s
+
+# SYM: Filename: .{{[/\\]}}.{{[/\\]}}test.c
+# SYM: Function start filename: .{{[/\\]}}.{{[/\\]}}test.c
+
+# LOOKUP: Line info: line 0, column 0, start file 'test.c', start line 1
+
+ .text
+ .file "test.c"
+ .globl f1 # -- Begin function f1
+ .p2align 4, 0x90
+ .type f1, at function
+f1: # @f1
+.Lfunc_begin0:
+ .file 0 "./" "test.c" md5 0xde4c8c8bd673cd6151beb4570168727a
+ .loc 0 1 0 # test.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
+.Ltmp0:
+ .loc 0 1 13 prologue_end # test.c:1:13
+ popq %rbp
+ .cfi_def_cfa %rsp, 8
+ retq
+.Ltmp1:
+.Lfunc_end0:
+ .size f1, .Lfunc_end0-f1
+ .cfi_endproc
+ # -- End function
+ .section .debug_abbrev,"", at progbits
+ .byte 1 # Abbreviation Code
+ .byte 74 # DW_TAG_skeleton_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 114 # DW_AT_str_offsets_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 27 # DW_AT_comp_dir
+ .byte 37 # DW_FORM_strx1
+ .ascii "\264B" # DW_AT_GNU_pubnames
+ .byte 25 # DW_FORM_flag_present
+ .byte 118 # DW_AT_dwo_name
+ .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 0 # EOM(3)
+ .section .debug_info,"", at progbits
+.Lcu_begin0:
+ .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+ .short 5 # DWARF version number
+ .byte 4 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .quad -2320906069171721424
+ .byte 1 # Abbrev [1] 0x14:0x14 DW_TAG_skeleton_unit
+ .long .Lline_table_start0 # DW_AT_stmt_list
+ .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
+ .byte 0 # DW_AT_comp_dir
+ # DW_AT_GNU_pubnames
+ .byte 1 # DW_AT_dwo_name
+ .byte 0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .long .Laddr_table_base0 # DW_AT_addr_base
+.Ldebug_info_end0:
+ .section .debug_str_offsets,"", at progbits
+ .long 12 # Length of String Offsets Set
+ .short 5
+ .short 0
+.Lstr_offsets_base0:
+ .section .debug_str,"MS", at progbits,1
+.Lskel_string0:
+ .asciz "./" # string offset=0
+.Lskel_string1:
+ .asciz "./test.dwo" # string offset=3
+ .section .debug_str_offsets,"", at progbits
+ .long .Lskel_string0
+ .long .Lskel_string1
+ .section .debug_str_offsets.dwo,"e", at progbits
+ .long 20 # Length of String Offsets Set
+ .short 5
+ .short 0
+ .section .debug_str.dwo,"eMS", at progbits,1
+.Linfo_string0:
+ .asciz "f1" # string offset=0
+.Linfo_string1:
+ .asciz "clang version 14.0.0 (git at github.com:llvm/llvm-project.git e7fdff403e849b18d93cd4a5cb760cba66a92c0b)" # string offset=3
+.Linfo_string2:
+ .asciz "test.c" # string offset=104
+.Linfo_string3:
+ .asciz "./test.dwo" # string offset=111
+ .section .debug_str_offsets.dwo,"e", at progbits
+ .long 0
+ .long 3
+ .long 104
+ .long 111
+ .section .debug_info.dwo,"e", at progbits
+ .long .Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit
+.Ldebug_info_dwo_start0:
+ .short 5 # DWARF version number
+ .byte 5 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long 0 # Offset Into Abbrev. Section
+ .quad -2320906069171721424
+ .byte 1 # Abbrev [1] 0x14:0x12 DW_TAG_compile_unit
+ .byte 1 # DW_AT_producer
+ .short 12 # DW_AT_language
+ .byte 2 # DW_AT_name
+ .byte 3 # DW_AT_dwo_name
+ .byte 2 # Abbrev [2] 0x1a:0xb DW_TAG_subprogram
+ .byte 0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 86
+ .byte 0 # DW_AT_name
+ .byte 0 # DW_AT_decl_file
+ .byte 1 # DW_AT_decl_line
+ # DW_AT_external
+ .byte 0 # End Of Children Mark
+.Ldebug_info_dwo_end0:
+ .section .debug_abbrev.dwo,"e", at progbits
+ .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
+ .byte 118 # DW_AT_dwo_name
+ .byte 37 # DW_FORM_strx1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 17 # DW_AT_low_pc
+ .byte 27 # DW_FORM_addrx
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .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 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_addr,"", at progbits
+ .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.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:
+ .section .debug_gnu_pubnames,"", at 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 40 # Compilation Unit Length
+ .long 26 # DIE offset
+ .byte 48 # Attributes: FUNCTION, EXTERNAL
+ .asciz "f1" # External Name
+ .long 0 # End Mark
+.LpubNames_end0:
+ .section .debug_gnu_pubtypes,"", at 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 40 # Compilation Unit Length
+ .long 0 # End Mark
+.LpubTypes_end0:
+ .ident "clang version 14.0.0 (git at github.com:llvm/llvm-project.git e7fdff403e849b18d93cd4a5cb760cba66a92c0b)"
+ .section ".note.GNU-stack","", at progbits
+ .addrsig
+ .section .debug_line,"", at progbits
+.Lline_table_start0:
More information about the llvm-commits
mailing list