brintos

brintos / llvm-project-archived public Read only

0
0
Text · 42.2 KiB · c4e2fb2 Raw
831 lines · yaml
1## Test that yaml2obj emits .debug_line section.2 3## a) Generate the .debug_line section from the "DWARF" entry.4 5## Generate and verify a little endian DWARF32 .debug_line section.6 7# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o8# RUN: llvm-readobj --sections --section-data %t1.le.o | \9# RUN:   FileCheck %s -DSIZE=50 -DADDRALIGN=1 --check-prefixes=SHDR,DWARF-LE-CONTENT10 11#                  SHDR: Index: 112#             SHDR-NEXT: Name: .debug_line (1)13#             SHDR-NEXT: Type: SHT_PROGBITS (0x1)14#             SHDR-NEXT: Flags [ (0x0)15#             SHDR-NEXT: ]16#             SHDR-NEXT: Address: 0x017#             SHDR-NEXT: Offset: 0x4018#             SHDR-NEXT: Size: [[SIZE]]19#             SHDR-NEXT: Link: 020#             SHDR-NEXT: Info: 021#             SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]22#             SHDR-NEXT: EntrySize: 023# DWARF-LE-CONTENT-NEXT: SectionData (24# DWARF-LE-CONTENT-NEXT:   0000: 70000000 02003200 00000102 0304050125##                               |        |   |        | |  | | | |26##                               |        |   |        | |  | | | +- standard_opcode_lengths[DW_LNS_copy] (1-byte) 0x0127##                               |        |   |        | |  | | +- opcode_base (1-byte) 0x0528##                               |        |   |        | |  | +- line_range (1-byte) 0x0429##                               |        |   |        | |  +- line_base (signed 1-byte) 0x0330##                               |        |   |        | +- default_is_stmt (1-byte) 0x0231##                               |        |   |        +- minimum_instruction_length (1-byte) 0x0132##                               |        |   +-------- prologue_length (4-byte) 5033##                               |        +--- version (2-byte) 0x0234##                               +------- unit_length (4-byte) 0x7035##36# DWARF-LE-CONTENT-NEXT:   0010: 02030405 06070809 64697231 0064697237##                               | | | |  | | | |  |          |38##                               | | | |  | | | |  |          +----- include_directories[2] "dir2\0"39##                               | | | |  | | | |  +---------- include_directories[1] "dir1\0"40##                               | | | |  | | | +- standard_opcode_lengths[DW_LNS_fixed_advance_pc] (1-byte) 0x0941##                               | | | |  | | +- standard_opcode_lengths[DW_LNS_const_add_pc] (1-byte) 0x0842##                               | | | |  | +- standard_opcode_lengths[DW_LNS_set_basic_block] (1-byte) 0x0743##                               | | | |  +- standard_opcode_lengths[DW_LNS_negate_stmt] (1-byte) 0x0644##                               | | | +- standard_opcode_lengths[DW_LNS_set_column] (1-byte) 0x0545##                               | | +- standard_opcode_lengths[DW_LNS_set_file] (1-byte) 0x0446##                               | +- standard_opcode_lengths[DW_LNS_advance_line] (1-byte) 0x0347##                               +- standard_opcode_lengths[DW_LNS_advance_pc] (1-byte) 0x0248##49# DWARF-LE-CONTENT-NEXT:   0020: 32000061 2E630001 0203622E 6300020350##                               |   | |        |  | | |        | |51##                               |   | |        |  | | |        | +- ModTime (ULEB128) 0x0352##                               |   | |        |  | | |        +- DirIndex (ULEB128) 0x0253##                               |   | |        |  | | +-------- file_names[2] "b.c\0"54##                               |   | |        |  | +- Length (ULEB128) 0x0355##                               |   | |        |  +- ModTime (ULEB128) 0x0256##                               |   | |        +- DirIndex (ULEB128) 0x0157##                               |   | +-------- file_names[1] "a.c\0"58##                               |   +- terminating entry (1-byte) 0x0059##                               +--- the last two bytes of "dir2\0"60##61# DWARF-LE-CONTENT-NEXT:   0030: 040062##                               | |63##                               | +- terminating entry (1-byte) 0x0064##                               +- Length (ULEB128) 0x0465# DWARF-LE-CONTENT-NEXT: )66 67--- !ELF68FileHeader:69  Class: ELFCLASS6470  Data:  [[ENDIAN]]71  Type:  ET_EXEC72DWARF:73  debug_line:74    - Length:         0x7075      Version:        276      PrologueLength: 5077      MinInstLength:  178      DefaultIsStmt:  279      LineBase:       380      LineRange:      481      OpcodeBase:     582      StandardOpcodeLengths: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]83      IncludeDirs:84        - dir185        - dir286      Files:87        - Name:    "a.c"88          DirIdx:  189          ModTime: 290          Length:  391        - Name:    "b.c"92          DirIdx:  293          ModTime: 394          Length:  495 96## Generate and verify a big endian DWARF32 .debug_line section.97 98# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o99# RUN: llvm-readobj --sections --section-data %t1.be.o | \100# RUN:   FileCheck %s -DSIZE=50 -DADDRALIGN=1 --check-prefixes=SHDR,DWARF-BE-CONTENT101 102# DWARF-BE-CONTENT-NEXT: SectionData (103# DWARF-BE-CONTENT-NEXT:   0000: 00000070 00020000 00320102 03040501104##                               |        |   |        | |  | | | |105##                               |        |   |        | |  | | | +- standard_opcode_lengths[DW_LNS_copy] (1-byte) 0x01106##                               |        |   |        | |  | | +- opcode_base (1-byte) 0x05107##                               |        |   |        | |  | +- line_range (1-byte) 0x04108##                               |        |   |        | |  +- line_base (signed 1-byte) 0x03109##                               |        |   |        | +- default_is_stmt (1-byte) 0x02110##                               |        |   |        +- minimum_instruction_length (1-byte) 0x01111##                               |        |   +-------- prologue_length (4-byte) 50112##                               |        +--- version (2-byte) 0x02113##                               +------- unit_length (4-byte) 0x70114##115# DWARF-BE-CONTENT-NEXT:   0010: 02030405 06070809 64697231 00646972116##                               | | | |  | | | |  |          |117##                               | | | |  | | | |  |          +----- include_directories[2] "dir2\0"118##                               | | | |  | | | |  +---------- include_directories[1] "dir1\0"119##                               | | | |  | | | +- standard_opcode_lengths[DW_LNS_fixed_advance_pc] (1-byte) 0x09120##                               | | | |  | | +- standard_opcode_lengths[DW_LNS_const_add_pc] (1-byte) 0x08121##                               | | | |  | +- standard_opcode_lengths[DW_LNS_set_basic_block] (1-byte) 0x07122##                               | | | |  +- standard_opcode_lengths[DW_LNS_negate_stmt] (1-byte) 0x06123##                               | | | +- standard_opcode_lengths[DW_LNS_set_column] (1-byte) 0x05124##                               | | +- standard_opcode_lengths[DW_LNS_set_file] (1-byte) 0x04125##                               | +- standard_opcode_lengths[DW_LNS_advance_line] (1-byte) 0x03126##                               +- standard_opcode_lengths[DW_LNS_advance_pc] (1-byte) 0x02127##128# DWARF-BE-CONTENT-NEXT:   0020: 32000061 2E630001 0203622E 63000203129##                               |   | |        |  | | |        | |130##                               |   | |        |  | | |        | +- ModTime (ULEB128) 0x03131##                               |   | |        |  | | |        +- DirIndex (ULEB128) 0x02132##                               |   | |        |  | | +-------- file_names[2] "b.c\0"133##                               |   | |        |  | +- Length (ULEB128) 0x03134##                               |   | |        |  +- ModTime (ULEB128) 0x02135##                               |   | |        +- DirIndex (ULEB128) 0x01136##                               |   | +-------- file_names[1] "a.c\0"137##                               |   +- terminating entry (1-byte) 0x00138##                               +--- the last two bytes of "dir2\0"139##140# DWARF-BE-CONTENT-NEXT:   0030: 0400141##                               | |142##                               | +- terminating entry (1-byte) 0x00143##                               +- Length (ULEB128) 0x04144# DWARF-BE-CONTENT-NEXT: )145 146## b) Generate the .debug_line section from raw section content.147 148# RUN: yaml2obj --docnum=2 %s -o %t2.o149# RUN: llvm-readobj --sections --section-data %t2.o | \150# RUN:   FileCheck %s -DSIZE=3 -DADDRALIGN=0 --check-prefixes=SHDR,ARBITRARY-CONTENT151 152#      ARBITRARY-CONTENT: SectionData (153# ARBITRARY-CONTENT-NEXT:   0000: 112233 |."3|154# ARBITRARY-CONTENT-NEXT: )155 156--- !ELF157FileHeader:158  Class: ELFCLASS64159  Data:  ELFDATA2LSB160  Type:  ET_EXEC161Sections:162  - Name:    .debug_line163    Type:    SHT_PROGBITS164    Content: "112233"165 166## c) Generate the .debug_line section when the "Size" is specified.167 168# RUN: yaml2obj --docnum=3 %s -o %t3.o169# RUN: llvm-readobj --sections --section-data %t3.o | \170# RUN:   FileCheck %s -DSIZE=16 -DADDRALIGN=0 --check-prefixes=SHDR,SIZE171 172#      SIZE: SectionData (173# SIZE-NEXT:   0000: 00000000 00000000 00000000 00000000 |................|174# SIZE-NEXT: )175 176--- !ELF177FileHeader:178  Class: ELFCLASS64179  Data:  ELFDATA2LSB180  Type:  ET_EXEC181Sections:182  - Name: .debug_line183    Type: SHT_PROGBITS184    Size: 0x10185 186## d) Test that yaml2obj emits an error message when both the "Size" and the187## "debug_line" entry are specified at the same time.188 189# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR190 191# ERROR: yaml2obj: error: cannot specify section '.debug_line' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time192 193--- !ELF194FileHeader:195  Class: ELFCLASS64196  Data:  ELFDATA2LSB197  Type:  ET_EXEC198Sections:199  - Name: .debug_line200    Type: SHT_PROGBITS201    Size: 0x10202DWARF:203  debug_line:204    - Length:                0x70205      Version:               2206      PrologueLength:        50207      MinInstLength:         1208      DefaultIsStmt:         1209      LineBase:              1210      LineRange:             14211      OpcodeBase:            13212      StandardOpcodeLengths: []213 214## e) Test that yaml2obj emits an error message when both the "Content" and the215## "debug_line" entry are specified at the same time.216 217# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR218 219--- !ELF220FileHeader:221  Class: ELFCLASS64222  Data:  ELFDATA2LSB223  Type:  ET_EXEC224Sections:225  - Name:    .debug_line226    Type:    SHT_PROGBITS227    Content: "00"228DWARF:229  debug_line:230    - Length:                0x70231      Version:               2232      PrologueLength:        50233      MinInstLength:         1234      DefaultIsStmt:         1235      LineBase:              1236      LineRange:             14237      OpcodeBase:            13238      StandardOpcodeLengths: []239 240## f) Test that all the properties can be overridden by the section header when241## the "debug_line" entry doesn't exist.242 243# RUN: yaml2obj --docnum=6 %s -o %t6.o244# RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN245 246#      OVERRIDDEN: [Nr] Name        Type   Address          Off    Size   ES Flg Lk Inf Al247#      OVERRIDDEN: [ 1] .debug_line STRTAB 0000000000002020 000050 000011 01   A  2   1  2248# OVERRIDDEN-NEXT: [ 2] .sec        STRTAB 0000000000000000 000061 000000 00      0   0  0249 250--- !ELF251FileHeader:252  Class: ELFCLASS64253  Data:  ELFDATA2LSB254  Type:  ET_EXEC255Sections:256  - Name:         .debug_line257    Type:         SHT_STRTAB  # SHT_PROGBITS by default.258    Flags:        [SHF_ALLOC] # 0 by default.259    Link:         .sec        # 0 by default.260    EntSize:      1           # 0 by default.261    Info:         1           # 0 by default.262    AddressAlign: 2           # 0 by default.263    Address:      0x2020      # 0x00 by default.264    Offset:       0x50        # 0x40 for the first section.265    Size:         0x11        # Set the "Size" so that we can reuse the check tag "OVERRIDDEN".266  - Name:         .sec        # Linked by .debug_line.267    Type:         SHT_STRTAB268 269## g) Test that all the properties can be overridden by the section header when270## the "debug_line" entry exists.271 272# RUN: yaml2obj --docnum=7 %s -o %t7.o273# RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN274 275--- !ELF276FileHeader:277  Class: ELFCLASS64278  Data:  ELFDATA2LSB279  Type:  ET_EXEC280Sections:281  - Name:         .debug_line282    Type:         SHT_STRTAB  # SHT_PROGBITS by default.283    Flags:        [SHF_ALLOC] # 0 by default.284    Link:         .sec        # 0 by default.285    EntSize:      1           # 0 by default.286    Info:         1           # 0 by default.287    AddressAlign: 2           # 1 by default.288    Address:      0x2020      # 0x00 by default.289    Offset:       0x50        # 0x40 for the first section.290  - Name:         .sec        # Linked by .debug_line.291    Type:         SHT_STRTAB292DWARF:293  debug_line:294    - Length:                0x70295      Version:               2296      PrologueLength:        50297      MinInstLength:         1298      DefaultIsStmt:         1299      LineBase:              1300      LineRange:             14301      OpcodeBase:            13302      StandardOpcodeLengths: []303 304## h) Test that the address size is inferred from the target machine.305 306# RUN: yaml2obj --docnum=8 -DBITS=64 -DADDR=0x1234567890abcdef %s -o %t8.64-bit.o307# RUN: llvm-readelf --hex-dump=.debug_line %t8.64-bit.o | \308# RUN:   FileCheck %s --check-prefix=ADDRSIZE -DADDR="efcdab90 78563412"309 310#      ADDRSIZE: Hex dump of section '.debug_line':311# ADDRSIZE-NEXT: 0x00000000 34120000 02003412 00000101 010e0d00 4.....4.........312##                          ^-------                            unit_length (4-byte)313##                                   ^---                       version (2-byte)314##                                       ^--------              header_length (4-byte)315##                                                ^-            minimum_instruction_length (1-byte)316##                                                  ^-          default_is_stmt (1-byte)317##                                                     ^-       line_base (1-byte)318##                                                       ^-     line_range (1-byte)319##                                                         ^-   opcode_base (1-byte)320##                                                           ^- null byte for terminating include_directories321# ADDRSIZE-NEXT: 0x00000010 00000902 [[ADDR]]322##                          ^-                                  null byte for terminating file_names323##                            ^-                                DW_LNS_extended_op324##                              ^-                              extended op length (ULEB128) 0x09325##                                ^-                            DW_LNE_set_address326##                                   ^-------                   address327 328# RUN: yaml2obj --docnum=8 -DBITS=32 -DADDR=0x12345678 %s -o %t8.32-bit.o329# RUN: llvm-readelf --hex-dump=.debug_line %t8.32-bit.o | \330# RUN:   FileCheck %s --check-prefix=ADDRSIZE -DADDR="78563412"331 332--- !ELF333FileHeader:334  Class: ELFCLASS[[BITS]]335  Data:  ELFDATA2LSB336  Type:  ET_EXEC337DWARF:338  debug_line:339    - Length:                0x1234340      Version:               2341      PrologueLength:        0x1234342      MinInstLength:         1343      DefaultIsStmt:         1344      LineBase:              1345      LineRange:             14346      OpcodeBase:            13347      StandardOpcodeLengths: []348      Opcodes:349        - Opcode:    DW_LNS_extended_op350          ExtLen:    9351          SubOpcode: DW_LNE_set_address352          Data:      [[ADDR]]353 354## i) Test that yaml2obj is able to emit correct opcodes.355 356# RUN: yaml2obj --docnum=9 %s -o %t9.o357# RUN: llvm-readelf --hex-dump=.debug_line %t9.o | FileCheck %s --check-prefix=OPCODES358 359#      OPCODES: Hex dump of section '.debug_line':360# OPCODES-NEXT: 0x00000000 34120000 04003412 00000101 01010e0d 4.....4.........361##                         ^-------                            unit_length (4-byte)362##                                  ^---                       version (2-byte)363##                                      ^--------              header_length (4-byte)364##                                               ^-            minimum_instruction_length (1-byte)365##                                                 ^-          maximum_operations_per_instruction (1-byte)366##                                                    ^-       default_is_stmt (1-byte)367##                                                      ^-     line_base (1-byte)368##                                                        ^-   line_range (1-byte)369##                                                          ^- opcode_base (1-byte)370# OPCODES-NEXT: 0x00000010 00000102 b42403b4 2404b424 05b42406 .....$..$..$..$.371##                         ^-                                  null byte for terminating include_directories372##                           ^-                                null byte for terminating file_names373##                             ^-                              DW_LNS_copy (1-byte)374##                               ^-                            DW_LNS_advance_pc375##                                  ^---                       operands[0] (ULEB128) 0x1234376##                                      ^-                     DW_LNS_advance_line377##                                        ^----                operands[0] (SLEB128) 0x1234378##                                             ^-              DW_LNS_set_file379##                                               ^---          operands[0] (ULEB128) 0x1234380##                                                    ^-       DW_LNS_set_column381##                                                      ^---   operands[0] (ULEB128) 0x1234382##                                                          ^- DW_LNS_negate_stmt383# OPCODES-NEXT: 0x00000020 07080934 120a0b0c b4240009 01000902 ...4.....$......384##                         ^-                                  DW_LNS_set_basic_block385##                           ^-                                DW_LNS_const_add_pc386##                             ^-                              DW_LNS_fixed_advance_pc387##                               ^----                         operands[0] (uhalf, 2-byte)388##                                    ^-                       DW_LNS_set_prologue_end389##                                      ^-                     DW_LNS_set_epilogue_begin390##                                        ^-                   DW_LNS_set_isa391##                                           ^---              operands[0] (ULEB128) 0x1234392##                                               ^-            DW_LNS_extended_op393##                                                 ^-          extended op length (ULEB128) 0x09394##                                                    ^-       DW_LNE_end_sequence395##                                                      ^-     DW_LNS_extended_op396##                                                        ^-   extended op length (ULEB128) 0x09397##                                                          ^- DW_LNE_set_address398# OPCODES-NEXT: 0x00000030 34120000 00000000 00090361 62636400 4..........abcd.399##                         ^----------------                   operands[0] (8-byte)400##                                           ^-                DW_LNS_extended_op401##                                             ^-              extended op length (ULEB128) 0x09402##                                               ^-            DW_LNE_define_file403##                                                 ^---------- operands[0] "abcd\0"404# OPCODES-NEXT: 0x00000040 b424b424 b4240009 04b424            .$.$.$....$405##                         ^---                                operands[1] (ULEB128) 0x1234406##                             ^---                            operands[2] (ULEB128) 0x1234407##                                  ^---                       operands[3] (ULEB128) 0x1234408##                                      ^-                     DW_LNS_extended_op409##                                        ^-                   extended op length (ULEB128) 0x09410##                                           ^-                DW_LNE_set_discriminator411##                                             ^---            operands[0] (ULEB128) 0x1234412 413--- !ELF414FileHeader:415  Class: ELFCLASS64416  Data:  ELFDATA2LSB417  Type:  ET_EXEC418DWARF:419  debug_line:420    - Length:                0x1234421      Version:               4422      PrologueLength:        0x1234423      MinInstLength:         1424      MaxOpsPerInst:         1425      DefaultIsStmt:         1426      LineBase:              1427      LineRange:             14428      OpcodeBase:            13429      StandardOpcodeLengths: []430      Opcodes:431        - Opcode:    DW_LNS_copy432        - Opcode:    DW_LNS_advance_pc433          Data:      0x1234434        - Opcode:    DW_LNS_advance_line435          SData:     0x1234436        - Opcode:    DW_LNS_set_file437          Data:      0x1234438        - Opcode:    DW_LNS_set_column439          Data:      0x1234440        - Opcode:    DW_LNS_negate_stmt441        - Opcode:    DW_LNS_set_basic_block442        - Opcode:    DW_LNS_const_add_pc443        - Opcode:    DW_LNS_fixed_advance_pc444          Data:      0x1234445        - Opcode:    DW_LNS_set_prologue_end446        - Opcode:    DW_LNS_set_epilogue_begin447        - Opcode:    DW_LNS_set_isa448          Data:      0x1234449        - Opcode:    DW_LNS_extended_op450          ExtLen:    0x09451          SubOpcode: DW_LNE_end_sequence452        - Opcode:    DW_LNS_extended_op453          ExtLen:    0x09454          SubOpcode: DW_LNE_set_address455          Data:      0x1234456        - Opcode:    DW_LNS_extended_op457          ExtLen:    0x09458          SubOpcode: DW_LNE_define_file459          FileEntry:460            Name:    abcd461            DirIdx:  0x1234462            ModTime: 0x1234463            Length:  0x1234464        - Opcode:    DW_LNS_extended_op465          ExtLen:    0x09466          SubOpcode: DW_LNE_set_discriminator467          Data:      0x1234468 469## j) Test that yaml2obj is able to infer the length and header_length fields.470 471# RUN: yaml2obj --docnum=10 %s -o %t10.o472# RUN: llvm-readelf --hex-dump=.debug_line %t10.o | FileCheck %s --check-prefix=INFER-LENGTH473 474#      INFER-LENGTH: Hex dump of section '.debug_line':475# INFER-LENGTH-NEXT: 0x00000000 2e000000 04002500 00000101 01fb0e04 ......%.........476##                              ^-------                            unit_length (4-byte) 0x2e477##                                       ^---                       version (2-byte)478##                                           ^--------              header_length (4-byte) 0x25479##                                                    ^-            minimum_instruction_length (1-byte)480##                                                      ^-          maximum_operations_per_instruction (1-byte)481##                                                         ^-       default_is_stmt (1-byte)482##                                                           ^-     line_base (1-byte) -5483##                                                             ^-   line_range (1-byte)484##                                                               ^- opcode_base (1-byte)485# INFER-LENGTH-NEXT: 0x00000010 00010174 656d7031 0074656d 70320000 ...temp1.temp2..486##                              ^-----                              standard_opcode_lengths (3-byte)487##                                    ^-------------                include_directories[1] "temp1\0"488##                                                  ^------------   include_directories[2] "temp1\0"489##                                                               ^- include_directories null byte490# INFER-LENGTH-NEXT: 0x00000020 612e6300 01000062 2e630002 00000000 a.c....b.c......491##                              ^-------                            file_names[1] file name "a.c\0"492##                                       ^-                         file_names[1] directory index (ULEB128) 0x01493##                                         ^-                       file_names[1] file length (ULEB128) 0x00494##                                           ^-                     file_names[1] modification time 0x00495##                                             ^--------            file_names[2] file name "b.c\0"496##                                                      ^-          file_names[2] directory index (ULEB128) 0x02497##                                                         ^-       file_names[2] file length (ULEB128) 0x00498##                                                           ^-     file_names[2] modification time 0x00499##                                                             ^-   file_names null byte500##                                                               ^- DW_LNS_extended_op501# INFER-LENGTH-NEXT: 0x00000030 0101ffff ffff2500 00000000 00000400 ......%.........502##                              ^-                                  extended op length (ULEB128) 0x01503##                                ^-                                DW_LNE_end_sequence504##                                  ^--------------------------     unit_length (12-byte)505##                                                             ^--- version (2-byte)506# INFER-LENGTH-NEXT: 0x00000040 18000000 00000000 010101fb 0e040001 ................507##                              ^----------------                   header_length (8-byte)508##                                                ^-                minimum_instruction_length (1-byte)509##                                                  ^-              maximum_operations_per_instruction (1-byte)510##                                                    ^-            default_is_stmt (1-byte)511##                                                      ^-          line_base (1-byte) -5512##                                                         ^-       line_range (1-byte)513##                                                           ^-     opcode_base (1-byte)514##                                                             ^--- standard_opcode_lengths (3-byte)515# INFER-LENGTH-NEXT: 0x00000050 0174656d 70330000 632e6300 01000000 .temp3..c.c.....516##                              --517##                                ^------------                     include_directories[1] "temp3\0"518##                                             ^-                   include_directories null byte519##                                                ^-------          file_names[1] file name "a.c\0"520##                                                         ^-       file_names[1] directory index (ULEB128) 0x01521##                                                           ^-     file_names[1] file length (ULEB128) 0x00522##                                                             ^-   file_names[1] modification time 0x00523##                                                               ^- file_names null byte524# INFER-LENGTH-NEXT: 0x00000060 000101                              ...525##                              ^-                                  DW_LNS_extended_op526##                                ^-                                extended op length (ULEB128) 0x01527##                                  ^-                              DW_LNE_end_sequence528 529--- !ELF530FileHeader:531  Class: ELFCLASS64532  Data:  ELFDATA2LSB533  Type:  ET_EXEC534DWARF:535  debug_line:536    - Version:               4537      MinInstLength:         1538      MaxOpsPerInst:         1539      DefaultIsStmt:         1540      LineBase:              251541      LineRange:             14542      OpcodeBase:            4543      StandardOpcodeLengths: [ 0, 1, 1 ]544      IncludeDirs:545        - temp1546        - temp2547      Files:548        - Name:    a.c549          DirIdx:  1550          ModTime: 0551          Length:  0552        - Name:    b.c553          DirIdx:  2554          ModTime: 0555          Length:  0556      Opcodes:557        - Opcode:    DW_LNS_extended_op558          ExtLen:    1559          SubOpcode: DW_LNE_end_sequence560    - Format:                DWARF64561      Version:               4562      MinInstLength:         1563      MaxOpsPerInst:         1564      DefaultIsStmt:         1565      LineBase:              251566      LineRange:             14567      OpcodeBase:            4568      StandardOpcodeLengths: [ 0, 1, 1 ]569      IncludeDirs:570        - temp3571      Files:572        - Name:    c.c573          DirIdx:  1574          ModTime: 0575          Length:  0576      Opcodes:577        - Opcode:    DW_LNS_extended_op578          ExtLen:    1579          SubOpcode: DW_LNE_end_sequence580 581## k) Test that we can omit the include_directories, file_names and opcodes582## fields of the line table.583 584# RUN: yaml2obj --docnum=11 %s -o %t11.o585# RUN: llvm-readelf --hex-dump=.debug_line %t11.o | \586# RUN:   FileCheck %s --check-prefix=OMIT-FIELDS587 588#      OMIT-FIELDS: Hex dump of section '.debug_line':589# OMIT-FIELDS-NEXT: 0x00000000 11000000 04000b00 00000101 01fb0e04 ................590##                             ^-------                            unit_length (4-byte)591##                                      ^---                       version (2-byte)592##                                          ^--------              header_length (4-byte)593##                                                   ^-            minimum_instruction_length (1-byte)594##                                                     ^-          maximum_operations_per_instruction (1-byte)595##                                                        ^-       default_is_stmt (1-byte)596##                                                          ^-     line_base (1-byte) -5597##                                                            ^-   line_range (1-byte)598##                                                              ^- opcode_base (1-byte)599# OMIT-FIELDS-NEXT: 0x00000010 00010100 00                         .....600##                             ^-----                              standard_opcode_lengths (3-byte)601##                                   ^-                            include_directories null byte (1-byte)602##                                      ^-                         file_names null byte (1-byte)603 604--- !ELF605FileHeader:606  Class: ELFCLASS64607  Data:  ELFDATA2LSB608  Type:  ET_EXEC609DWARF:610  debug_line:611    - Version:               4612      MinInstLength:         1613      MaxOpsPerInst:         1614      DefaultIsStmt:         1615      LineBase:              251616      LineRange:             14617      OpcodeBase:            4618      StandardOpcodeLengths: [ 0, 1, 1 ]619 620## l) Test that we can specify or omit the ExtLen field of extended opcodes.621 622# RUN: yaml2obj --docnum=12 %s -o %t12.o623# RUN: llvm-readelf --hex-dump=.debug_line %t12.o | \624# RUN:   FileCheck %s --check-prefix=EXTLEN --strict-whitespace625 626#      EXTLEN: Hex dump of section '.debug_line':627# EXTLEN-NEXT: 0x00000000 20000000 04000800 00000101 01fb0e01628##                        ^---------------------------------- line number program header629# EXTLEN-NEXT: 0x00000010 0000000c 03616263 6400b424 b424b424630##                        ----631##                            ^-                              DW_LNS_extended_op632##                              ^-                            extended opcode length (ULEB128) 12633##                                 ^-                         DW_LNE_define_file634##                                   ^----------              "abcd\0"635##                                              ^---          directory index (ULEB128) 0x1234636##                                                   ^---     modification time (ULEB128) 0x1234637##                                                       ^--- file length (ULEB128) 0x1234638# EXTLEN-NEXT: 0x00000020 00b42401{{  }}639##                        ^-                                  DW_LNS_extended_op640##                          ^---                              extended opcode length (ULEB128) 0x1234641##                              ^-                            DW_LNE_end_sequence642 643--- !ELF644FileHeader:645  Class: ELFCLASS64646  Data:  ELFDATA2LSB647  Type:  ET_EXEC648DWARF:649  debug_line:650    - Version:               4651      MinInstLength:         1652      MaxOpsPerInst:         1653      DefaultIsStmt:         1654      LineBase:              251655      LineRange:             14656      OpcodeBase:            1657      StandardOpcodeLengths: []658      Opcodes:659        - Opcode:    DW_LNS_extended_op660          ## Omit the ExtLen field.661          SubOpcode: DW_LNE_define_file662          FileEntry:663            Name:    abcd664            DirIdx:  0x1234665            ModTime: 0x1234666            Length:  0x1234667        - Opcode:    DW_LNS_extended_op668          ## Specify the ExtLen field.669          ExtLen:    0x1234670          SubOpcode: DW_LNE_end_sequence671 672## m) Test how yaml2obj generates the opcode_base and the673## standard_opcode_lengths fields.674 675## Both the opcode_base and the standard_opcode_lengths fields are not676## specified (DWARFv2).677 678# RUN: yaml2obj --docnum=13 -DVERSION=2 -DMAXOPSPERINST='' %s -o %t13.o679# RUN: llvm-readelf --hex-dump=.debug_line %t13.o | \680# RUN:   FileCheck %s --check-prefix=OPCODEBASEV2681 682#      OPCODEBASEV2: Hex dump of section '.debug_line':683# OPCODEBASEV2-NEXT: 0x00000000 16000000 02001000 00000101 00010a00 ................684##                                                             ^-   opcode_base (10)685##                                                               ^- standard_opcode_lengths[DW_LNS_copy] = 0686# OPCODEBASEV2-NEXT: 0x00000010 01010101 00000001 0000              ..........687##                              ^-                                  standard_opcode_lengths[DW_LNS_advance_pc] = 1688##                                ^-                                standard_opcode_lengths[DW_LNS_advance_line] = 1689##                                  ^-                              standard_opcode_lengths[DW_LNS_set_file] = 1690##                                    ^-                            standard_opcode_lengths[DW_LNS_set_column] = 1691##                                       ^-                         standard_opcode_lengths[DW_LNS_negate_stmt] = 0692##                                         ^-                       standard_opcode_lengths[DW_LNS_set_basic_block] = 0693##                                           ^-                     standard_opcode_lengths[DW_LNS_const_add_pc] = 0694##                                             ^-                   standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1695##                                                ^---              terminators for include_directories and file_names696 697--- !ELF698FileHeader:699  Class: ELFCLASS64700  Data:  ELFDATA2LSB701  Type:  ET_EXEC702DWARF:703  debug_line:704    - Version:               [[VERSION=4]]705      MinInstLength:         1706      [[MAXOPSPERINST=MaxOpsPerInst: 0]]707      DefaultIsStmt:         1708      LineBase:              0709      LineRange:             1710      OpcodeBase:            [[OPCODEBASE=<none>]]711      StandardOpcodeLengths: [[STANDARDOPCODELENGTHS=<none>]]712 713## Both the opcode_base and the standard_opcode_lengths fields are not714## specified (DWARFv3).715 716# RUN: yaml2obj --docnum=13 -DVERSION=3 -DMAXOPSPERINST='' %s -o %t14.o717# RUN: llvm-readelf --hex-dump=.debug_line %t14.o | \718# RUN:   FileCheck %s --check-prefix=OPCODEBASEV3719 720#      OPCODEBASEV3: Hex dump of section '.debug_line':721# OPCODEBASEV3-NEXT: 0x00000000 19000000 03001300 00000101 00010d00 ................722##                                                             ^-   opcode_base (13)723##                                                               ^- standard_opcode_lengths[DW_LNS_copy] = 0724# OPCODEBASEV3-NEXT: 0x00000010 01010101 00000001 00000100 00       .............725##                              ^-                                  standard_opcode_lengths[DW_LNS_advance_pc] = 1726##                                ^-                                standard_opcode_lengths[DW_LNS_advance_line] = 1727##                                  ^-                              standard_opcode_lengths[DW_LNS_set_file] = 1728##                                    ^-                            standard_opcode_lengths[DW_LNS_set_column] = 1729##                                       ^-                         standard_opcode_lengths[DW_LNS_negate_stmt] = 0730##                                         ^-                       standard_opcode_lengths[DW_LNS_set_basic_block] = 0731##                                           ^-                     standard_opcode_lengths[DW_LNS_const_add_pc] = 0732##                                             ^-                   standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1733##                                                ^-                standard_opcode_lengths[DW_LNS_set_prologue_end] = 0734##                                                  ^-              standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0735##                                                    ^-            standard_opcode_lengths[DW_LNS_set_isa] = 1736##                                                      ^----       terminators for include_directories and file_names737 738## Both the opcode_base and the standard_opcode_lengths fields are not739## specified (DWARFv4).740 741# RUN: yaml2obj --docnum=13 %s -o %t15.o742# RUN: llvm-readelf --hex-dump=.debug_line %t15.o | \743# RUN:   FileCheck %s --check-prefix=OPCODEBASEV4744 745#      OPCODEBASEV4: Hex dump of section '.debug_line':746# OPCODEBASEV4-NEXT: 0x00000000 1a000000 04001400 00000100 0100010d ................747##                                                              ^- opcode_base (13)748# OPCODEBASEV4-NEXT: 0x00000010 00010101 01000000 01000001 0000     ..............749##                              ^-                                  standard_opcode_lengths[DW_LNS_copy] = 0750##                                ^-                                standard_opcode_lengths[DW_LNS_advance_pc] = 1751##                                  ^-                              standard_opcode_lengths[DW_LNS_advance_line] = 1752##                                    ^-                            standard_opcode_lengths[DW_LNS_set_file] = 1753##                                       ^-                         standard_opcode_lengths[DW_LNS_set_column] = 1754##                                         ^-                       standard_opcode_lengths[DW_LNS_negate_stmt] = 0755##                                           ^-                     standard_opcode_lengths[DW_LNS_set_basic_block] = 0756##                                             ^-                   standard_opcode_lengths[DW_LNS_const_add_pc] = 0757##                                                ^-                standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1758##                                                  ^-              standard_opcode_lengths[DW_LNS_set_prologue_end] = 0759##                                                    ^-            standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0760##                                                      ^-          standard_opcode_lengths[DW_LNS_set_isa] = 1761##                                                         ^---     terminators for include_directories and file_names762 763## Specify the opcode_base field (opcode_base == 0).764 765# RUN: yaml2obj --docnum=13 -DOPCODEBASE=0 %s -o %t16.o766# RUN: llvm-readelf --hex-dump=.debug_line %t16.o | \767# RUN:   FileCheck %s --check-prefix=ZERO-OPCODEBASE768 769#      ZERO-OPCODEBASE: Hex dump of section '.debug_line':770# ZERO-OPCODEBASE-NEXT: 0x00000000 0e000000 04000800 00000100 01000100 ................771##                                                                  ^- opcode_base (0)772# ZERO-OPCODEBASE-NEXT: 0x00000010 0000                                ..773##                                 ^---                                terminators for include_directories and file_names774 775## Specify the opcode_base field (opcode_base != 0, opcode_base - 1 < 12).776## The standard_opcode_lengths array will be truncated.777 778# RUN: yaml2obj --docnum=13 -DOPCODEBASE=4 %s -o %t17.o779# RUN: llvm-readelf --hex-dump=.debug_line %t17.o | \780# RUN:   FileCheck %s --check-prefix=OPCODEBASE781 782#      OPCODEBASE: Hex dump of section '.debug_line':783# OPCODEBASE-NEXT: 0x00000000 11000000 04000b00 00000100 01000104 ................784##                                                             ^- opcode_base (4)785# OPCODEBASE-NEXT: 0x00000010 00010100 00                         .....786##                            ^-----                              standard_opcode_lengths (3-byte)787##                                  ^----                         terminators for include_directories and file_names788 789## Specify the opcode_base field (opcode_base != 0, opcode_base - 1 > 12).790## The standard_opcode_lengths array will be extended.791 792# RUN: yaml2obj --docnum=13 -DOPCODEBASE=20 %s -o %t18.o793# RUN: llvm-readelf --hex-dump=.debug_line %t18.o | \794# RUN:   FileCheck %s --check-prefix=OPCODEBASE1795 796#      OPCODEBASE1: Hex dump of section '.debug_line':797# OPCODEBASE1-NEXT: 0x00000000 21000000 04001b00 00000100 01000114 !...............798##                                                              ^- opcode_base (20)799# OPCODEBASE1-NEXT: 0x00000010 00010101 01000000 01000001 00000000 ................800##                             ^-------------------------          standard_opcode_lengths defined in DWARFv5 (12-byte)801##                                                        ^------- extended standard_opcode_lengths (7-byte)802# OPCODEBASE1-NEXT: 0x00000020 00000000 00                         .....803##                             ------804##                                   ^----                         terminators for include_directories and file_names805 806## Specify the standard_opcode_lengths field.807 808# RUN: yaml2obj --docnum=13 -DSTANDARDOPCODELENGTHS=[0,1,0] %s -o %t19.o809# RUN: llvm-readelf --hex-dump=.debug_line %t19.o | \810# RUN:   FileCheck %s --check-prefix=OPCODELENGTHS811 812#      OPCODELENGTHS: Hex dump of section '.debug_line':813# OPCODELENGTHS-NEXT: 0x00000000 11000000 04000b00 00000100 01000104 ................814##                                                                ^- opcode_base (4)815# OPCODELENGTHS-NEXT: 0x00000010 00010000 00                         .....816##                               ^-----                              standard_opcode_lengths (3-byte)817##                                     ^----                         terminators for include_directories and file_names818 819## Specify both the opcode_base and the standard_opcode_lengths fields.820 821# RUN: yaml2obj --docnum=13 -DOPCODEBASE=2 -DSTANDARDOPCODELENGTHS=[0,1,0] %s -o %t20.o822# RUN: llvm-readelf --hex-dump=.debug_line %t20.o | \823# RUN:   FileCheck %s --check-prefix=OPCODEBASE-LENGTHS824 825#      OPCODEBASE-LENGTHS: Hex dump of section '.debug_line':826# OPCODEBASE-LENGTHS-NEXT: 0x00000000 11000000 04000b00 00000100 01000102 ................827##                                                                     ^- opcode_base (2)828# OPCODEBASE-LENGTHS-NEXT: 0x00000010 00010000 00                         .....829##                                    ^-----                              standard_opcode_lengths (3-byte)830##                                          ^----                         terminators for include_directories and file_names831