xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s (revision 57b48987f6c21e369e7bb1626dc79ca74aa34fdb)
1# An example of a function which has been split into two parts. Roughly
2# corresponds to this C code.
3# int baz();
4# int bar() { return 47; }
5# int foo(int flag) { return flag ? bar() : baz(); }
6# The function bar has been placed "in the middle" of foo, and the function
7# entry point is deliberately not its lowest address.
8
9# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t
10# RUN: %lldb %t -o "image lookup -v -n foo" -o "expr -- &foo" -o exit | FileCheck %s
11
12# CHECK-LABEL: image lookup
13# CHECK: 1 match found in {{.*}}
14# CHECK: Summary: {{.*}}`foo
15# CHECK: Function: id = {{.*}}, name = "foo", ranges = [0x0000000000000000-0x000000000000000e)[0x0000000000000014-0x000000000000001c)
16
17# CHECK-LABEL: expr -- &foo
18# CHECK: (void (*)()) $0 = 0x0000000000000007
19
20        .text
21
22foo.__part.1:
23        .cfi_startproc
24        callq   bar
25        jmp     foo.__part.3
26.Lfoo.__part.1_end:
27        .size   foo.__part.1, .Lfoo.__part.1_end-foo.__part.1
28        .cfi_endproc
29
30        .type   foo,@function
31foo:
32        .cfi_startproc
33        cmpl    $0, %edi
34        je      foo.__part.2
35        jmp     foo.__part.1
36        .cfi_endproc
37.Lfoo_end:
38        .size   foo, .Lfoo_end-foo
39
40bar:
41        .cfi_startproc
42        movl    $47, %eax
43        retq
44        .cfi_endproc
45.Lbar_end:
46        .size   bar, .Lbar_end-bar
47
48foo.__part.2:
49        .cfi_startproc
50        callq   baz
51        jmp     foo.__part.3
52.Lfoo.__part.2_end:
53        .size   foo.__part.2, .Lfoo.__part.2_end-foo.__part.2
54        .cfi_endproc
55
56foo.__part.3:
57        .cfi_startproc
58        retq
59.Lfoo.__part.3_end:
60        .size   foo.__part.3, .Lfoo.__part.3_end-foo.__part.3
61        .cfi_endproc
62
63
64        .section        .debug_abbrev,"",@progbits
65        .byte   1                               # Abbreviation Code
66        .byte   17                              # DW_TAG_compile_unit
67        .byte   1                               # DW_CHILDREN_yes
68        .byte   37                              # DW_AT_producer
69        .byte   8                               # DW_FORM_string
70        .byte   19                              # DW_AT_language
71        .byte   5                               # DW_FORM_data2
72        .byte   17                              # DW_AT_low_pc
73        .byte   1                               # DW_FORM_addr
74        .byte   85                              # DW_AT_ranges
75        .byte   35                              # DW_FORM_rnglistx
76        .byte   116                             # DW_AT_rnglists_base
77        .byte   23                              # DW_FORM_sec_offset
78        .byte   0                               # EOM(1)
79        .byte   0                               # EOM(2)
80        .byte   2                               # Abbreviation Code
81        .byte   46                              # DW_TAG_subprogram
82        .byte   0                               # DW_CHILDREN_no
83        .byte   17                              # DW_AT_low_pc
84        .byte   1                               # DW_FORM_addr
85        .byte   18                              # DW_AT_high_pc
86        .byte   1                               # DW_FORM_addr
87        .byte   3                               # DW_AT_name
88        .byte   8                               # DW_FORM_string
89        .byte   0                               # EOM(1)
90        .byte   0                               # EOM(2)
91        .byte   3                               # Abbreviation Code
92        .byte   46                              # DW_TAG_subprogram
93        .byte   0                               # DW_CHILDREN_no
94        .byte   85                              # DW_AT_ranges
95        .byte   35                              # DW_FORM_rnglistx
96        .byte   64                              # DW_AT_frame_base
97        .byte   24                              # DW_FORM_exprloc
98        .byte   3                               # DW_AT_name
99        .byte   8                               # DW_FORM_string
100        .byte   0                               # EOM(1)
101        .byte   0                               # EOM(2)
102        .byte   0                               # EOM(3)
103
104        .section        .debug_info,"",@progbits
105.Lcu_begin0:
106        .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
107.Ldebug_info_start0:
108        .short  5                               # DWARF version number
109        .byte   1                               # DWARF Unit Type
110        .byte   8                               # Address Size (in bytes)
111        .long   .debug_abbrev                   # Offset Into Abbrev. Section
112        .byte   1                               # Abbrev [1] DW_TAG_compile_unit
113        .asciz  "Hand-written DWARF"            # DW_AT_producer
114        .short  29                              # DW_AT_language
115        .quad   0                               # DW_AT_low_pc
116        .byte   1                               # DW_AT_ranges
117        .long   .Lrnglists_table_base0          # DW_AT_rnglists_base
118        .byte   2                               # Abbrev [2] DW_TAG_subprogram
119        .quad   bar                             # DW_AT_low_pc
120        .quad   .Lbar_end                       # DW_AT_high_pc
121        .asciz  "bar"                           # DW_AT_name
122        .byte   3                               # Abbrev [3] DW_TAG_subprogram
123        .byte   0                               # DW_AT_ranges
124        .byte   1                               # DW_AT_frame_base
125        .byte   86
126        .asciz  "foo"                           # DW_AT_name
127        .byte   0                               # End Of Children Mark
128.Ldebug_info_end0:
129
130        .section        .debug_rnglists,"",@progbits
131        .long   .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
132.Ldebug_list_header_start0:
133        .short  5                               # Version
134        .byte   8                               # Address size
135        .byte   0                               # Segment selector size
136        .long   2                               # Offset entry count
137.Lrnglists_table_base0:
138        .long   .Ldebug_ranges0-.Lrnglists_table_base0
139        .long   .Ldebug_ranges1-.Lrnglists_table_base0
140.Ldebug_ranges0:
141        .byte   6                               # DW_RLE_start_end
142        .quad   foo
143        .quad   .Lfoo_end
144        .byte   6                               # DW_RLE_start_end
145        .quad   foo.__part.1
146        .quad   .Lfoo.__part.1_end
147        .byte   6                               # DW_RLE_start_end
148        .quad   foo.__part.2
149        .quad   .Lfoo.__part.2_end
150        .byte   6                               # DW_RLE_start_end
151        .quad   foo.__part.3
152        .quad   .Lfoo.__part.3_end
153        .byte   0                               # DW_RLE_end_of_list
154.Ldebug_ranges1:
155        .byte   6                               # DW_RLE_start_end
156        .quad   bar
157        .quad   .Lbar_end
158        .byte   6                               # DW_RLE_start_end
159        .quad   foo.__part.1
160        .quad   .Lfoo.__part.1_end
161        .byte   6                               # DW_RLE_start_end
162        .quad   foo.__part.2
163        .quad   .Lfoo.__part.2_end
164        .byte   6                               # DW_RLE_start_end
165        .quad   foo.__part.3
166        .quad   .Lfoo.__part.3_end
167        .byte   6                               # DW_RLE_start_end
168        .quad   foo
169        .quad   .Lfoo_end
170        .byte   0                               # DW_RLE_end_of_list
171.Ldebug_list_header_end0:
172
173        .section        ".note.GNU-stack","",@progbits
174