xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp.s (revision b74a01a80b72f581c68d336b0de5ed9757efbaa8)
1# RUN: llvm-mc --filetype=obj --triple x86_64-pc-linux %s -o %t --defsym MAIN=0
2# RUN: llvm-mc --filetype=obj --triple x86_64-pc-linux %s -o %t.dwp --defsym DWP=0
3# RUN: %lldb %t -o "target variable A" -o "image lookup -v -n F1" -b | FileCheck %s
4# RUN: lldb-test symbols %t | FileCheck %s --check-prefix=SYMBOLS
5
6# CHECK-LABEL: target variable A
7# CHECK: (INT0) A = 0
8# CHECK: (INT1) A = 1
9# CHECK: (INT2) A = 2
10# CHECK: (INT3) A = 3
11
12# CHECK-LABEL: image lookup -v -n F1
13# CHECK: CompileUnit: id = {0x00000001}, file = "1.c", language = "unknown"
14# CHECK: Function: {{.*}}, name = "F1", range = [0x0000000000000001-0x0000000000000002)
15# CHECK: Variable: {{.*}}, name = "x", type = "int", valid ranges = <block>, location = [0x0000000000000001, 0x0000000000000002) -> DW_OP_reg1 RDX
16
17# SYMBOLS:      Compile units:
18# SYMBOLS-NEXT: CompileUnit{0x00000000}, language = "<not loaded>", file = '0.c'
19# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x0
20# SYMBOLS-NEXT:   Function{{.*}}, demangled = F0
21# SYMBOLS-NEXT:   Block{{.*}}, ranges = [0x00000000-0x00000001)
22# SYMBOLS-NEXT:     Variable{{.*}}, name = "x", {{.*}}, location =
23# SYMBOLS-NEXT:       [0x0000000000000000, 0x0000000000000001): DW_OP_reg0 RAX
24# SYMBOLS-EMPTY:
25# SYMBOLS-NEXT: CompileUnit{0x00000001}, language = "<not loaded>", file = '1.c'
26# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x2
27# SYMBOLS-NEXT:   Function{{.*}}, demangled = F1
28# SYMBOLS-NEXT:   Block{{.*}}, ranges = [0x00000001-0x00000002)
29# SYMBOLS-NEXT:     Variable{{.*}}, name = "x", {{.*}}, location =
30# SYMBOLS-NEXT:       [0x0000000000000001, 0x0000000000000002): DW_OP_reg1 RDX
31# SYMBOLS-EMPTY:
32# SYMBOLS-NEXT: CompileUnit{0x00000002}, language = "<not loaded>", file = '2.c'
33# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x4
34# SYMBOLS-NEXT:   Function{{.*}}, demangled = F2
35# SYMBOLS-NEXT:   Block{{.*}}, ranges = [0x00000002-0x00000003)
36# SYMBOLS-NEXT:     Variable{{.*}}, name = "x", {{.*}}, location =
37# SYMBOLS-NEXT:       [0x0000000000000002, 0x0000000000000003): DW_OP_reg2 RCX
38# SYMBOLS-EMPTY:
39# SYMBOLS-NEXT: CompileUnit{0x00000003}, language = "<not loaded>", file = '3.c'
40# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x6
41# SYMBOLS-NEXT:   Function{{.*}}, demangled = F3
42# SYMBOLS-NEXT:   Block{{.*}}, ranges = [0x00000003-0x00000004)
43# SYMBOLS-NEXT:     Variable{{.*}}, name = "x", {{.*}}, location =
44# SYMBOLS-NEXT:       [0x0000000000000003, 0x0000000000000004): DW_OP_reg3 RBX
45# SYMBOLS-EMPTY:
46# SYMBOLS-NEXT: CompileUnit{0x00000004}, language = "<not loaded>", file = ''
47# SYMBOLS-EMPTY:
48
49        .section        .debug_abbrev,"",@progbits
50        .byte   1                       # Abbreviation Code
51        .byte   17                      # DW_TAG_compile_unit
52        .byte   0                       # DW_CHILDREN_no
53        .ascii  "\260B"                 # DW_AT_GNU_dwo_name
54        .byte   8                       # DW_FORM_string
55        .ascii  "\261B"                 # DW_AT_GNU_dwo_id
56        .byte   7                       # DW_FORM_data8
57        .ascii  "\263B"                 # DW_AT_GNU_addr_base
58        .byte   23                      # DW_FORM_sec_offset
59        .byte   85                      # DW_AT_ranges
60        .byte   23                      # DW_FORM_sec_offset
61        .byte   0                       # EOM(1)
62        .byte   0                       # EOM(2)
63        .byte   0                       # EOM(3)
64
65.ifdef MAIN
66.irpc I,01234
67        .data
68A\I:
69        .long \I
70
71        .text
72F\I:
73        nop
74
75        .section        .debug_info,"",@progbits
76.Lcu_begin\I:
77        .long   .Ldebug_info_end\I-.Ldebug_info_start\I # Length of Unit
78.Ldebug_info_start\I:
79        .short  4                       # DWARF version number
80        .long   .debug_abbrev           # Offset Into Abbrev. Section
81        .byte   8                       # Address Size (in bytes)
82        .byte   1                       # Abbrev [1] 0xb:0x25 DW_TAG_compile_unit
83        .asciz  "A.dwo"                 # DW_AT_GNU_dwo_name
84        .quad   \I                      # DW_AT_GNU_dwo_id
85        .long   .debug_addr             # DW_AT_GNU_addr_base
86        .long   .Lranges\I              # DW_AT_ranges
87.Ldebug_info_end\I:
88
89        .section        .debug_addr,"",@progbits
90        .quad   A\I
91        .quad   F\I
92
93        .section        .debug_ranges,"",@progbits
94.Lranges\I:
95        .quad   F\I
96        .quad   F\I+1
97        .quad   0
98        .quad   0
99.endr
100.endif
101
102.ifdef DWP
103# This deliberately excludes compile unit 4 to check test the case of a missing
104# split unit.
105.irpc I,0123
106        .section        .debug_str.dwo,"MSe",@progbits,1
107.Lstr\I:
108        .byte   'I', 'N', 'T', '0'+\I, 0
109
110        .section        .debug_str_offsets.dwo,"e",@progbits
111.Lstr_offsets\I:
112        .long   .Lstr\I-.debug_str.dwo
113.Lstr_offsets_end\I:
114
115        .section        .debug_loc.dwo,"e",@progbits
116.Lloc\I:
117        .byte   3                       # DW_LLE_startx_length
118        .uleb128 \I*2+1
119        .long   1
120        .short 1                      # Expression size
121        .byte   80+\I                   # super-register DW_OP_reg0+\I
122        .byte   0                       # DW_LLE_end_of_list
123.Lloc_end\I:
124
125        .section        .debug_abbrev.dwo,"e",@progbits
126.Labbrev\I:
127        .byte   \I*10+1                 # Abbreviation Code
128        .byte   17                      # DW_TAG_compile_unit
129        .byte   1                       # DW_CHILDREN_yes
130        .byte   37                      # DW_AT_producer
131        .byte   8                       # DW_FORM_string
132        .byte   3                       # DW_AT_name
133        .byte   8                       # DW_FORM_string
134        .byte   0                       # EOM(1)
135        .byte   0                       # EOM(2)
136        .byte   \I*10+2                 # Abbreviation Code
137        .byte   52                      # DW_TAG_variable
138        .byte   0                       # DW_CHILDREN_no
139        .byte   3                       # DW_AT_name
140        .byte   8                       # DW_FORM_string
141        .byte   73                      # DW_AT_type
142        .byte   19                      # DW_FORM_ref4
143        .byte   2                       # DW_AT_location
144        .byte   24                      # DW_FORM_exprloc
145        .byte   0                       # EOM(1)
146        .byte   0                       # EOM(2)
147        .byte   \I*10+3                 # Abbreviation Code
148        .byte   36                      # DW_TAG_base_type
149        .byte   0                       # DW_CHILDREN_no
150        .byte   3                       # DW_AT_name
151        .byte   8                       # DW_FORM_string
152        .byte   62                      # DW_AT_encoding
153        .byte   11                      # DW_FORM_data1
154        .byte   11                      # DW_AT_byte_size
155        .byte   11                      # DW_FORM_data1
156        .byte   0                       # EOM(1)
157        .byte   0                       # EOM(2)
158        .byte   \I*10+4                 # Abbreviation Code
159        .byte   22                      # DW_TAG_typedef
160        .byte   0                       # DW_CHILDREN_no
161        .byte   3                       # DW_AT_name
162        .uleb128 0x1f02                 # DW_FORM_GNU_str_index
163        .byte   73                      # DW_AT_type
164        .byte   19                      # DW_FORM_ref4
165        .byte   0                       # EOM(1)
166        .byte   0                       # EOM(2)
167        .byte   \I*10+5                 # Abbreviation Code
168        .byte   46                      # DW_TAG_subprogram
169        .byte   1                       # DW_CHILDREN_yes
170        .byte   17                      # DW_AT_low_pc
171        .uleb128 0x1f01                 # DW_FORM_GNU_addr_index
172        .byte   18                      # DW_AT_high_pc
173        .byte   11                      # DW_FORM_data1
174        .byte   3                       # DW_AT_name
175        .byte   8                       # DW_FORM_string
176        .byte   0                       # EOM(1)
177        .byte   0                       # EOM(2)
178        .byte   \I*10+6                 # Abbreviation Code
179        .byte   5                       # DW_TAG_formal_parameter
180        .byte   0                       # DW_CHILDREN_no
181        .byte   2                       # DW_AT_location
182        .byte   23                      # DW_FORM_sec_offset
183        .byte   3                       # DW_AT_name
184        .byte   8                       # DW_FORM_string
185        .byte   73                      # DW_AT_type
186        .byte   19                      # DW_FORM_ref4
187        .byte   0                       # EOM(1)
188        .byte   0                       # EOM(2)
189        .byte   0                       # EOM(3)
190.Labbrev_end\I:
191
192        .section        .debug_info.dwo,"e",@progbits
193.Lcu_begin\I:
194        .long   .Ldebug_info_end\I-.Ldebug_info_start\I # Length of Unit
195.Ldebug_info_start\I:
196        .short  4                       # DWARF version number
197        .long   0                       # Offset Into Abbrev. Section
198        .byte   8                       # Address Size (in bytes)
199        .byte   \I*10+1                 # Abbrev DW_TAG_compile_unit
200        .asciz  "Hand-written DWARF"    # DW_AT_producer
201        .byte   '0'+\I, '.', 'c', 0     # DW_AT_name
202        .byte   \I*10+2                 # Abbrev DW_TAG_variable
203        .asciz  "A"                     # DW_AT_name
204        .long   .Ltypedef\I-.Lcu_begin\I# DW_AT_type
205        .byte   2                       # DW_AT_location
206        .byte   0xfb                    # DW_OP_GNU_addr_index
207        .byte   \I*2
208.Ltypedef\I:
209        .byte   \I*10+4                 # Abbrev DW_TAG_typedef
210        .byte   0                       # DW_AT_name
211        .long   .Ltype\I-.Lcu_begin\I   # DW_AT_type
212.Ltype\I:
213        .byte   \I*10+3                 # Abbrev DW_TAG_base_type
214        .asciz  "int"                   # DW_AT_name
215        .byte   5                       # DW_AT_encoding
216        .byte   4                       # DW_AT_byte_size
217
218        .byte   \I*10+5                 # Abbrev DW_TAG_subprogram
219        .uleb128 \I*2+1                 # DW_AT_low_pc
220        .byte   1                       # DW_AT_high_pc
221        .byte   'F', '0'+\I, 0          # DW_AT_name
222
223        .byte   \I*10+6                 # Abbrev DW_TAG_formal_parameter
224        .long   0                       # DW_AT_location
225        .asciz  "x"                     # DW_AT_name
226        .long   .Ltype\I-.Lcu_begin\I   # DW_AT_type
227
228        .byte   0                       # End Of Children Mark
229        .byte   0                       # End Of Children Mark
230.Ldebug_info_end\I:
231.endr
232
233        .section        .debug_cu_index,"",@progbits
234        .short  2                       # DWARF version number
235        .short  0                       # Reserved
236        .long   4                       # Section count
237        .long   4                       # Unit count
238        .long   8                       # Slot count
239
240        .quad   0, 1, 2, 3, 0, 0, 0, 0  # Hash table
241        .long   1, 2, 3, 4, 0, 0, 0, 0  # Index table
242
243        .long   1                       # DW_SECT_INFO
244        .long   3                       # DW_SECT_ABBREV
245        .long   5                       # DW_SECT_LOC
246        .long   6                       # DW_SECT_STR_OFFSETS
247
248.irpc I,0123
249        .long .Lcu_begin\I-.debug_info.dwo
250        .long .Labbrev\I-.debug_abbrev.dwo
251        .long .Lloc\I-.debug_loc.dwo
252        .long .Lstr_offsets\I-.debug_str_offsets.dwo
253.endr
254.irpc I,0123
255        .long .Ldebug_info_end\I-.Lcu_begin\I
256        .long .Labbrev_end\I-.Labbrev\I
257        .long .Lloc_end\I-.Lloc\I
258        .long .Lstr_offsets_end\I-.Lstr_offsets\I
259.endr
260
261.endif
262