• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Test location list handling, including the cases of invalid input. The exact
2# behavior in the invalid cases is not particularly important, but it should be
3# "reasonable".
4
5# REQUIRES: x86
6# UNSUPPORTED: lldb-repro
7
8# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym LOC=0 > %t
9# RUN: %lldb %t -o "image lookup -v -a 0" -o "image lookup -v -a 2" \
10# RUN:   -o "image dump symfile" -o exit | FileCheck %s
11
12# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym LOCLISTS=0 > %t
13# RUN: %lldb %t -o "image lookup -v -a 0" -o "image lookup -v -a 2" \
14# RUN:   -o "image dump symfile" -o exit | FileCheck %s --check-prefix=CHECK --check-prefix=LOCLISTS
15
16# CHECK-LABEL: image lookup -v -a 0
17# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = DW_OP_reg5 RDI,
18# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = ,
19
20# CHECK-LABEL: image lookup -v -a 2
21# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = DW_OP_reg0 RAX,
22# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = ,
23# CHECK: Variable: {{.*}}, name = "x3", type = "int", location = DW_OP_reg1 RDX,
24
25# CHECK-LABEL: image dump symfile
26# CHECK: CompileUnit{0x00000000}
27# CHECK:   Function{
28# CHECK:     Variable{{.*}}, name = "x0", {{.*}}, scope = parameter, location =
29# CHECK-NEXT:  [0x0000000000000000, 0x0000000000000001): DW_OP_reg5 RDI
30# CHECK-NEXT:  [0x0000000000000001, 0x0000000000000006): DW_OP_reg0 RAX
31# CHECK:     Variable{{.*}}, name = "x1", {{.*}}, scope = parameter
32# CHECK:     Variable{{.*}}, name = "x2", {{.*}}, scope = parameter, location = 0x00000000: error: unexpected end of data
33# CHECK:     Variable{{.*}}, name = "x3", {{.*}}, scope = parameter, location =
34# CHECK-NEXT:  [0x0000000000000002, 0x0000000000000003): DW_OP_reg1 RDX
35# LOCLISTS:  Variable{{.*}}, name = "x4", {{.*}}, scope = parameter, location =
36# LOCLISTS-NEXT: DW_LLE_startx_length   (0x000000000000dead, 0x0000000000000001): DW_OP_reg2 RCX
37
38.ifdef LOC
39.macro OFFSET_PAIR lo hi
40        .quad \lo
41        .quad \hi
42.endm
43
44.macro BASE_ADDRESS base
45        .quad -1
46        .quad \base
47.endm
48
49.macro EXPR_SIZE sz
50        .short \sz
51.endm
52
53.macro END_OF_LIST
54        .quad 0
55        .quad 0
56.endm
57.endif
58
59.ifdef LOCLISTS
60.macro OFFSET_PAIR lo hi
61        .byte   4                       # DW_LLE_offset_pair
62        .uleb128 \lo
63        .uleb128 \hi
64.endm
65
66.macro BASE_ADDRESS base
67        .byte   6                       # DW_LLE_base_address
68        .quad \base
69.endm
70
71.macro EXPR_SIZE sz
72        .uleb128 \sz
73.endm
74
75.macro END_OF_LIST
76        .byte   0                       # DW_LLE_end_of_list
77.endm
78.endif
79
80        .type   f,@function
81f:                                      # @f
82.Lfunc_begin0:
83        nop
84.Ltmp0:
85        nop
86.Ltmp1:
87        nop
88.Ltmp2:
89        nop
90.Ltmp3:
91        nop
92.Ltmp4:
93        nop
94.Lfunc_end0:
95        .size   f, .Lfunc_end0-f
96
97        .section        .debug_str,"MS",@progbits,1
98.Linfo_string0:
99        .asciz  "Hand-written DWARF"
100.Linfo_string3:
101        .asciz  "f"
102.Linfo_string4:
103        .asciz  "int"
104
105.ifdef LOC
106        .section        .debug_loc,"",@progbits
107.endif
108.ifdef LOCLISTS
109        .section        .debug_loclists,"",@progbits
110        .long   .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
111.Ldebug_loclist_table_start0:
112        .short  5                       # Version
113        .byte   8                       # Address size
114        .byte   0                       # Segment selector size
115        .long   0                       # Offset entry count
116.endif
117.Ldebug_loc0:
118        OFFSET_PAIR .Lfunc_begin0-.Lfunc_begin0, .Ltmp0-.Lfunc_begin0
119        EXPR_SIZE 1
120        .byte   85                      # super-register DW_OP_reg5
121        OFFSET_PAIR   .Ltmp0-.Lfunc_begin0, .Lfunc_end0-.Lfunc_begin0
122        EXPR_SIZE 1
123        .byte   80                      # super-register DW_OP_reg0
124        END_OF_LIST
125
126.Ldebug_loc3:
127        BASE_ADDRESS .Ltmp1
128        OFFSET_PAIR .Ltmp1-.Ltmp1, .Ltmp2-.Ltmp1
129        EXPR_SIZE 1
130        .byte   81                      # super-register DW_OP_reg1
131        END_OF_LIST
132
133.ifdef LOCLISTS
134.Ldebug_loc4:
135        .byte   3                       # DW_LLE_startx_length
136        .uleb128 0xdead
137        .uleb128 1
138        EXPR_SIZE 1
139        .byte   82                      # super-register DW_OP_reg2
140        END_OF_LIST
141.endif
142
143.Ldebug_loc2:
144        OFFSET_PAIR .Lfunc_begin0-.Lfunc_begin0, .Lfunc_end0-.Lfunc_begin0
145        EXPR_SIZE  0xdead
146.Ldebug_loclist_table_end0:
147
148        .section        .debug_abbrev,"",@progbits
149        .byte   1                       # Abbreviation Code
150        .byte   17                      # DW_TAG_compile_unit
151        .byte   1                       # DW_CHILDREN_yes
152        .byte   37                      # DW_AT_producer
153        .byte   14                      # DW_FORM_strp
154        .byte   19                      # DW_AT_language
155        .byte   5                       # DW_FORM_data2
156        .byte   17                      # DW_AT_low_pc
157        .byte   1                       # DW_FORM_addr
158        .byte   18                      # DW_AT_high_pc
159        .byte   6                       # DW_FORM_data4
160        .byte   0                       # EOM(1)
161        .byte   0                       # EOM(2)
162        .byte   2                       # Abbreviation Code
163        .byte   46                      # DW_TAG_subprogram
164        .byte   1                       # DW_CHILDREN_yes
165        .byte   17                      # DW_AT_low_pc
166        .byte   1                       # DW_FORM_addr
167        .byte   18                      # DW_AT_high_pc
168        .byte   6                       # DW_FORM_data4
169        .byte   3                       # DW_AT_name
170        .byte   14                      # DW_FORM_strp
171        .byte   73                      # DW_AT_type
172        .byte   19                      # DW_FORM_ref4
173        .byte   0                       # EOM(1)
174        .byte   0                       # EOM(2)
175        .byte   3                       # Abbreviation Code
176        .byte   5                       # DW_TAG_formal_parameter
177        .byte   0                       # DW_CHILDREN_no
178        .byte   2                       # DW_AT_location
179        .byte   23                      # DW_FORM_sec_offset
180        .byte   3                       # DW_AT_name
181        .byte   8                       # DW_FORM_string
182        .byte   73                      # DW_AT_type
183        .byte   19                      # DW_FORM_ref4
184        .byte   0                       # EOM(1)
185        .byte   0                       # EOM(2)
186        .byte   4                       # Abbreviation Code
187        .byte   36                      # DW_TAG_base_type
188        .byte   0                       # DW_CHILDREN_no
189        .byte   3                       # DW_AT_name
190        .byte   14                      # DW_FORM_strp
191        .byte   62                      # DW_AT_encoding
192        .byte   11                      # DW_FORM_data1
193        .byte   11                      # DW_AT_byte_size
194        .byte   11                      # DW_FORM_data1
195        .byte   0                       # EOM(1)
196        .byte   0                       # EOM(2)
197        .byte   0                       # EOM(3)
198
199        .section        .debug_info,"",@progbits
200.Lcu_begin0:
201        .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
202.Ldebug_info_start0:
203.ifdef LOC
204        .short  4                       # DWARF version number
205        .long   .debug_abbrev           # Offset Into Abbrev. Section
206        .byte   8                       # Address Size (in bytes)
207.endif
208.ifdef LOCLISTS
209        .short  5                       # DWARF version number
210        .byte   1                       # DWARF Unit Type
211        .byte   8                       # Address Size (in bytes)
212        .long   .debug_abbrev           # Offset Into Abbrev. Section
213.endif
214        .byte   1                       # Abbrev [1] 0xb:0x50 DW_TAG_compile_unit
215        .long   .Linfo_string0          # DW_AT_producer
216        .short  12                      # DW_AT_language
217        .quad   .Lfunc_begin0           # DW_AT_low_pc
218        .long   .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
219        .byte   2                       # Abbrev [2] 0x2a:0x29 DW_TAG_subprogram
220        .quad   .Lfunc_begin0           # DW_AT_low_pc
221        .long   .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
222        .long   .Linfo_string3          # DW_AT_name
223        .long   .Lint                   # DW_AT_type
224        .byte   3                       # Abbrev [3] DW_TAG_formal_parameter
225        .long   .Ldebug_loc0            # DW_AT_location
226        .asciz  "x0"                    # DW_AT_name
227        .long   .Lint-.Lcu_begin0       # DW_AT_type
228        .byte   3                       # Abbrev [3] DW_TAG_formal_parameter
229        .long   0xdeadbeef              # DW_AT_location
230        .asciz  "x1"                    # DW_AT_name
231        .long   .Lint-.Lcu_begin0       # DW_AT_type
232        .byte   3                       # Abbrev [3] DW_TAG_formal_parameter
233        .long   .Ldebug_loc2            # DW_AT_location
234        .asciz  "x2"                    # DW_AT_name
235        .long   .Lint-.Lcu_begin0       # DW_AT_type
236        .byte   3                       # Abbrev [3] DW_TAG_formal_parameter
237        .long   .Ldebug_loc3            # DW_AT_location
238        .asciz  "x3"                    # DW_AT_name
239        .long   .Lint-.Lcu_begin0       # DW_AT_type
240.ifdef LOCLISTS
241        .byte   3                       # Abbrev [3] DW_TAG_formal_parameter
242        .long   .Ldebug_loc4            # DW_AT_location
243        .asciz  "x4"                    # DW_AT_name
244        .long   .Lint-.Lcu_begin0       # DW_AT_type
245.endif
246        .byte   0                       # End Of Children Mark
247.Lint:
248        .byte   4                       # Abbrev [4] 0x53:0x7 DW_TAG_base_type
249        .long   .Linfo_string4          # DW_AT_name
250        .byte   5                       # DW_AT_encoding
251        .byte   4                       # DW_AT_byte_size
252        .byte   0                       # End Of Children Mark
253.Ldebug_info_end0:
254