Skip to content

Commit 7ec7876

Browse files
committed
[lldb] Fix handling of DW_AT_decl_file according to D91014
Apply changes from https://reviews.llvm.org/D91014 to other places where DWARF entries are being processed. Differential Revision: https://reviews.llvm.org/D96778
1 parent 925093d commit 7ec7876

File tree

4 files changed

+334
-3
lines changed

4 files changed

+334
-3
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
22012201
case DW_AT_description:
22022202
default:
22032203
case DW_AT_decl_file:
2204-
decl.SetFile(die.GetCU()->GetFile(form_value.Unsigned()));
2204+
decl.SetFile(attributes.CompileUnitAtIndex(i)->GetFile(
2205+
form_value.Unsigned()));
22052206
break;
22062207
case DW_AT_decl_line:
22072208
decl.SetLine(form_value.Unsigned());

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,8 +3126,8 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
31263126
continue;
31273127
switch (attr) {
31283128
case DW_AT_decl_file:
3129-
decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
3130-
form_value.Unsigned()));
3129+
decl.SetFile(
3130+
attributes.CompileUnitAtIndex(i)->GetFile(form_value.Unsigned()));
31313131
break;
31323132
case DW_AT_decl_line:
31333133
decl.SetLine(form_value.Unsigned());
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Check that DW_AT_decl_file of DW_AT_variable which is inherited by
2+
# DW_AT_abstract_origin from a different DW_TAG_compile_unit is using the
3+
# DW_TAG_compile_unit->DW_AT_stmt_list where the DW_AT_decl_file is located (and
4+
# not where the DW_AT_abstract_origin is located).
5+
# DW_TAG_variable in CU 1 is using DW_AT_decl_file 3.
6+
# CU 1 has files:
7+
# file_names[ 1]: name: "inlinevarother.h"
8+
# file_names[ 2]: name: "inlinevar1.c"
9+
# file_names[ 3]: name: "inlinevar.h"
10+
# CU 2 has files:
11+
# file_names[ 1]: name: "inlinevar2.c"
12+
# file_names[ 2]: name: "inlinevar.h"
13+
14+
# REQUIRES: x86
15+
16+
// RUN: %clang -o %t --target=x86_64-pc-linux %s \
17+
// RUN: %S/Inputs/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu2.s
18+
19+
# RUN: %lldb %t \
20+
# RUN: -o 'b other' -o r -o disas -o 'frame variable --show-declaration' \
21+
# RUN: -o exit | FileCheck %s
22+
23+
# CHECK: inlinevar.h:2: (int) var = {{.*}}
24+
# Unfixed LLDB did show only: (int) var = {{.*}}
25+
26+
.text
27+
.file "inlinevar1.c"
28+
.file 1 "" "./inlinevarother.h"
29+
.globl main # -- Begin function main
30+
.type main,@function
31+
main: # @main
32+
.Lfunc_begin1:
33+
.file 2 "" "inlinevar1.c"
34+
.loc 2 4 0 # inlinevar1.c:4:0
35+
.Ltmp2:
36+
.file 3 "" "./inlinevar.h"
37+
.loc 3 2 16 prologue_end # ./inlinevar.h:2:16
38+
movl $42, %eax
39+
pushq %rax
40+
.loc 3 3 10 # ./inlinevar.h:3:10
41+
.Ltmp3:
42+
.loc 2 5 20 # inlinevar1.c:5:20
43+
callq other
44+
popq %rcx
45+
.loc 2 5 19 # inlinevar1.c:5:19
46+
addl %ecx, %eax
47+
.loc 2 5 3 # inlinevar1.c:5:3
48+
retq
49+
.Ltmp4:
50+
.Lfunc_end1:
51+
.size main, .Lfunc_end1-main
52+
# -- End function
53+
.section .debug_abbrev,"",@progbits
54+
.byte 1 # Abbreviation Code
55+
.byte 17 # DW_TAG_compile_unit
56+
.byte 1 # DW_CHILDREN_yes
57+
.byte 37 # DW_AT_producer
58+
.byte 14 # DW_FORM_strp
59+
.byte 19 # DW_AT_language
60+
.byte 5 # DW_FORM_data2
61+
.byte 3 # DW_AT_name
62+
.byte 14 # DW_FORM_strp
63+
.byte 16 # DW_AT_stmt_list
64+
.byte 23 # DW_FORM_sec_offset
65+
.byte 27 # DW_AT_comp_dir
66+
.byte 14 # DW_FORM_strp
67+
.byte 17 # DW_AT_low_pc
68+
.byte 1 # DW_FORM_addr
69+
.byte 18 # DW_AT_high_pc
70+
.byte 6 # DW_FORM_data4
71+
.byte 0 # EOM(1)
72+
.byte 0 # EOM(2)
73+
.byte 3 # Abbreviation Code
74+
.byte 46 # DW_TAG_subprogram
75+
.byte 1 # DW_CHILDREN_yes
76+
.byte 3 # DW_AT_name
77+
.byte 14 # DW_FORM_strp
78+
.byte 58 # DW_AT_decl_file
79+
.byte 11 # DW_FORM_data1
80+
.byte 59 # DW_AT_decl_line
81+
.byte 11 # DW_FORM_data1
82+
.byte 73 # DW_AT_type
83+
.byte 19 # DW_FORM_ref4
84+
.byte 32 # DW_AT_inline
85+
.byte 11 # DW_FORM_data1
86+
.byte 0 # EOM(1)
87+
.byte 0 # EOM(2)
88+
.byte 4 # Abbreviation Code
89+
.byte 52 # DW_TAG_variable
90+
.byte 0 # DW_CHILDREN_no
91+
.byte 3 # DW_AT_name
92+
.byte 14 # DW_FORM_strp
93+
.byte 58 # DW_AT_decl_file
94+
.byte 11 # DW_FORM_data1
95+
.byte 59 # DW_AT_decl_line
96+
.byte 11 # DW_FORM_data1
97+
.byte 73 # DW_AT_type
98+
.byte 19 # DW_FORM_ref4
99+
.byte 0 # EOM(1)
100+
.byte 0 # EOM(2)
101+
.byte 5 # Abbreviation Code
102+
.byte 36 # DW_TAG_base_type
103+
.byte 0 # DW_CHILDREN_no
104+
.byte 3 # DW_AT_name
105+
.byte 14 # DW_FORM_strp
106+
.byte 62 # DW_AT_encoding
107+
.byte 11 # DW_FORM_data1
108+
.byte 11 # DW_AT_byte_size
109+
.byte 11 # DW_FORM_data1
110+
.byte 0 # EOM(1)
111+
.byte 0 # EOM(2)
112+
.byte 0 # EOM(3)
113+
.section .debug_info,"",@progbits
114+
.Lcu_begin0:
115+
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
116+
.Ldebug_info_start0:
117+
.short 4 # DWARF version number
118+
.long .debug_abbrev # Offset Into Abbrev. Section
119+
.byte 8 # Address Size (in bytes)
120+
.byte 1 # Abbrev [1] DW_TAG_compile_unit
121+
.long .Linfo_string0 # DW_AT_producer
122+
.short 0xc # DW_AT_language
123+
.long .Linfo_string1 # DW_AT_name
124+
.long .Lline_table_start0 # DW_AT_stmt_list
125+
.long .Linfo_string2 # DW_AT_comp_dir
126+
.quad .Lfunc_begin1 # DW_AT_low_pc
127+
.long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
128+
.globl debuginfo_func_inlined
129+
debuginfo_func_inlined:
130+
.Lfunc_inlined:
131+
.byte 3 # Abbrev [3] DW_TAG_subprogram
132+
.long .Linfo_string4 # DW_AT_name
133+
.byte 3 # DW_AT_decl_file
134+
.byte 1 # DW_AT_decl_line
135+
.long .Ltype_int-.Lcu_begin0 # DW_AT_type
136+
.byte 1 # DW_AT_inline
137+
.globl debuginfo_var_var
138+
debuginfo_var_var:
139+
.Lvar_var:
140+
.byte 4 # Abbrev [4] DW_TAG_variable
141+
.long .Linfo_string6 # DW_AT_name
142+
.byte 3 # DW_AT_decl_file
143+
.byte 2 # DW_AT_decl_line
144+
.long .Ltype_int-.Lcu_begin0 # DW_AT_type
145+
.byte 0 # End Of Children Mark
146+
.Ltype_int:
147+
.byte 5 # Abbrev [5] DW_TAG_base_type
148+
.long .Linfo_string5 # DW_AT_name
149+
.byte 5 # DW_AT_encoding
150+
.byte 4 # DW_AT_byte_size
151+
.byte 0 # End Of Children Mark
152+
.Ldebug_info_end0:
153+
.section .debug_str,"MS",@progbits,1
154+
.Linfo_string0:
155+
.asciz "clang version 11.0.0 + hand coding"
156+
.Linfo_string1:
157+
.asciz "inlinevar1.c"
158+
.Linfo_string2:
159+
.asciz ""
160+
.Linfo_string4:
161+
.asciz "inlined"
162+
.Linfo_string5:
163+
.asciz "int"
164+
.Linfo_string6:
165+
.asciz "var"
166+
.section ".note.GNU-stack","",@progbits
167+
.addrsig
168+
.addrsig_sym other
169+
.section .debug_line,"",@progbits
170+
.Lline_table_start0:
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
.text
2+
.file "inlinevar2.c"
3+
.globl other # -- Begin function other
4+
.type other,@function
5+
other: # @other
6+
.Lfunc_begin0:
7+
.file 1 "" "inlinevar2.c"
8+
.loc 1 3 0 # inlinevar2.c:3:0
9+
.Ltmp0:
10+
.file 2 "" "./inlinevar.h"
11+
.loc 2 2 16 prologue_end # ./inlinevar.h:2:16
12+
movl $42, %eax
13+
.loc 2 3 10 # ./inlinevar.h:3:10
14+
.loc 1 3 41 # inlinevar2.c:3:41
15+
retq
16+
.Ltmp1:
17+
.Ltmp2:
18+
.Lfunc_end0:
19+
.size other, .Lfunc_end0-other
20+
# -- End function
21+
.section .debug_abbrev,"",@progbits
22+
.byte 1 # Abbreviation Code
23+
.byte 17 # DW_TAG_compile_unit
24+
.byte 1 # DW_CHILDREN_yes
25+
.byte 37 # DW_AT_producer
26+
.byte 14 # DW_FORM_strp
27+
.byte 19 # DW_AT_language
28+
.byte 5 # DW_FORM_data2
29+
.byte 3 # DW_AT_name
30+
.byte 14 # DW_FORM_strp
31+
.byte 16 # DW_AT_stmt_list
32+
.byte 23 # DW_FORM_sec_offset
33+
.byte 27 # DW_AT_comp_dir
34+
.byte 14 # DW_FORM_strp
35+
.byte 17 # DW_AT_low_pc
36+
.byte 1 # DW_FORM_addr
37+
.byte 18 # DW_AT_high_pc
38+
.byte 6 # DW_FORM_data4
39+
.byte 0 # EOM(1)
40+
.byte 0 # EOM(2)
41+
.byte 4 # Abbreviation Code
42+
.byte 36 # DW_TAG_base_type
43+
.byte 0 # DW_CHILDREN_no
44+
.byte 3 # DW_AT_name
45+
.byte 14 # DW_FORM_strp
46+
.byte 62 # DW_AT_encoding
47+
.byte 11 # DW_FORM_data1
48+
.byte 11 # DW_AT_byte_size
49+
.byte 11 # DW_FORM_data1
50+
.byte 0 # EOM(1)
51+
.byte 0 # EOM(2)
52+
.byte 6 # Abbreviation Code
53+
.byte 46 # DW_TAG_subprogram
54+
.byte 1 # DW_CHILDREN_yes
55+
.byte 17 # DW_AT_low_pc
56+
.byte 1 # DW_FORM_addr
57+
.byte 18 # DW_AT_high_pc
58+
.byte 6 # DW_FORM_data4
59+
.byte 64 # DW_AT_frame_base
60+
.byte 24 # DW_FORM_exprloc
61+
.byte 3 # DW_AT_name
62+
.byte 14 # DW_FORM_strp
63+
.byte 58 # DW_AT_decl_file
64+
.byte 11 # DW_FORM_data1
65+
.byte 59 # DW_AT_decl_line
66+
.byte 11 # DW_FORM_data1
67+
.byte 73 # DW_AT_type
68+
.byte 19 # DW_FORM_ref4
69+
.byte 63 # DW_AT_external
70+
.byte 25 # DW_FORM_flag_present
71+
.byte 0 # EOM(1)
72+
.byte 0 # EOM(2)
73+
.byte 7 # Abbreviation Code
74+
.byte 29 # DW_TAG_inlined_subroutine
75+
.byte 1 # DW_CHILDREN_yes
76+
.byte 49 # DW_AT_abstract_origin
77+
.byte 0x10 # DW_FORM_ref_addr
78+
.byte 17 # DW_AT_low_pc
79+
.byte 1 # DW_FORM_addr
80+
.byte 18 # DW_AT_high_pc
81+
.byte 6 # DW_FORM_data4
82+
.byte 88 # DW_AT_call_file
83+
.byte 11 # DW_FORM_data1
84+
.byte 89 # DW_AT_call_line
85+
.byte 11 # DW_FORM_data1
86+
.byte 87 # DW_AT_call_column
87+
.byte 11 # DW_FORM_data1
88+
.byte 0 # EOM(1)
89+
.byte 0 # EOM(2)
90+
.byte 8 # Abbreviation Code
91+
.byte 52 # DW_TAG_variable
92+
.byte 0 # DW_CHILDREN_no
93+
.byte 2 # DW_AT_location
94+
.byte 24 # DW_FORM_exprloc
95+
.byte 49 # DW_AT_abstract_origin
96+
.byte 0x10 # DW_FORM_ref_addr
97+
.byte 0 # EOM(1)
98+
.byte 0 # EOM(2)
99+
.byte 0 # EOM(3)
100+
.section .debug_info,"",@progbits
101+
.Lcu_begin0:
102+
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
103+
.Ldebug_info_start0:
104+
.short 4 # DWARF version number
105+
.long .debug_abbrev # Offset Into Abbrev. Section
106+
.byte 8 # Address Size (in bytes)
107+
.byte 1 # Abbrev [1] DW_TAG_compile_unit
108+
.long .Linfo_string0 # DW_AT_producer
109+
.short 0xc # DW_AT_language
110+
.long .Linfo_string1 # DW_AT_name
111+
.long .Lline_table_start0 # DW_AT_stmt_list
112+
.long .Linfo_string2 # DW_AT_comp_dir
113+
.quad .Lfunc_begin0 # DW_AT_low_pc
114+
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
115+
.Ltype_int:
116+
.byte 4 # Abbrev [4] DW_TAG_base_type
117+
.long .Linfo_string5 # DW_AT_name
118+
.byte 5 # DW_AT_encoding
119+
.byte 4 # DW_AT_byte_size
120+
.byte 6 # Abbrev [6] DW_TAG_subprogram
121+
.quad .Lfunc_begin0 # DW_AT_low_pc
122+
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
123+
.byte 1 # DW_AT_frame_base
124+
.byte 86
125+
.long .Linfo_string8 # DW_AT_name
126+
.byte 1 # DW_AT_decl_file
127+
.byte 3 # DW_AT_decl_line
128+
.long .Ltype_int-.Lcu_begin0 # DW_AT_type
129+
# DW_AT_external
130+
.byte 7 # Abbrev [7] DW_TAG_inlined_subroutine
131+
.long debuginfo_func_inlined # DW_AT_abstract_origin
132+
.quad .Ltmp0 # DW_AT_low_pc
133+
.long .Ltmp1-.Ltmp0 # DW_AT_high_pc
134+
.byte 1 # DW_AT_call_file
135+
.byte 3 # DW_AT_call_line
136+
.byte 48 # DW_AT_call_column
137+
.byte 8 # Abbrev [8] DW_TAG_variable
138+
.byte 2 # DW_AT_location
139+
.byte 145
140+
.byte 124
141+
.long debuginfo_var_var # DW_AT_abstract_origin
142+
.byte 0 # End Of Children Mark
143+
.byte 0 # End Of Children Mark
144+
.byte 0 # End Of Children Mark
145+
.Ldebug_info_end0:
146+
.section .debug_str,"MS",@progbits,1
147+
.Linfo_string0:
148+
.asciz "clang version 11.0.0 + hand coding"
149+
.Linfo_string1:
150+
.asciz "inlinevar2.c"
151+
.Linfo_string2:
152+
.asciz ""
153+
.Linfo_string5:
154+
.asciz "int"
155+
.Linfo_string8:
156+
.asciz "other"
157+
.section ".note.GNU-stack","",@progbits
158+
.addrsig
159+
.section .debug_line,"",@progbits
160+
.Lline_table_start0:

0 commit comments

Comments
 (0)