xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwarf5-debug_line.s (revision 8a64d80a959bf2844df33f9112e456f33de7b468)
1# Test handling of DWARF5 line tables. In particular, test that we handle files
2# which are present in the line table more than once.
3
4# RUN: llvm-mc -filetype=obj -o %t -triple x86_64-pc-linux %s
5# RUN: %lldb %t -o "source info -f file0.c" -o "source info -f file1.c" \
6# RUN:   -o "breakpoint set -f file0.c -l 42" \
7# RUN:   -o "breakpoint set -f file0.c -l 47" \
8# RUN:   -o exit | FileCheck %s
9
10# CHECK-LABEL: source info -f file0.c
11# CHECK: [0x0000000000000000-0x0000000000000001): /file0.c:42
12# CHECK-LABEL: source info -f file1.c
13# CHECK: [0x0000000000000001-0x0000000000000002): /file1.c:47
14# CHECK-LABEL: breakpoint set -f file0.c -l 42
15# CHECK: Breakpoint 1: {{.*}}`foo,
16# CHECK-LABEL: breakpoint set -f file0.c -l 47
17# CHECK: Breakpoint 2: {{.*}}`foo + 2,
18
19        .text
20        .globl  foo
21foo:
22        nop
23        nop
24        nop
25.Lfoo_end:
26
27        .section        .debug_abbrev,"",@progbits
28        .byte   1                       # Abbreviation Code
29        .byte   17                      # DW_TAG_compile_unit
30        .byte   0                       # DW_CHILDREN_no
31        .byte   37                      # DW_AT_producer
32        .byte   8                       # DW_FORM_string
33        .byte   19                      # DW_AT_language
34        .byte   5                       # DW_FORM_data2
35        .byte   3                       # DW_AT_name
36        .byte   8                       # DW_FORM_string
37        .byte   16                      # DW_AT_stmt_list
38        .byte   23                      # DW_FORM_sec_offset
39        .byte   27                      # DW_AT_comp_dir
40        .byte   8                       # DW_FORM_string
41        .byte   17                      # DW_AT_low_pc
42        .byte   1                       # DW_FORM_addr
43        .byte   18                      # DW_AT_high_pc
44        .byte   6                       # DW_FORM_data4
45        .byte   0                       # EOM(1)
46        .byte   0                       # EOM(2)
47        .byte   0                       # EOM(3)
48
49        .section        .debug_info,"",@progbits
50.Lcu_begin0:
51        .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
52.Ldebug_info_start0:
53        .short  5                       # DWARF version number
54        .byte   1                       # DWARF Unit Type
55        .byte   8                       # Address Size (in bytes)
56        .long   .debug_abbrev           # Offset Into Abbrev. Section
57        .byte   1                       # Abbrev [1] 0xc:0x23 DW_TAG_compile_unit
58        .asciz  "Hand-written DWARF"    # DW_AT_producer
59        .short  12                      # DW_AT_language
60        .asciz  "file0.c"               # DW_AT_name
61        .long   .Lline_table_begin      # DW_AT_stmt_list
62        .asciz  "/"                     # DW_AT_comp_dir
63        .quad   foo                     # DW_AT_low_pc
64        .long   .Lfoo_end-foo           # DW_AT_high_pc
65.Ldebug_info_end0:
66
67        .section        .debug_line,"",@progbits
68.Lline_table_begin:
69        .long .Lline_end-.Lline_start
70.Lline_start:
71        .short  5                       # DWARF version number
72        .byte   8                       # Address Size (in bytes)
73        .byte   0                       # Segment Selector Size
74        .long   .Lheader_end-.Lheader_start
75.Lheader_start:
76        .byte   1                       # Minimum Instruction Length
77        .byte   1                       # Maximum Operations per Instruction
78        .byte   1                       # Default is_stmt
79        .byte   0                       # Line Base
80        .byte   0                       # Line Range
81        .byte   5                       # Opcode Base
82        .byte   0, 1, 1, 1              # Standard Opcode Lengths
83
84        # Directory table format
85        .byte   1                       # One element per directory entry
86        .byte   1                       # DW_LNCT_path
87        .byte   0x08                    # DW_FORM_string
88
89        # Directory table entries
90        .byte   1                       # 1 directory
91        .asciz  "/"
92
93        # File table format
94        .byte   2                       # 2 elements per file entry
95        .byte   1                       # DW_LNCT_path
96        .byte   0x08                    # DW_FORM_string
97        .byte   2                       # DW_LNCT_directory_index
98        .byte   0x0b                    # DW_FORM_data1
99
100        # File table entries
101        .byte   3                       # 3 files
102        .asciz  "file0.c"
103        .byte   0
104        .asciz  "file1.c"
105        .byte   0
106        .asciz  "file0.c"
107        .byte   0
108.Lheader_end:
109
110        .byte   4, 0                    # DW_LNS_set_file 0
111        .byte   0, 9, 2                 # DW_LNE_set_address
112        .quad   foo
113        .byte   3, 41                   # DW_LNS_advance_line 41
114        .byte   1                       # DW_LNS_copy
115
116        .byte   4, 1                    # DW_LNS_set_file 1
117        .byte   2, 1                    # DW_LNS_advance_pc 1
118        .byte   3, 5                    # DW_LNS_advance_line 5
119        .byte   1                       # DW_LNS_copy
120
121        .byte   4, 2                    # DW_LNS_set_file 2
122        .byte   2, 1                    # DW_LNS_advance_pc 1
123        .byte   1                       # DW_LNS_copy
124
125        .byte   2, 1                    # DW_LNS_advance_pc 1
126        .byte   0, 1, 1                 # DW_LNE_end_sequence
127.Lline_end:
128