xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/unused-inlined-params.s (revision 5a3556aa5563fb89693935303463881df44094de)
1# The below program is roughly derived from the following C program.
2# To see the annotated debug info, look for the section
3# '.section    .debug_info' below.
4#
5# __attribute__((always_inline))
6# void f(void* unused1, int used, int unused2, int partial, int unused3) {
7#   used += partial;
8#   printf("f %i", partial);
9#   printf("f %i", used);   // |partial| is not live at this line.
10# }
11#
12# void g(int unused) {
13#   printf("Hello");
14# }
15#
16# __attribute__((noinline))
17# void other() {
18#   f(nullptr, 1, 0, 2, 0);
19# }
20#
21# int main(int argc, char** argv) {
22#   f(argv, 42, 1, argc, 2);
23#   g(1);
24#   other();
25#   return 0;
26# }
27
28    .text
29    .file    "unused-inlined-params.c"
30
31.Lcu_begin:
32
33    .globl    other
34other:
35    nop
36.Linlined_f_in_other:
37break_at_inlined_f_in_other:
38    callq    printf        # Omitted the setup of arguments.
39.Linlined_f_in_other_between_printfs:
40    callq    printf        # Omitted the setup of arguments.
41.Linlined_f_in_other_end:
42    retq
43.Lother_end:
44    .size    other, .Lother_end-other
45
46    .globl    main
47main:
48    .file    1 "/example" "unused-inlined-params.c"
49    movl    $1, %esi
50.Linlined_f:
51break_at_inlined_f_in_main:
52    leal    42(%rsi), %ebx
53.Linlined_f_before_printf:
54    callq    printf        # Omitted the setup of arguments.
55.Linlined_f_between_printfs:
56break_at_inlined_f_in_main_between_printfs:
57    callq    printf        # Omitted the setup of arguments.
58.Linlined_f_end:
59.Linlined_g:
60break_at_inlined_g_in_main:
61    callq    printf        # Omitted the setup of arguments.
62.Linlined_g_end:
63    callq    other
64    retq
65.Lmain_end:
66    .size    main, .Lmain_end-main
67
68# Dummy printf implementation.
69printf:
70    retq
71
72# Simple entry point to make the linker happy.
73    .globl  _start
74_start:
75    jmp     main
76
77.Lcu_end:
78
79
80    .section    .debug_loc,"",@progbits
81.Ldebug_loc_partial:
82    .quad    .Linlined_f-.Lcu_begin
83    .quad    .Linlined_f_between_printfs-.Lcu_begin
84    .short   1                               # Loc expr size
85    .byte    84                              # super-register DW_OP_reg4
86    .quad    0
87    .quad    0
88.Ldebug_loc_used:
89    .quad    .Linlined_f-.Lcu_begin
90    .quad    .Linlined_f_before_printf-.Lcu_begin
91    .short   3                               # Loc expr size
92    .byte    17                              # DW_OP_consts
93    .byte    42                              # value
94    .byte    159                             # DW_OP_stack_value
95    .quad    .Linlined_f_before_printf-.Lcu_begin
96    .quad    .Linlined_f_end-.Lcu_begin
97    .short   1                               # Loc expr size
98    .byte    83                              # super-register DW_OP_reg3
99    .quad    0
100    .quad    0
101.Ldebug_loc_partial_in_other:
102    .quad    .Linlined_f_in_other-.Lcu_begin
103    .quad    .Linlined_f_in_other_between_printfs-.Lcu_begin
104    .short   3                               # Loc expr size
105    .byte    17                              # DW_OP_consts
106    .byte    2                               # value
107    .byte    159                             # DW_OP_stack_value
108    .quad    0
109    .quad    0
110.Ldebug_loc_used_in_other:
111    .quad    .Linlined_f_in_other-.Lcu_begin
112    .quad    .Linlined_f_in_other_end-.Lcu_begin
113    .short   3                               # Loc expr size
114    .byte    17                              # DW_OP_consts
115    .byte    1                               # value
116    .byte    159                             # DW_OP_stack_value
117    .quad    0
118    .quad    0
119
120    .section    .debug_abbrev,"",@progbits
121    .byte    1                               # Abbreviation Code
122    .byte    17                              # DW_TAG_compile_unit
123    .byte    1                               # DW_CHILDREN_yes
124    .byte    3                               # DW_AT_name
125    .byte    14                              # DW_FORM_strp
126    .byte    16                              # DW_AT_stmt_list
127    .byte    23                              # DW_FORM_sec_offset
128    .byte    17                              # DW_AT_low_pc
129    .byte    1                               # DW_FORM_addr
130    .byte    18                              # DW_AT_high_pc
131    .byte    6                               # DW_FORM_data4
132    .byte    0                               # EOM(1)
133    .byte    0                               # EOM(2)
134
135    .byte    4                               # Abbreviation Code
136    .byte    5                               # DW_TAG_formal_parameter
137    .byte    0                               # DW_CHILDREN_no
138    .byte    2                               # DW_AT_location
139    .byte    23                              # DW_FORM_sec_offset
140    .byte    49                              # DW_AT_abstract_origin
141    .byte    19                              # DW_FORM_ref4
142    .byte    0                               # EOM(1)
143    .byte    0                               # EOM(2)
144
145    .byte    5                               # Abbreviation Code
146    .byte    46                              # DW_TAG_subprogram
147    .byte    1                               # DW_CHILDREN_yes
148    .byte    3                               # DW_AT_name
149    .byte    14                              # DW_FORM_strp
150    .byte    58                              # DW_AT_decl_file
151    .byte    11                              # DW_FORM_data1
152    .byte    59                              # DW_AT_decl_line
153    .byte    11                              # DW_FORM_data1
154    .byte    39                              # DW_AT_prototyped
155    .byte    25                              # DW_FORM_flag_present
156    .byte    63                              # DW_AT_external
157    .byte    25                              # DW_FORM_flag_present
158    .byte    32                              # DW_AT_inline
159    .byte    11                              # DW_FORM_data1
160    .byte    0                               # EOM(1)
161    .byte    0                               # EOM(2)
162
163    .byte    6                               # Abbreviation Code
164    .byte    5                               # DW_TAG_formal_parameter
165    .byte    0                               # DW_CHILDREN_no
166    .byte    3                               # DW_AT_name
167    .byte    14                              # DW_FORM_strp
168    .byte    58                              # DW_AT_decl_file
169    .byte    11                              # DW_FORM_data1
170    .byte    59                              # DW_AT_decl_line
171    .byte    11                              # DW_FORM_data1
172    .byte    73                              # DW_AT_type
173    .byte    19                              # DW_FORM_ref4
174    .byte    0                               # EOM(1)
175    .byte    0                               # EOM(2)
176
177    .byte    7                               # Abbreviation Code
178    .byte    15                              # DW_TAG_pointer_type
179    .byte    0                               # DW_CHILDREN_no
180    .byte    0                               # EOM(1)
181    .byte    0                               # EOM(2)
182
183    .byte    8                               # Abbreviation Code
184    .byte    36                              # DW_TAG_base_type
185    .byte    0                               # DW_CHILDREN_no
186    .byte    3                               # DW_AT_name
187    .byte    14                              # DW_FORM_strp
188    .byte    62                              # DW_AT_encoding
189    .byte    11                              # DW_FORM_data1
190    .byte    11                              # DW_AT_byte_size
191    .byte    11                              # DW_FORM_data1
192    .byte    0                               # EOM(1)
193    .byte    0                               # EOM(2)
194
195    .byte    9                               # Abbreviation Code
196    .byte    46                              # DW_TAG_subprogram
197    .byte    1                               # DW_CHILDREN_yes
198    .byte    17                              # DW_AT_low_pc
199    .byte    1                               # DW_FORM_addr
200    .byte    18                              # DW_AT_high_pc
201    .byte    6                               # DW_FORM_data4
202    .byte    64                              # DW_AT_frame_base
203    .byte    24                              # DW_FORM_exprloc
204    .byte    3                               # DW_AT_name
205    .byte    14                              # DW_FORM_strp
206    .byte    58                              # DW_AT_decl_file
207    .byte    11                              # DW_FORM_data1
208    .byte    59                              # DW_AT_decl_line
209    .byte    11                              # DW_FORM_data1
210    .byte    39                              # DW_AT_prototyped
211    .byte    25                              # DW_FORM_flag_present
212    .byte    73                              # DW_AT_type
213    .byte    19                              # DW_FORM_ref4
214    .byte    63                              # DW_AT_external
215    .byte    25                              # DW_FORM_flag_present
216    .byte    0                               # EOM(1)
217    .byte    0                               # EOM(2)
218
219    .byte    10                              # Abbreviation Code
220    .byte    5                               # DW_TAG_formal_parameter
221    .byte    0                               # DW_CHILDREN_no
222    .byte    2                               # DW_AT_location
223    .byte    23                              # DW_FORM_sec_offset
224    .byte    3                               # DW_AT_name
225    .byte    14                              # DW_FORM_strp
226    .byte    58                              # DW_AT_decl_file
227    .byte    11                              # DW_FORM_data1
228    .byte    59                              # DW_AT_decl_line
229    .byte    11                              # DW_FORM_data1
230    .byte    73                              # DW_AT_type
231    .byte    19                              # DW_FORM_ref4
232    .byte    0                               # EOM(1)
233    .byte    0                               # EOM(2)
234
235    .byte    11                              # Abbreviation Code
236    .byte    29                              # DW_TAG_inlined_subroutine
237    .byte    1                               # DW_CHILDREN_yes
238    .byte    49                              # DW_AT_abstract_origin
239    .byte    19                              # DW_FORM_ref4
240    .byte    17                              # DW_AT_low_pc
241    .byte    1                               # DW_FORM_addr
242    .byte    18                              # DW_AT_high_pc
243    .byte    6                               # DW_FORM_data4
244    .byte    88                              # DW_AT_call_file
245    .byte    11                              # DW_FORM_data1
246    .byte    89                              # DW_AT_call_line
247    .byte    11                              # DW_FORM_data1
248    .byte    87                              # DW_AT_call_column
249    .byte    11                              # DW_FORM_data1
250    .byte    0                               # EOM(1)
251    .byte    0                               # EOM(2)
252
253    .byte    12                              # Abbreviation Code
254    .byte    15                              # DW_TAG_pointer_type
255    .byte    0                               # DW_CHILDREN_no
256    .byte    73                              # DW_AT_type
257    .byte    19                              # DW_FORM_ref4
258    .byte    0                               # EOM(1)
259    .byte    0                               # EOM(2)
260    .byte    0                               # EOM(3)
261
262    .section    .debug_info,"",@progbits
263.Ldi_cu_begin:
264    .long    .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
265.Ldebug_info_start0:
266    .short    4                              # DWARF version number
267    .long    .debug_abbrev                   # Offset Into Abbrev. Section
268    .byte    8                               # Address Size (in bytes)
269    .byte    1                               # Abbrev [1] DW_TAG_compile_unit
270    .long    .Linfo_string_fname             #   DW_AT_name
271    .long    .Lline_table_start0             #   DW_AT_stmt_list
272    .quad    .Lcu_begin                      #   DW_AT_low_pc
273    .long    .Lcu_end-.Lcu_begin             #   DW_AT_high_pc
274
275# Debug info for |f| (abstract version with all parameters).
276
277.Ldebug_info_f:
278    .byte    5                               #   Abbrev [5] DW_TAG_subprogram
279    .long    .Linfo_string_f                 #     DW_AT_name
280    .byte    1                               #     DW_AT_decl_file
281    .byte    4                               #     DW_AT_decl_line
282                                             #     DW_AT_prototyped
283                                             #     DW_AT_external
284    .byte    1                               #     DW_AT_inline
285.Ldebug_info_param1:
286    .byte    6                               #     Abbrev [6] DW_TAG_formal_parameter
287    .long    .Linfo_string_unused1           #       DW_AT_name
288    .byte    1                               #       DW_AT_decl_file
289    .byte    4                               #       DW_AT_decl_line
290    .long    .Ldebug_info_void_ptr-.Ldi_cu_begin
291                                             #       DW_AT_type
292.Ldebug_info_param2:
293    .byte    6                               #     Abbrev [6] DW_TAG_formal_parameter
294    .long    .Linfo_string_used              #       DW_AT_name
295    .byte    1                               #       DW_AT_decl_file
296    .byte    4                               #       DW_AT_decl_line
297    .long    .Ldebug_info_int-.Ldi_cu_begin  #       DW_AT_type
298.Ldebug_info_param3:
299    .byte    6                               #     Abbrev [6] DW_TAG_formal_parameter
300    .long    .Linfo_string_unused2           #       DW_AT_name
301    .byte    1                               #       DW_AT_decl_file
302    .byte    4                               #       DW_AT_decl_line
303    .long    .Ldebug_info_int-.Ldi_cu_begin  #       DW_AT_type
304.Ldebug_info_param4:
305    .byte    6                               #     Abbrev [6] DW_TAG_formal_parameter
306    .long    .Linfo_string_partial           #       DW_AT_name
307    .byte    1                               #       DW_AT_decl_file
308    .byte    4                               #       DW_AT_decl_line
309    .long    .Ldebug_info_int-.Ldi_cu_begin  #       DW_AT_type
310.Ldebug_info_param5:
311    .byte    6                               #     Abbrev [6] DW_TAG_formal_parameter
312    .long    .Linfo_string_unused3           #       DW_AT_name
313    .byte    1                               #       DW_AT_decl_file
314    .byte    4                               #       DW_AT_decl_line
315    .long    .Ldebug_info_int-.Ldi_cu_begin  #       DW_AT_type
316    .byte    0                               #   End Of Children Mark (DW_TAG_subprogram)
317
318# Debug info for |g| (abstract version with all parameters).
319
320.Ldebug_info_g:
321    .byte    5                               #   Abbrev [5] DW_TAG_subprogram
322    .long    .Linfo_string_g                 #     DW_AT_name
323    .byte    1                               #     DW_AT_decl_file
324    .byte    4                               #     DW_AT_decl_line
325                                             #     DW_AT_prototyped
326                                             #     DW_AT_external
327    .byte    1                               #     DW_AT_inline
328.Ldebug_info_g_param1:
329    .byte    6                               #     Abbrev [6] DW_TAG_formal_parameter
330    .long    .Linfo_string_unused            #       DW_AT_name
331    .byte    1                               #       DW_AT_decl_file
332    .byte    10                              #       DW_AT_decl_line
333    .long    .Ldebug_info_int-.Ldi_cu_begin
334    .byte    0                               #   End Of Children Mark (DW_TAG_subprogram)
335
336# Debug info for |main|.
337
338    .byte    9                               #   Abbrev [9] DW_TAG_subprogram
339    .quad    main                            #     DW_AT_low_pc
340    .long    .Lmain_end-main                 #     DW_AT_high_pc
341    .byte    1                               #     DW_AT_frame_base
342    .byte    87
343    .long    .Linfo_string_main              #     DW_AT_name
344    .byte    1                               #     DW_AT_decl_file
345    .byte    18                              #     DW_AT_decl_line
346                                             #     DW_AT_prototyped
347    .long    .Ldebug_info_int-.Ldi_cu_begin  #     DW_AT_type
348                                             #     DW_AT_external
349
350#   Debug info for concrete |f| inlined into |main|.
351
352    .byte    11                              #     Abbrev [11] DW_TAG_inlined_subroutine
353    .long    .Ldebug_info_f-.Ldi_cu_begin
354                                             #       DW_AT_abstract_origin
355    .quad    .Linlined_f                     #       DW_AT_low_pc
356    .long    .Linlined_f_end-.Linlined_f     #       DW_AT_high_pc
357    .byte    1                               #       DW_AT_call_file
358    .byte    20                              #       DW_AT_call_line
359    .byte    3                               #       DW_AT_call_column
360    .byte    4                               #       Abbrev [4] DW_TAG_formal_parameter
361    .long    .Ldebug_loc_used                #         DW_AT_location
362    .long    .Ldebug_info_param2-.Ldi_cu_begin
363                                             #         DW_AT_abstract_origin
364    .byte    4                               #       Abbrev [4] DW_TAG_formal_parameter
365    .long    .Ldebug_loc_partial             #         DW_AT_location
366    .long    .Ldebug_info_param4-.Ldi_cu_begin
367                                             #         DW_AT_abstract_origin
368    .byte    0                               #     End Of Children Mark (DW_TAG_inlined_subroutine)
369
370#   Debug info for concrete |g| inlined into |main|.
371
372    .byte    11                              #     Abbrev [11] DW_TAG_inlined_subroutine
373    .long    .Ldebug_info_g-.Ldi_cu_begin
374                                             #       DW_AT_abstract_origin
375    .quad    .Linlined_g                     #       DW_AT_low_pc
376    .long    .Linlined_g_end-.Linlined_g     #       DW_AT_high_pc
377    .byte    1                               #       DW_AT_call_file
378    .byte    21                              #       DW_AT_call_line
379    .byte    3                               #       DW_AT_call_column
380    .byte    0                               #     End Of Children Mark (DW_TAG_inlined_subroutine)
381
382    .byte    0                               #   End Of Children Mark (DW_TAG_subprogram)
383
384# Debug info for |other|.
385
386    .byte    9                               #   Abbrev [9] DW_TAG_subprogram
387    .quad    other                           #     DW_AT_low_pc
388    .long    .Lother_end-other               #     DW_AT_high_pc
389    .byte    1                               #     DW_AT_frame_base
390    .byte    87
391    .long    .Linfo_string_other             #     DW_AT_name
392    .byte    1                               #     DW_AT_decl_file
393    .byte    15                              #     DW_AT_decl_line
394                                             #     DW_AT_prototyped
395    .long    .Ldebug_info_int-.Ldi_cu_begin  #     DW_AT_type
396                                             #     DW_AT_external
397
398#   Debug info for concrete |f| inlined into |other|.
399
400    .byte    11                              #     Abbrev [11] DW_TAG_inlined_subroutine
401    .long    .Ldebug_info_f-.Ldi_cu_begin
402                                             #       DW_AT_abstract_origin
403    .quad    .Linlined_f_in_other            #       DW_AT_low_pc
404    .long    .Linlined_f_in_other_end-.Linlined_f_in_other
405                                             #       DW_AT_high_pc
406    .byte    1                               #       DW_AT_call_file
407    .byte    16                              #       DW_AT_call_line
408    .byte    3                               #       DW_AT_call_column
409    .byte    4                               #       Abbrev [4] DW_TAG_formal_parameter
410    .long    .Ldebug_loc_used_in_other       #         DW_AT_location
411    .long    .Ldebug_info_param2-.Ldi_cu_begin
412                                             #         DW_AT_abstract_origin
413    .byte    4                               #       Abbrev [4] DW_TAG_formal_parameter
414    .long    .Ldebug_loc_partial_in_other    #         DW_AT_location
415    .long    .Ldebug_info_param4-.Ldi_cu_begin
416                                             #         DW_AT_abstract_origin
417    .byte    0                               #     End Of Children Mark (DW_TAG_inlined_subroutine)
418    .byte    0                               #   End Of Children Mark (DW_TAG_subprogram)
419
420.Ldebug_info_void_ptr:
421    .byte    7                               #   Abbrev [7] DW_TAG_pointer_type
422.Ldebug_info_int:
423    .byte    8                               #   Abbrev [8] DW_TAG_base_type
424    .long    .Linfo_string_int               #     DW_AT_name
425    .byte    5                               #     DW_AT_encoding
426    .byte    4                               #     DW_AT_byte_size
427
428    .byte    0                               # End Of Children Mark (DW_TAG_compile_unit)
429.Ldebug_info_end0:
430    .section    .debug_str,"MS",@progbits,1
431.Linfo_string_fname:
432    .asciz    "unused-inlined-params.c"
433.Linfo_string_f:
434    .asciz    "f"
435.Linfo_string_unused1:
436    .asciz    "unused1"
437.Linfo_string_used:
438    .asciz    "used"
439.Linfo_string_int:
440    .asciz    "int"
441.Linfo_string_unused2:
442    .asciz    "unused2"
443.Linfo_string_partial:
444    .asciz    "partial"
445.Linfo_string_unused3:
446    .asciz    "unused3"
447.Linfo_string_main:
448    .asciz    "main"
449.Linfo_string_g:
450    .asciz    "g"
451.Linfo_string_unused:
452    .asciz    "unused"
453.Linfo_string_other:
454    .asciz    "other"
455    .section    ".note.GNU-stack","",@progbits
456    .addrsig
457    .section    .debug_line,"",@progbits
458.Lline_table_start0:
459