Recommit "rL366894: [yaml2obj] - Allow custom fields for the SHT_UNDEF sections."
[llvm-complete.git] / test / tools / llvm-symbolizer / only-empty-ranges.s
blobd28f2c996e86b93906e09949f435b0cc28196b8c
1 # REQUIRES: x86-registered-target
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3 # RUN: llvm-symbolizer 0x0 0x2 0x3 0x4 --obj=%t.o | FileCheck %s
4 # This test makes sure we don't attempt to access out of the line table boundaries
5 # if the last range is empty.
6 # Produced from the following program:
7 # int func(int a) {
8 # return 1 + a;
9 # }
10 # compiled with clang -O3 -g -S
11 # Edited by adding a redundant, empty last range.
12 # The line table (llvm-dwarfdump --debug-line) looks like:
14 # Address Line Column File ISA Discriminator Flags
15 # ------------------ ------ ------ ------ --- ------------- -------------
16 # 0x0000000000000000 1 0 1 0 0 is_stmt
17 # 0x0000000000000000 2 12 1 0 0 is_stmt prologue_end
18 # 0x0000000000000003 2 3 1 0 0
19 # 0x0000000000000003 3 3 1 0 0
20 # 0x0000000000000004 3 3 1 0 0 end_sequence
22 # 0x0 should pick the second line in the table - line 2, col 12
23 # CHECK: func
24 # CHECK: /scratch/a.cpp:2:12
25 # 0x2 does not exist in the table, so we should pick the line with a
26 # lower address that describes the range - in this case, the second line.
27 # CHECK: func
28 # CHECK: /scratch/a.cpp:2:12
29 # 0x3 also has a sequence of empty ranges, so we should pick the first range after
30 # skipping the empty ones.
31 # This also verifies we don't attempt to access outside boundaries.
32 # CHECK: func
33 # CHECK: /scratch/a.cpp:3:3
34 # CHECK: ??
35 # CHECK: ??:0:0
37 .text
38 .file "a.cpp"
39 .globl _Z4funci # -- Begin function _Z4funci
40 .p2align 4, 0x90
41 .type _Z4funci,@function
42 _Z4funci: # @_Z4funci
43 .Lfunc_begin0:
44 .file 1 "/llvm-project" "/scratch/a.cpp"
45 .loc 1 1 0 # /scratch/a.cpp:1:0
46 .cfi_startproc
47 # %bb.0:
48 #DEBUG_VALUE: func:a <- $edi
49 # kill: def $edi killed $edi def $rdi
50 #DEBUG_VALUE: func:a <- $edi
51 .loc 1 2 12 prologue_end # /scratch/a.cpp:2:12
52 leal 1(%rdi), %eax
53 .loc 1 2 3 # /scratch/a.cpp:2:3
54 .loc 1 3 3 is_stmt 0 # this forms an empty range torgether with the previous.
55 retq
56 .Ltmp0:
57 .Lfunc_end0:
58 .size _Z4funci, .Lfunc_end0-_Z4funci
59 .cfi_endproc
60 # -- End function
61 .section .debug_str,"MS",@progbits,1
62 .Linfo_string0:
63 .asciz "clang version 7.0.1-6 (tags/RELEASE_701/final)" # string offset=0
64 .Linfo_string1:
65 .asciz "/scratch/a.cpp" # string offset=47
66 .Linfo_string2:
67 .asciz "/llvm-project" # string offset=97
68 .Linfo_string3:
69 .asciz "_Z4funci" # string offset=146
70 .Linfo_string4:
71 .asciz "func" # string offset=155
72 .Linfo_string5:
73 .asciz "int" # string offset=160
74 .Linfo_string6:
75 .asciz "a" # string offset=164
76 .section .debug_loc,"",@progbits
77 .Ldebug_loc0:
78 .quad .Lfunc_begin0-.Lfunc_begin0
79 .quad .Lfunc_end0-.Lfunc_begin0
80 .short 1 # Loc expr size
81 .byte 85 # super-register DW_OP_reg5
82 .quad 0
83 .quad 0
84 .section .debug_abbrev,"",@progbits
85 .byte 1 # Abbreviation Code
86 .byte 17 # DW_TAG_compile_unit
87 .byte 1 # DW_CHILDREN_yes
88 .byte 37 # DW_AT_producer
89 .byte 14 # DW_FORM_strp
90 .byte 19 # DW_AT_language
91 .byte 5 # DW_FORM_data2
92 .byte 3 # DW_AT_name
93 .byte 14 # DW_FORM_strp
94 .byte 16 # DW_AT_stmt_list
95 .byte 23 # DW_FORM_sec_offset
96 .byte 27 # DW_AT_comp_dir
97 .byte 14 # DW_FORM_strp
98 .ascii "\264B" # DW_AT_GNU_pubnames
99 .byte 25 # DW_FORM_flag_present
100 .byte 17 # DW_AT_low_pc
101 .byte 1 # DW_FORM_addr
102 .byte 18 # DW_AT_high_pc
103 .byte 6 # DW_FORM_data4
104 .byte 0 # EOM(1)
105 .byte 0 # EOM(2)
106 .byte 2 # Abbreviation Code
107 .byte 46 # DW_TAG_subprogram
108 .byte 1 # DW_CHILDREN_yes
109 .byte 17 # DW_AT_low_pc
110 .byte 1 # DW_FORM_addr
111 .byte 18 # DW_AT_high_pc
112 .byte 6 # DW_FORM_data4
113 .byte 64 # DW_AT_frame_base
114 .byte 24 # DW_FORM_exprloc
115 .byte 110 # DW_AT_linkage_name
116 .byte 14 # DW_FORM_strp
117 .byte 3 # DW_AT_name
118 .byte 14 # DW_FORM_strp
119 .byte 58 # DW_AT_decl_file
120 .byte 11 # DW_FORM_data1
121 .byte 59 # DW_AT_decl_line
122 .byte 11 # DW_FORM_data1
123 .byte 73 # DW_AT_type
124 .byte 19 # DW_FORM_ref4
125 .byte 63 # DW_AT_external
126 .byte 25 # DW_FORM_flag_present
127 .byte 0 # EOM(1)
128 .byte 0 # EOM(2)
129 .byte 3 # Abbreviation Code
130 .byte 5 # DW_TAG_formal_parameter
131 .byte 0 # DW_CHILDREN_no
132 .byte 2 # DW_AT_location
133 .byte 23 # DW_FORM_sec_offset
134 .byte 3 # DW_AT_name
135 .byte 14 # DW_FORM_strp
136 .byte 58 # DW_AT_decl_file
137 .byte 11 # DW_FORM_data1
138 .byte 59 # DW_AT_decl_line
139 .byte 11 # DW_FORM_data1
140 .byte 73 # DW_AT_type
141 .byte 19 # DW_FORM_ref4
142 .byte 0 # EOM(1)
143 .byte 0 # EOM(2)
144 .byte 4 # Abbreviation Code
145 .byte 36 # DW_TAG_base_type
146 .byte 0 # DW_CHILDREN_no
147 .byte 3 # DW_AT_name
148 .byte 14 # DW_FORM_strp
149 .byte 62 # DW_AT_encoding
150 .byte 11 # DW_FORM_data1
151 .byte 11 # DW_AT_byte_size
152 .byte 11 # DW_FORM_data1
153 .byte 0 # EOM(1)
154 .byte 0 # EOM(2)
155 .byte 0 # EOM(3)
156 .section .debug_info,"",@progbits
157 .Lcu_begin0:
158 .long 91 # Length of Unit
159 .short 4 # DWARF version number
160 .long .debug_abbrev # Offset Into Abbrev. Section
161 .byte 8 # Address Size (in bytes)
162 .byte 1 # Abbrev [1] 0xb:0x54 DW_TAG_compile_unit
163 .long .Linfo_string0 # DW_AT_producer
164 .short 4 # DW_AT_language
165 .long .Linfo_string1 # DW_AT_name
166 .long .Lline_table_start0 # DW_AT_stmt_list
167 .long .Linfo_string2 # DW_AT_comp_dir
168 # DW_AT_GNU_pubnames
169 .quad .Lfunc_begin0 # DW_AT_low_pc
170 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
171 .byte 2 # Abbrev [2] 0x2a:0x2d DW_TAG_subprogram
172 .quad .Lfunc_begin0 # DW_AT_low_pc
173 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
174 .byte 1 # DW_AT_frame_base
175 .byte 87
176 .long .Linfo_string3 # DW_AT_linkage_name
177 .long .Linfo_string4 # DW_AT_name
178 .byte 1 # DW_AT_decl_file
179 .byte 1 # DW_AT_decl_line
180 .long 87 # DW_AT_type
181 # DW_AT_external
182 .byte 3 # Abbrev [3] 0x47:0xf DW_TAG_formal_parameter
183 .long .Ldebug_loc0 # DW_AT_location
184 .long .Linfo_string6 # DW_AT_name
185 .byte 1 # DW_AT_decl_file
186 .byte 1 # DW_AT_decl_line
187 .long 87 # DW_AT_type
188 .byte 0 # End Of Children Mark
189 .byte 4 # Abbrev [4] 0x57:0x7 DW_TAG_base_type
190 .long .Linfo_string5 # DW_AT_name
191 .byte 5 # DW_AT_encoding
192 .byte 4 # DW_AT_byte_size
193 .byte 0 # End Of Children Mark
194 .section .debug_macinfo,"",@progbits
195 .byte 0 # End Of Macro List Mark
196 .section .debug_pubnames,"",@progbits
197 .long .LpubNames_end0-.LpubNames_begin0 # Length of Public Names Info
198 .LpubNames_begin0:
199 .short 2 # DWARF Version
200 .long .Lcu_begin0 # Offset of Compilation Unit Info
201 .long 95 # Compilation Unit Length
202 .long 42 # DIE offset
203 .asciz "func" # External Name
204 .long 0 # End Mark
205 .LpubNames_end0:
206 .section .debug_pubtypes,"",@progbits
207 .long .LpubTypes_end0-.LpubTypes_begin0 # Length of Public Types Info
208 .LpubTypes_begin0:
209 .short 2 # DWARF Version
210 .long .Lcu_begin0 # Offset of Compilation Unit Info
211 .long 95 # Compilation Unit Length
212 .long 87 # DIE offset
213 .asciz "int" # External Name
214 .long 0 # End Mark
215 .LpubTypes_end0:
217 .ident "clang version 7.0.1-6 (tags/RELEASE_701/final)"
218 .section ".note.GNU-stack","",@progbits
219 .addrsig
220 .section .debug_line,"",@progbits
221 .Lline_table_start0: