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.o 8# RUN: llvm-readobj --sections --section-data %t1.le.o | \ 9# RUN: FileCheck %s -DSIZE=50 -DADDRALIGN=1 --check-prefixes=SHDR,DWARF-LE-CONTENT 10 11# SHDR: Index: 1 12# 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: 0x0 17# SHDR-NEXT: Offset: 0x40 18# SHDR-NEXT: Size: [[SIZE]] 19# SHDR-NEXT: Link: 0 20# SHDR-NEXT: Info: 0 21# SHDR-NEXT: AddressAlignment: [[ADDRALIGN]] 22# SHDR-NEXT: EntrySize: 0 23# DWARF-LE-CONTENT-NEXT: SectionData ( 24# DWARF-LE-CONTENT-NEXT: 0000: 70000000 02003200 00000102 03040501 25## | | | | | | | | | 26## | | | | | | | | +- standard_opcode_lengths[DW_LNS_copy] (1-byte) 0x01 27## | | | | | | | +- opcode_base (1-byte) 0x05 28## | | | | | | +- line_range (1-byte) 0x04 29## | | | | | +- line_base (signed 1-byte) 0x03 30## | | | | +- default_is_stmt (1-byte) 0x02 31## | | | +- minimum_instruction_length (1-byte) 0x01 32## | | +-------- prologue_length (4-byte) 50 33## | +--- version (2-byte) 0x02 34## +------- unit_length (4-byte) 0x70 35## 36# DWARF-LE-CONTENT-NEXT: 0010: 02030405 06070809 64697231 00646972 37## | | | | | | | | | | 38## | | | | | | | | | +----- include_directories[2] "dir2\0" 39## | | | | | | | | +---------- include_directories[1] "dir1\0" 40## | | | | | | | +- standard_opcode_lengths[DW_LNS_fixed_advance_pc] (1-byte) 0x09 41## | | | | | | +- standard_opcode_lengths[DW_LNS_const_add_pc] (1-byte) 0x08 42## | | | | | +- standard_opcode_lengths[DW_LNS_set_basic_block] (1-byte) 0x07 43## | | | | +- standard_opcode_lengths[DW_LNS_negate_stmt] (1-byte) 0x06 44## | | | +- standard_opcode_lengths[DW_LNS_set_column] (1-byte) 0x05 45## | | +- standard_opcode_lengths[DW_LNS_set_file] (1-byte) 0x04 46## | +- standard_opcode_lengths[DW_LNS_advance_line] (1-byte) 0x03 47## +- standard_opcode_lengths[DW_LNS_advance_pc] (1-byte) 0x02 48## 49# DWARF-LE-CONTENT-NEXT: 0020: 32000061 2E630001 0203622E 63000203 50## | | | | | | | | | 51## | | | | | | | | +- ModTime (ULEB128) 0x03 52## | | | | | | | +- DirIndex (ULEB128) 0x02 53## | | | | | | +-------- file_names[2] "b.c\0" 54## | | | | | +- Length (ULEB128) 0x03 55## | | | | +- ModTime (ULEB128) 0x02 56## | | | +- DirIndex (ULEB128) 0x01 57## | | +-------- file_names[1] "a.c\0" 58## | +- terminating entry (1-byte) 0x00 59## +--- the last two bytes of "dir2\0" 60## 61# DWARF-LE-CONTENT-NEXT: 0030: 0400 62## | | 63## | +- terminating entry (1-byte) 0x00 64## +- Length (ULEB128) 0x04 65# DWARF-LE-CONTENT-NEXT: ) 66 67--- !ELF 68FileHeader: 69 Class: ELFCLASS64 70 Data: [[ENDIAN]] 71 Type: ET_EXEC 72DWARF: 73 debug_line: 74 - Length: 0x70 75 Version: 2 76 PrologueLength: 50 77 MinInstLength: 1 78 DefaultIsStmt: 2 79 LineBase: 3 80 LineRange: 4 81 OpcodeBase: 5 82 StandardOpcodeLengths: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] 83 IncludeDirs: 84 - dir1 85 - dir2 86 Files: 87 - Name: "a.c" 88 DirIdx: 1 89 ModTime: 2 90 Length: 3 91 - Name: "b.c" 92 DirIdx: 2 93 ModTime: 3 94 Length: 4 95 96## Generate and verify a big endian DWARF32 .debug_line section. 97 98# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o 99# RUN: llvm-readobj --sections --section-data %t1.be.o | \ 100# RUN: FileCheck %s -DSIZE=50 -DADDRALIGN=1 --check-prefixes=SHDR,DWARF-BE-CONTENT 101 102# DWARF-BE-CONTENT-NEXT: SectionData ( 103# DWARF-BE-CONTENT-NEXT: 0000: 00000070 00020000 00320102 03040501 104## | | | | | | | | | 105## | | | | | | | | +- standard_opcode_lengths[DW_LNS_copy] (1-byte) 0x01 106## | | | | | | | +- opcode_base (1-byte) 0x05 107## | | | | | | +- line_range (1-byte) 0x04 108## | | | | | +- line_base (signed 1-byte) 0x03 109## | | | | +- default_is_stmt (1-byte) 0x02 110## | | | +- minimum_instruction_length (1-byte) 0x01 111## | | +-------- prologue_length (4-byte) 50 112## | +--- version (2-byte) 0x02 113## +------- unit_length (4-byte) 0x70 114## 115# DWARF-BE-CONTENT-NEXT: 0010: 02030405 06070809 64697231 00646972 116## | | | | | | | | | | 117## | | | | | | | | | +----- include_directories[2] "dir2\0" 118## | | | | | | | | +---------- include_directories[1] "dir1\0" 119## | | | | | | | +- standard_opcode_lengths[DW_LNS_fixed_advance_pc] (1-byte) 0x09 120## | | | | | | +- standard_opcode_lengths[DW_LNS_const_add_pc] (1-byte) 0x08 121## | | | | | +- standard_opcode_lengths[DW_LNS_set_basic_block] (1-byte) 0x07 122## | | | | +- standard_opcode_lengths[DW_LNS_negate_stmt] (1-byte) 0x06 123## | | | +- standard_opcode_lengths[DW_LNS_set_column] (1-byte) 0x05 124## | | +- standard_opcode_lengths[DW_LNS_set_file] (1-byte) 0x04 125## | +- standard_opcode_lengths[DW_LNS_advance_line] (1-byte) 0x03 126## +- standard_opcode_lengths[DW_LNS_advance_pc] (1-byte) 0x02 127## 128# DWARF-BE-CONTENT-NEXT: 0020: 32000061 2E630001 0203622E 63000203 129## | | | | | | | | | 130## | | | | | | | | +- ModTime (ULEB128) 0x03 131## | | | | | | | +- DirIndex (ULEB128) 0x02 132## | | | | | | +-------- file_names[2] "b.c\0" 133## | | | | | +- Length (ULEB128) 0x03 134## | | | | +- ModTime (ULEB128) 0x02 135## | | | +- DirIndex (ULEB128) 0x01 136## | | +-------- file_names[1] "a.c\0" 137## | +- terminating entry (1-byte) 0x00 138## +--- the last two bytes of "dir2\0" 139## 140# DWARF-BE-CONTENT-NEXT: 0030: 0400 141## | | 142## | +- terminating entry (1-byte) 0x00 143## +- Length (ULEB128) 0x04 144# 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.o 149# RUN: llvm-readobj --sections --section-data %t2.o | \ 150# RUN: FileCheck %s -DSIZE=3 -DADDRALIGN=0 --check-prefixes=SHDR,ARBITRARY-CONTENT 151 152# ARBITRARY-CONTENT: SectionData ( 153# ARBITRARY-CONTENT-NEXT: 0000: 112233 |."3| 154# ARBITRARY-CONTENT-NEXT: ) 155 156--- !ELF 157FileHeader: 158 Class: ELFCLASS64 159 Data: ELFDATA2LSB 160 Type: ET_EXEC 161Sections: 162 - Name: .debug_line 163 Type: SHT_PROGBITS 164 Content: "112233" 165 166## c) Generate the .debug_line section when the "Size" is specified. 167 168# RUN: yaml2obj --docnum=3 %s -o %t3.o 169# RUN: llvm-readobj --sections --section-data %t3.o | \ 170# RUN: FileCheck %s -DSIZE=16 -DADDRALIGN=0 --check-prefixes=SHDR,SIZE 171 172# SIZE: SectionData ( 173# SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................| 174# SIZE-NEXT: ) 175 176--- !ELF 177FileHeader: 178 Class: ELFCLASS64 179 Data: ELFDATA2LSB 180 Type: ET_EXEC 181Sections: 182 - Name: .debug_line 183 Type: SHT_PROGBITS 184 Size: 0x10 185 186## d) Test that yaml2obj emits an error message when both the "Size" and the 187## "debug_line" entry are specified at the same time. 188 189# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR 190 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 time 192 193--- !ELF 194FileHeader: 195 Class: ELFCLASS64 196 Data: ELFDATA2LSB 197 Type: ET_EXEC 198Sections: 199 - Name: .debug_line 200 Type: SHT_PROGBITS 201 Size: 0x10 202DWARF: 203 debug_line: 204 - Length: 0x70 205 Version: 2 206 PrologueLength: 50 207 MinInstLength: 1 208 DefaultIsStmt: 1 209 LineBase: 1 210 LineRange: 14 211 OpcodeBase: 13 212 StandardOpcodeLengths: [] 213 214## e) Test that yaml2obj emits an error message when both the "Content" and the 215## "debug_line" entry are specified at the same time. 216 217# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR 218 219--- !ELF 220FileHeader: 221 Class: ELFCLASS64 222 Data: ELFDATA2LSB 223 Type: ET_EXEC 224Sections: 225 - Name: .debug_line 226 Type: SHT_PROGBITS 227 Content: "00" 228DWARF: 229 debug_line: 230 - Length: 0x70 231 Version: 2 232 PrologueLength: 50 233 MinInstLength: 1 234 DefaultIsStmt: 1 235 LineBase: 1 236 LineRange: 14 237 OpcodeBase: 13 238 StandardOpcodeLengths: [] 239 240## f) Test that all the properties can be overridden by the section header when 241## the "debug_line" entry doesn't exist. 242 243# RUN: yaml2obj --docnum=6 %s -o %t6.o 244# RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN 245 246# OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al 247# OVERRIDDEN: [ 1] .debug_line STRTAB 0000000000002020 000050 000011 01 A 2 1 2 248# OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 000061 000000 00 0 0 0 249 250--- !ELF 251FileHeader: 252 Class: ELFCLASS64 253 Data: ELFDATA2LSB 254 Type: ET_EXEC 255Sections: 256 - Name: .debug_line 257 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_STRTAB 268 269## g) Test that all the properties can be overridden by the section header when 270## the "debug_line" entry exists. 271 272# RUN: yaml2obj --docnum=7 %s -o %t7.o 273# RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN 274 275--- !ELF 276FileHeader: 277 Class: ELFCLASS64 278 Data: ELFDATA2LSB 279 Type: ET_EXEC 280Sections: 281 - Name: .debug_line 282 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_STRTAB 292DWARF: 293 debug_line: 294 - Length: 0x70 295 Version: 2 296 PrologueLength: 50 297 MinInstLength: 1 298 DefaultIsStmt: 1 299 LineBase: 1 300 LineRange: 14 301 OpcodeBase: 13 302 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.o 307# 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_directories 321# ADDRSIZE-NEXT: 0x00000010 00000902 [[ADDR]] 322## ^- null byte for terminating file_names 323## ^- DW_LNS_extended_op 324## ^- extended op length (ULEB128) 0x09 325## ^- DW_LNE_set_address 326## ^------- address 327 328# RUN: yaml2obj --docnum=8 -DBITS=32 -DADDR=0x12345678 %s -o %t8.32-bit.o 329# RUN: llvm-readelf --hex-dump=.debug_line %t8.32-bit.o | \ 330# RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDR="78563412" 331 332--- !ELF 333FileHeader: 334 Class: ELFCLASS[[BITS]] 335 Data: ELFDATA2LSB 336 Type: ET_EXEC 337DWARF: 338 debug_line: 339 - Length: 0x1234 340 Version: 2 341 PrologueLength: 0x1234 342 MinInstLength: 1 343 DefaultIsStmt: 1 344 LineBase: 1 345 LineRange: 14 346 OpcodeBase: 13 347 StandardOpcodeLengths: [] 348 Opcodes: 349 - Opcode: DW_LNS_extended_op 350 ExtLen: 9 351 SubOpcode: DW_LNE_set_address 352 Data: [[ADDR]] 353 354## i) Test that yaml2obj is able to emit correct opcodes. 355 356# RUN: yaml2obj --docnum=9 %s -o %t9.o 357# RUN: llvm-readelf --hex-dump=.debug_line %t9.o | FileCheck %s --check-prefix=OPCODES 358 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_directories 372## ^- null byte for terminating file_names 373## ^- DW_LNS_copy (1-byte) 374## ^- DW_LNS_advance_pc 375## ^--- operands[0] (ULEB128) 0x1234 376## ^- DW_LNS_advance_line 377## ^---- operands[0] (SLEB128) 0x1234 378## ^- DW_LNS_set_file 379## ^--- operands[0] (ULEB128) 0x1234 380## ^- DW_LNS_set_column 381## ^--- operands[0] (ULEB128) 0x1234 382## ^- DW_LNS_negate_stmt 383# OPCODES-NEXT: 0x00000020 07080934 120a0b0c b4240009 01000902 ...4.....$...... 384## ^- DW_LNS_set_basic_block 385## ^- DW_LNS_const_add_pc 386## ^- DW_LNS_fixed_advance_pc 387## ^---- operands[0] (uhalf, 2-byte) 388## ^- DW_LNS_set_prologue_end 389## ^- DW_LNS_set_epilogue_begin 390## ^- DW_LNS_set_isa 391## ^--- operands[0] (ULEB128) 0x1234 392## ^- DW_LNS_extended_op 393## ^- extended op length (ULEB128) 0x09 394## ^- DW_LNE_end_sequence 395## ^- DW_LNS_extended_op 396## ^- extended op length (ULEB128) 0x09 397## ^- DW_LNE_set_address 398# OPCODES-NEXT: 0x00000030 34120000 00000000 00090361 62636400 4..........abcd. 399## ^---------------- operands[0] (8-byte) 400## ^- DW_LNS_extended_op 401## ^- extended op length (ULEB128) 0x09 402## ^- DW_LNE_define_file 403## ^---------- operands[0] "abcd\0" 404# OPCODES-NEXT: 0x00000040 b424b424 b4240009 04b424 .$.$.$....$ 405## ^--- operands[1] (ULEB128) 0x1234 406## ^--- operands[2] (ULEB128) 0x1234 407## ^--- operands[3] (ULEB128) 0x1234 408## ^- DW_LNS_extended_op 409## ^- extended op length (ULEB128) 0x09 410## ^- DW_LNE_set_discriminator 411## ^--- operands[0] (ULEB128) 0x1234 412 413--- !ELF 414FileHeader: 415 Class: ELFCLASS64 416 Data: ELFDATA2LSB 417 Type: ET_EXEC 418DWARF: 419 debug_line: 420 - Length: 0x1234 421 Version: 4 422 PrologueLength: 0x1234 423 MinInstLength: 1 424 MaxOpsPerInst: 1 425 DefaultIsStmt: 1 426 LineBase: 1 427 LineRange: 14 428 OpcodeBase: 13 429 StandardOpcodeLengths: [] 430 Opcodes: 431 - Opcode: DW_LNS_copy 432 - Opcode: DW_LNS_advance_pc 433 Data: 0x1234 434 - Opcode: DW_LNS_advance_line 435 SData: 0x1234 436 - Opcode: DW_LNS_set_file 437 Data: 0x1234 438 - Opcode: DW_LNS_set_column 439 Data: 0x1234 440 - Opcode: DW_LNS_negate_stmt 441 - Opcode: DW_LNS_set_basic_block 442 - Opcode: DW_LNS_const_add_pc 443 - Opcode: DW_LNS_fixed_advance_pc 444 Data: 0x1234 445 - Opcode: DW_LNS_set_prologue_end 446 - Opcode: DW_LNS_set_epilogue_begin 447 - Opcode: DW_LNS_set_isa 448 Data: 0x1234 449 - Opcode: DW_LNS_extended_op 450 ExtLen: 0x09 451 SubOpcode: DW_LNE_end_sequence 452 - Opcode: DW_LNS_extended_op 453 ExtLen: 0x09 454 SubOpcode: DW_LNE_set_address 455 Data: 0x1234 456 - Opcode: DW_LNS_extended_op 457 ExtLen: 0x09 458 SubOpcode: DW_LNE_define_file 459 FileEntry: 460 Name: abcd 461 DirIdx: 0x1234 462 ModTime: 0x1234 463 Length: 0x1234 464 - Opcode: DW_LNS_extended_op 465 ExtLen: 0x09 466 SubOpcode: DW_LNE_set_discriminator 467 Data: 0x1234 468 469## j) Test that yaml2obj is able to infer the length and header_length fields. 470 471# RUN: yaml2obj --docnum=10 %s -o %t10.o 472# RUN: llvm-readelf --hex-dump=.debug_line %t10.o | FileCheck %s --check-prefix=INFER-LENGTH 473 474# INFER-LENGTH: Hex dump of section '.debug_line': 475# INFER-LENGTH-NEXT: 0x00000000 2e000000 04002500 00000101 01fb0e04 ......%......... 476## ^------- unit_length (4-byte) 0x2e 477## ^--- version (2-byte) 478## ^-------- header_length (4-byte) 0x25 479## ^- minimum_instruction_length (1-byte) 480## ^- maximum_operations_per_instruction (1-byte) 481## ^- default_is_stmt (1-byte) 482## ^- line_base (1-byte) -5 483## ^- 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 byte 490# 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) 0x01 493## ^- file_names[1] file length (ULEB128) 0x00 494## ^- file_names[1] modification time 0x00 495## ^-------- file_names[2] file name "b.c\0" 496## ^- file_names[2] directory index (ULEB128) 0x02 497## ^- file_names[2] file length (ULEB128) 0x00 498## ^- file_names[2] modification time 0x00 499## ^- file_names null byte 500## ^- DW_LNS_extended_op 501# INFER-LENGTH-NEXT: 0x00000030 0101ffff ffff2500 00000000 00000400 ......%......... 502## ^- extended op length (ULEB128) 0x01 503## ^- DW_LNE_end_sequence 504## ^-------------------------- 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) -5 512## ^- 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 byte 519## ^------- file_names[1] file name "a.c\0" 520## ^- file_names[1] directory index (ULEB128) 0x01 521## ^- file_names[1] file length (ULEB128) 0x00 522## ^- file_names[1] modification time 0x00 523## ^- file_names null byte 524# INFER-LENGTH-NEXT: 0x00000060 000101 ... 525## ^- DW_LNS_extended_op 526## ^- extended op length (ULEB128) 0x01 527## ^- DW_LNE_end_sequence 528 529--- !ELF 530FileHeader: 531 Class: ELFCLASS64 532 Data: ELFDATA2LSB 533 Type: ET_EXEC 534DWARF: 535 debug_line: 536 - Version: 4 537 MinInstLength: 1 538 MaxOpsPerInst: 1 539 DefaultIsStmt: 1 540 LineBase: 251 541 LineRange: 14 542 OpcodeBase: 4 543 StandardOpcodeLengths: [ 0, 1, 1 ] 544 IncludeDirs: 545 - temp1 546 - temp2 547 Files: 548 - Name: a.c 549 DirIdx: 1 550 ModTime: 0 551 Length: 0 552 - Name: b.c 553 DirIdx: 2 554 ModTime: 0 555 Length: 0 556 Opcodes: 557 - Opcode: DW_LNS_extended_op 558 ExtLen: 1 559 SubOpcode: DW_LNE_end_sequence 560 - Format: DWARF64 561 Version: 4 562 MinInstLength: 1 563 MaxOpsPerInst: 1 564 DefaultIsStmt: 1 565 LineBase: 251 566 LineRange: 14 567 OpcodeBase: 4 568 StandardOpcodeLengths: [ 0, 1, 1 ] 569 IncludeDirs: 570 - temp3 571 Files: 572 - Name: c.c 573 DirIdx: 1 574 ModTime: 0 575 Length: 0 576 Opcodes: 577 - Opcode: DW_LNS_extended_op 578 ExtLen: 1 579 SubOpcode: DW_LNE_end_sequence 580 581## k) Test that we can omit the include_directories, file_names and opcodes 582## fields of the line table. 583 584# RUN: yaml2obj --docnum=11 %s -o %t11.o 585# RUN: llvm-readelf --hex-dump=.debug_line %t11.o | \ 586# RUN: FileCheck %s --check-prefix=OMIT-FIELDS 587 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) -5 597## ^- 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--- !ELF 605FileHeader: 606 Class: ELFCLASS64 607 Data: ELFDATA2LSB 608 Type: ET_EXEC 609DWARF: 610 debug_line: 611 - Version: 4 612 MinInstLength: 1 613 MaxOpsPerInst: 1 614 DefaultIsStmt: 1 615 LineBase: 251 616 LineRange: 14 617 OpcodeBase: 4 618 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.o 623# RUN: llvm-readelf --hex-dump=.debug_line %t12.o | \ 624# RUN: FileCheck %s --check-prefix=EXTLEN --strict-whitespace 625 626# EXTLEN: Hex dump of section '.debug_line': 627# EXTLEN-NEXT: 0x00000000 20000000 04000800 00000101 01fb0e01 628## ^---------------------------------- line number program header 629# EXTLEN-NEXT: 0x00000010 0000000c 03616263 6400b424 b424b424 630## ---- 631## ^- DW_LNS_extended_op 632## ^- extended opcode length (ULEB128) 12 633## ^- DW_LNE_define_file 634## ^---------- "abcd\0" 635## ^--- directory index (ULEB128) 0x1234 636## ^--- modification time (ULEB128) 0x1234 637## ^--- file length (ULEB128) 0x1234 638# EXTLEN-NEXT: 0x00000020 00b42401{{ }} 639## ^- DW_LNS_extended_op 640## ^--- extended opcode length (ULEB128) 0x1234 641## ^- DW_LNE_end_sequence 642 643--- !ELF 644FileHeader: 645 Class: ELFCLASS64 646 Data: ELFDATA2LSB 647 Type: ET_EXEC 648DWARF: 649 debug_line: 650 - Version: 4 651 MinInstLength: 1 652 MaxOpsPerInst: 1 653 DefaultIsStmt: 1 654 LineBase: 251 655 LineRange: 14 656 OpcodeBase: 1 657 StandardOpcodeLengths: [] 658 Opcodes: 659 - Opcode: DW_LNS_extended_op 660 ## Omit the ExtLen field. 661 SubOpcode: DW_LNE_define_file 662 FileEntry: 663 Name: abcd 664 DirIdx: 0x1234 665 ModTime: 0x1234 666 Length: 0x1234 667 - Opcode: DW_LNS_extended_op 668 ## Specify the ExtLen field. 669 ExtLen: 0x1234 670 SubOpcode: DW_LNE_end_sequence 671 672## m) Test how yaml2obj generates the opcode_base and the 673## standard_opcode_lengths fields. 674 675## Both the opcode_base and the standard_opcode_lengths fields are not 676## specified (DWARFv2). 677 678# RUN: yaml2obj --docnum=13 -DVERSION=2 -DMAXOPSPERINST='' %s -o %t13.o 679# RUN: llvm-readelf --hex-dump=.debug_line %t13.o | \ 680# RUN: FileCheck %s --check-prefix=OPCODEBASEV2 681 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] = 0 686# OPCODEBASEV2-NEXT: 0x00000010 01010101 00000001 0000 .......... 687## ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1 688## ^- standard_opcode_lengths[DW_LNS_advance_line] = 1 689## ^- standard_opcode_lengths[DW_LNS_set_file] = 1 690## ^- standard_opcode_lengths[DW_LNS_set_column] = 1 691## ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0 692## ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0 693## ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0 694## ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 695## ^--- terminators for include_directories and file_names 696 697--- !ELF 698FileHeader: 699 Class: ELFCLASS64 700 Data: ELFDATA2LSB 701 Type: ET_EXEC 702DWARF: 703 debug_line: 704 - Version: [[VERSION=4]] 705 MinInstLength: 1 706 [[MAXOPSPERINST=MaxOpsPerInst: 0]] 707 DefaultIsStmt: 1 708 LineBase: 0 709 LineRange: 1 710 OpcodeBase: [[OPCODEBASE=<none>]] 711 StandardOpcodeLengths: [[STANDARDOPCODELENGTHS=<none>]] 712 713## Both the opcode_base and the standard_opcode_lengths fields are not 714## specified (DWARFv3). 715 716# RUN: yaml2obj --docnum=13 -DVERSION=3 -DMAXOPSPERINST='' %s -o %t14.o 717# RUN: llvm-readelf --hex-dump=.debug_line %t14.o | \ 718# RUN: FileCheck %s --check-prefix=OPCODEBASEV3 719 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] = 0 724# OPCODEBASEV3-NEXT: 0x00000010 01010101 00000001 00000100 00 ............. 725## ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1 726## ^- standard_opcode_lengths[DW_LNS_advance_line] = 1 727## ^- standard_opcode_lengths[DW_LNS_set_file] = 1 728## ^- standard_opcode_lengths[DW_LNS_set_column] = 1 729## ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0 730## ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0 731## ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0 732## ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 733## ^- standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 734## ^- standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 735## ^- standard_opcode_lengths[DW_LNS_set_isa] = 1 736## ^---- terminators for include_directories and file_names 737 738## Both the opcode_base and the standard_opcode_lengths fields are not 739## specified (DWARFv4). 740 741# RUN: yaml2obj --docnum=13 %s -o %t15.o 742# RUN: llvm-readelf --hex-dump=.debug_line %t15.o | \ 743# RUN: FileCheck %s --check-prefix=OPCODEBASEV4 744 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] = 0 750## ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1 751## ^- standard_opcode_lengths[DW_LNS_advance_line] = 1 752## ^- standard_opcode_lengths[DW_LNS_set_file] = 1 753## ^- standard_opcode_lengths[DW_LNS_set_column] = 1 754## ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0 755## ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0 756## ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0 757## ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 758## ^- standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 759## ^- standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 760## ^- standard_opcode_lengths[DW_LNS_set_isa] = 1 761## ^--- terminators for include_directories and file_names 762 763## Specify the opcode_base field (opcode_base == 0). 764 765# RUN: yaml2obj --docnum=13 -DOPCODEBASE=0 %s -o %t16.o 766# RUN: llvm-readelf --hex-dump=.debug_line %t16.o | \ 767# RUN: FileCheck %s --check-prefix=ZERO-OPCODEBASE 768 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_names 774 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.o 779# RUN: llvm-readelf --hex-dump=.debug_line %t17.o | \ 780# RUN: FileCheck %s --check-prefix=OPCODEBASE 781 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_names 788 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.o 793# RUN: llvm-readelf --hex-dump=.debug_line %t18.o | \ 794# RUN: FileCheck %s --check-prefix=OPCODEBASE1 795 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_names 805 806## Specify the standard_opcode_lengths field. 807 808# RUN: yaml2obj --docnum=13 -DSTANDARDOPCODELENGTHS=[0,1,0] %s -o %t19.o 809# RUN: llvm-readelf --hex-dump=.debug_line %t19.o | \ 810# RUN: FileCheck %s --check-prefix=OPCODELENGTHS 811 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_names 818 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.o 822# RUN: llvm-readelf --hex-dump=.debug_line %t20.o | \ 823# RUN: FileCheck %s --check-prefix=OPCODEBASE-LENGTHS 824 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_names 831