xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s (revision 57b48987f6c21e369e7bb1626dc79ca74aa34fdb)
12a3c08f6SPavel Labath# An example of a function which has been split into two parts. Roughly
22a3c08f6SPavel Labath# corresponds to this C code.
32a3c08f6SPavel Labath# int baz();
42a3c08f6SPavel Labath# int bar() { return 47; }
52a3c08f6SPavel Labath# int foo(int flag) { return flag ? bar() : baz(); }
6*57b48987SPavel Labath# The function bar has been placed "in the middle" of foo, and the function
7*57b48987SPavel Labath# entry point is deliberately not its lowest address.
82a3c08f6SPavel Labath
92a3c08f6SPavel Labath# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t
10*57b48987SPavel Labath# RUN: %lldb %t -o "image lookup -v -n foo" -o "expr -- &foo" -o exit | FileCheck %s
112a3c08f6SPavel Labath
12*57b48987SPavel Labath# CHECK-LABEL: image lookup
132a3c08f6SPavel Labath# CHECK: 1 match found in {{.*}}
142a3c08f6SPavel Labath# CHECK: Summary: {{.*}}`foo
1551b74bb9SPavel Labath# CHECK: Function: id = {{.*}}, name = "foo", ranges = [0x0000000000000000-0x000000000000000e)[0x0000000000000014-0x000000000000001c)
162a3c08f6SPavel Labath
17*57b48987SPavel Labath# CHECK-LABEL: expr -- &foo
18*57b48987SPavel Labath# CHECK: (void (*)()) $0 = 0x0000000000000007
19*57b48987SPavel Labath
202a3c08f6SPavel Labath        .text
212a3c08f6SPavel Labath
22*57b48987SPavel Labathfoo.__part.1:
23*57b48987SPavel Labath        .cfi_startproc
24*57b48987SPavel Labath        callq   bar
25*57b48987SPavel Labath        jmp     foo.__part.3
26*57b48987SPavel Labath.Lfoo.__part.1_end:
27*57b48987SPavel Labath        .size   foo.__part.1, .Lfoo.__part.1_end-foo.__part.1
28*57b48987SPavel Labath        .cfi_endproc
29*57b48987SPavel Labath
302a3c08f6SPavel Labath        .type   foo,@function
312a3c08f6SPavel Labathfoo:
322a3c08f6SPavel Labath        .cfi_startproc
332a3c08f6SPavel Labath        cmpl    $0, %edi
342a3c08f6SPavel Labath        je      foo.__part.2
352a3c08f6SPavel Labath        jmp     foo.__part.1
362a3c08f6SPavel Labath        .cfi_endproc
372a3c08f6SPavel Labath.Lfoo_end:
382a3c08f6SPavel Labath        .size   foo, .Lfoo_end-foo
392a3c08f6SPavel Labath
402a3c08f6SPavel Labathbar:
412a3c08f6SPavel Labath        .cfi_startproc
422a3c08f6SPavel Labath        movl    $47, %eax
432a3c08f6SPavel Labath        retq
442a3c08f6SPavel Labath        .cfi_endproc
452a3c08f6SPavel Labath.Lbar_end:
462a3c08f6SPavel Labath        .size   bar, .Lbar_end-bar
472a3c08f6SPavel Labath
482a3c08f6SPavel Labathfoo.__part.2:
492a3c08f6SPavel Labath        .cfi_startproc
502a3c08f6SPavel Labath        callq   baz
512a3c08f6SPavel Labath        jmp     foo.__part.3
522a3c08f6SPavel Labath.Lfoo.__part.2_end:
532a3c08f6SPavel Labath        .size   foo.__part.2, .Lfoo.__part.2_end-foo.__part.2
542a3c08f6SPavel Labath        .cfi_endproc
552a3c08f6SPavel Labath
562a3c08f6SPavel Labathfoo.__part.3:
572a3c08f6SPavel Labath        .cfi_startproc
582a3c08f6SPavel Labath        retq
592a3c08f6SPavel Labath.Lfoo.__part.3_end:
602a3c08f6SPavel Labath        .size   foo.__part.3, .Lfoo.__part.3_end-foo.__part.3
612a3c08f6SPavel Labath        .cfi_endproc
622a3c08f6SPavel Labath
632a3c08f6SPavel Labath
642a3c08f6SPavel Labath        .section        .debug_abbrev,"",@progbits
652a3c08f6SPavel Labath        .byte   1                               # Abbreviation Code
662a3c08f6SPavel Labath        .byte   17                              # DW_TAG_compile_unit
672a3c08f6SPavel Labath        .byte   1                               # DW_CHILDREN_yes
682a3c08f6SPavel Labath        .byte   37                              # DW_AT_producer
692a3c08f6SPavel Labath        .byte   8                               # DW_FORM_string
702a3c08f6SPavel Labath        .byte   19                              # DW_AT_language
712a3c08f6SPavel Labath        .byte   5                               # DW_FORM_data2
722a3c08f6SPavel Labath        .byte   17                              # DW_AT_low_pc
732a3c08f6SPavel Labath        .byte   1                               # DW_FORM_addr
742a3c08f6SPavel Labath        .byte   85                              # DW_AT_ranges
752a3c08f6SPavel Labath        .byte   35                              # DW_FORM_rnglistx
762a3c08f6SPavel Labath        .byte   116                             # DW_AT_rnglists_base
772a3c08f6SPavel Labath        .byte   23                              # DW_FORM_sec_offset
782a3c08f6SPavel Labath        .byte   0                               # EOM(1)
792a3c08f6SPavel Labath        .byte   0                               # EOM(2)
802a3c08f6SPavel Labath        .byte   2                               # Abbreviation Code
812a3c08f6SPavel Labath        .byte   46                              # DW_TAG_subprogram
822a3c08f6SPavel Labath        .byte   0                               # DW_CHILDREN_no
832a3c08f6SPavel Labath        .byte   17                              # DW_AT_low_pc
842a3c08f6SPavel Labath        .byte   1                               # DW_FORM_addr
852a3c08f6SPavel Labath        .byte   18                              # DW_AT_high_pc
862a3c08f6SPavel Labath        .byte   1                               # DW_FORM_addr
872a3c08f6SPavel Labath        .byte   3                               # DW_AT_name
882a3c08f6SPavel Labath        .byte   8                               # DW_FORM_string
892a3c08f6SPavel Labath        .byte   0                               # EOM(1)
902a3c08f6SPavel Labath        .byte   0                               # EOM(2)
912a3c08f6SPavel Labath        .byte   3                               # Abbreviation Code
922a3c08f6SPavel Labath        .byte   46                              # DW_TAG_subprogram
932a3c08f6SPavel Labath        .byte   0                               # DW_CHILDREN_no
942a3c08f6SPavel Labath        .byte   85                              # DW_AT_ranges
952a3c08f6SPavel Labath        .byte   35                              # DW_FORM_rnglistx
962a3c08f6SPavel Labath        .byte   64                              # DW_AT_frame_base
972a3c08f6SPavel Labath        .byte   24                              # DW_FORM_exprloc
982a3c08f6SPavel Labath        .byte   3                               # DW_AT_name
992a3c08f6SPavel Labath        .byte   8                               # DW_FORM_string
1002a3c08f6SPavel Labath        .byte   0                               # EOM(1)
1012a3c08f6SPavel Labath        .byte   0                               # EOM(2)
1022a3c08f6SPavel Labath        .byte   0                               # EOM(3)
1032a3c08f6SPavel Labath
1042a3c08f6SPavel Labath        .section        .debug_info,"",@progbits
1052a3c08f6SPavel Labath.Lcu_begin0:
1062a3c08f6SPavel Labath        .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
1072a3c08f6SPavel Labath.Ldebug_info_start0:
1082a3c08f6SPavel Labath        .short  5                               # DWARF version number
1092a3c08f6SPavel Labath        .byte   1                               # DWARF Unit Type
1102a3c08f6SPavel Labath        .byte   8                               # Address Size (in bytes)
1112a3c08f6SPavel Labath        .long   .debug_abbrev                   # Offset Into Abbrev. Section
1122a3c08f6SPavel Labath        .byte   1                               # Abbrev [1] DW_TAG_compile_unit
1132a3c08f6SPavel Labath        .asciz  "Hand-written DWARF"            # DW_AT_producer
1142a3c08f6SPavel Labath        .short  29                              # DW_AT_language
1152a3c08f6SPavel Labath        .quad   0                               # DW_AT_low_pc
1162a3c08f6SPavel Labath        .byte   1                               # DW_AT_ranges
1172a3c08f6SPavel Labath        .long   .Lrnglists_table_base0          # DW_AT_rnglists_base
1182a3c08f6SPavel Labath        .byte   2                               # Abbrev [2] DW_TAG_subprogram
1192a3c08f6SPavel Labath        .quad   bar                             # DW_AT_low_pc
1202a3c08f6SPavel Labath        .quad   .Lbar_end                       # DW_AT_high_pc
1212a3c08f6SPavel Labath        .asciz  "bar"                           # DW_AT_name
1222a3c08f6SPavel Labath        .byte   3                               # Abbrev [3] DW_TAG_subprogram
1232a3c08f6SPavel Labath        .byte   0                               # DW_AT_ranges
1242a3c08f6SPavel Labath        .byte   1                               # DW_AT_frame_base
1252a3c08f6SPavel Labath        .byte   86
1262a3c08f6SPavel Labath        .asciz  "foo"                           # DW_AT_name
1272a3c08f6SPavel Labath        .byte   0                               # End Of Children Mark
1282a3c08f6SPavel Labath.Ldebug_info_end0:
1292a3c08f6SPavel Labath
1302a3c08f6SPavel Labath        .section        .debug_rnglists,"",@progbits
1312a3c08f6SPavel Labath        .long   .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
1322a3c08f6SPavel Labath.Ldebug_list_header_start0:
1332a3c08f6SPavel Labath        .short  5                               # Version
1342a3c08f6SPavel Labath        .byte   8                               # Address size
1352a3c08f6SPavel Labath        .byte   0                               # Segment selector size
1362a3c08f6SPavel Labath        .long   2                               # Offset entry count
1372a3c08f6SPavel Labath.Lrnglists_table_base0:
1382a3c08f6SPavel Labath        .long   .Ldebug_ranges0-.Lrnglists_table_base0
1392a3c08f6SPavel Labath        .long   .Ldebug_ranges1-.Lrnglists_table_base0
1402a3c08f6SPavel Labath.Ldebug_ranges0:
1412a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1422a3c08f6SPavel Labath        .quad   foo
1432a3c08f6SPavel Labath        .quad   .Lfoo_end
1442a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1452a3c08f6SPavel Labath        .quad   foo.__part.1
1462a3c08f6SPavel Labath        .quad   .Lfoo.__part.1_end
1472a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1482a3c08f6SPavel Labath        .quad   foo.__part.2
1492a3c08f6SPavel Labath        .quad   .Lfoo.__part.2_end
1502a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1512a3c08f6SPavel Labath        .quad   foo.__part.3
1522a3c08f6SPavel Labath        .quad   .Lfoo.__part.3_end
1532a3c08f6SPavel Labath        .byte   0                               # DW_RLE_end_of_list
1542a3c08f6SPavel Labath.Ldebug_ranges1:
1552a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1562a3c08f6SPavel Labath        .quad   bar
1572a3c08f6SPavel Labath        .quad   .Lbar_end
1582a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1592a3c08f6SPavel Labath        .quad   foo.__part.1
1602a3c08f6SPavel Labath        .quad   .Lfoo.__part.1_end
1612a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1622a3c08f6SPavel Labath        .quad   foo.__part.2
1632a3c08f6SPavel Labath        .quad   .Lfoo.__part.2_end
1642a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1652a3c08f6SPavel Labath        .quad   foo.__part.3
1662a3c08f6SPavel Labath        .quad   .Lfoo.__part.3_end
1672a3c08f6SPavel Labath        .byte   6                               # DW_RLE_start_end
1682a3c08f6SPavel Labath        .quad   foo
1692a3c08f6SPavel Labath        .quad   .Lfoo_end
1702a3c08f6SPavel Labath        .byte   0                               # DW_RLE_end_of_list
1712a3c08f6SPavel Labath.Ldebug_list_header_end0:
1722a3c08f6SPavel Labath
1732a3c08f6SPavel Labath        .section        ".note.GNU-stack","",@progbits
174