Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Standalone View
llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
Show First 20 Lines • Show All 413 Lines • ▼ Show 20 Lines | |||||
Sections: | Sections: | ||||
- Name: .debug_info | - Name: .debug_info | ||||
Type: SHT_PROGBITS | Type: SHT_PROGBITS | ||||
Size: 0x10 | Size: 0x10 | ||||
## d) Test that yaml2obj emits an error message when both the "Size" and the | ## d) Test that yaml2obj emits an error message when both the "Size" and the | ||||
## "debug_info" entry are specified at the same time. | ## "debug_info" entry are specified at the same time. | ||||
# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR | # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT | ||||
# ERROR: yaml2obj: error: cannot specify section '.debug_info' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time | # AMBIGUOUS-CONTENT: yaml2obj: error: cannot specify section '.debug_info' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time | ||||
--- !ELF | --- !ELF | ||||
FileHeader: | FileHeader: | ||||
Class: ELFCLASS64 | Class: ELFCLASS64 | ||||
Data: ELFDATA2LSB | Data: ELFDATA2LSB | ||||
Type: ET_EXEC | Type: ET_EXEC | ||||
Machine: EM_X86_64 | Machine: EM_X86_64 | ||||
Sections: | Sections: | ||||
Show All 13 Lines | - Length: | ||||
UnitType: DW_UT_type | UnitType: DW_UT_type | ||||
AbbrOffset: 0x1234 | AbbrOffset: 0x1234 | ||||
AddrSize: 4 | AddrSize: 4 | ||||
Entries: [] | Entries: [] | ||||
## e) Test that yaml2obj emits an error message when both the "Content" and the | ## e) Test that yaml2obj emits an error message when both the "Content" and the | ||||
## "debug_info" entry are specified at the same time. | ## "debug_info" entry are specified at the same time. | ||||
# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR | # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT | ||||
--- !ELF | --- !ELF | ||||
FileHeader: | FileHeader: | ||||
Class: ELFCLASS64 | Class: ELFCLASS64 | ||||
Data: ELFDATA2LSB | Data: ELFDATA2LSB | ||||
Type: ET_EXEC | Type: ET_EXEC | ||||
Machine: EM_X86_64 | Machine: EM_X86_64 | ||||
Sections: | Sections: | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | DWARF: | ||||
debug_info: | debug_info: | ||||
- Length: | - Length: | ||||
TotalLength: 0x1234 | TotalLength: 0x1234 | ||||
Version: 5 | Version: 5 | ||||
UnitType: DW_UT_type | UnitType: DW_UT_type | ||||
AbbrOffset: 0x1234 | AbbrOffset: 0x1234 | ||||
AddrSize: 4 | AddrSize: 4 | ||||
Entries: [] | Entries: [] | ||||
## h) Test that yaml2obj emits values in the DIE according to the abbreviation whose | |||||
## index is equal to the value in 'AbbrevCode'. | |||||
# RUN: yaml2obj --docnum=9 %s -o %t9.o | |||||
# RUN: llvm-readelf --hex-dump=.debug_info %t9.o | \ | |||||
# RUN: FileCheck %s --check-prefix=FORM --match-full-lines | |||||
# FORM: Hex dump of section '.debug_info': | |||||
# FORM-NEXT: 0x00000000 34120000 05000204 34120000 02341221 4.......4....4.! | |||||
## ^------- unit_length (4-byte) | |||||
## ^- abbreviation code (ULEB128) | |||||
## ^--- Form: DW_FORM_data2 (2-byte) | |||||
## ^- Form: DW_FORM_data4 (4-byte) | |||||
# FORM-NEXT: 0x00000010 43658701 21436587 341200 Ce..!Ce.4.. | |||||
## ------ | |||||
## ^- abbreviation code (ULEB128) | |||||
## ^------- Form: DW_FORM_data4 (4-byte) | |||||
## ^--- Form: DW_FORM_data2 (2-byte) | |||||
## ^- abbreviation code (ULEB128) | |||||
# FORM-EMPTY: | |||||
--- !ELF | |||||
FileHeader: | |||||
Class: ELFCLASS64 | |||||
Data: ELFDATA2LSB | |||||
Type: ET_EXEC | |||||
Machine: EM_X86_64 | |||||
DWARF: | |||||
debug_abbrev: | |||||
- Tag: DW_TAG_compile_unit | |||||
Children: DW_CHILDREN_yes | |||||
Attributes: | |||||
- Attribute: DW_AT_low_pc | |||||
Form: DW_FORM_data4 | |||||
- Attribute: DW_AT_high_pc | |||||
Form: DW_FORM_data2 | |||||
- Tag: DW_TAG_subprogram | |||||
Children: DW_CHILDREN_no | |||||
Attributes: | |||||
- Attribute: DW_AT_low_pc | |||||
Form: DW_FORM_data2 | |||||
- Attribute: DW_AT_high_pc | |||||
Form: DW_FORM_data4 | |||||
debug_info: | |||||
- Length: | |||||
TotalLength: 0x1234 | |||||
Version: 5 | |||||
UnitType: DW_UT_type | |||||
AbbrOffset: 0x1234 | |||||
AddrSize: 4 | |||||
Entries: | |||||
## Test that yaml2obj emits values when the abbrev code is specified. | |||||
- AbbrCode: 2 | |||||
Values: | |||||
jhenderson: Probably "ignores the contents of entries with abbrev code 0". (I wouldn't use the full term… | |||||
- Value: 0x1234 | |||||
- Value: 0x87654321 | |||||
## Test that yaml2obj emits values when the abbrev code is specified to | |||||
## be lower than the first abbrev. | |||||
using the ... -> when the abbrev code is specified. I think the value 2 is unimportant here. jhenderson: using the ... -> when the abbrev code is specified.
I think the value 2 is unimportant here. | |||||
- AbbrCode: 1 | |||||
Values: | |||||
- Value: 0x87654321 | |||||
- Value: 0x1234 | |||||
## Test that yaml2obj ignores the contents of entries with abbrev code 0. | |||||
- AbbrCode: 0 | |||||
using the ... -> when the abbrev code is specified to be lower than the first abbrev. jhenderson: using the ... -> when the abbrev code is specified to be lower than the first abbrev. | |||||
Values: | |||||
- Value: 0x1234 | |||||
## i) Test that yaml2obj reports a fatal error when 'debug_info' has values in its | |||||
## entries but 'debug_abbrev' doesn't have enough attributes for them. | |||||
# RUN: not --crash yaml2obj --docnum=10 %s -o %t10.o 2>&1 | \ | |||||
# RUN: FileCheck %s --check-prefixes=FATAL | |||||
# FATAL: LLVM ERROR: abbrev code must be less than or equal to the number of entries in abbreviation table | |||||
--- !ELF | |||||
FileHeader: | |||||
Class: ELFCLASS64 | |||||
Data: ELFDATA2LSB | |||||
Type: ET_EXEC | |||||
Machine: EM_X86_64 | |||||
DWARF: | |||||
There's a bit of tension here between the AbbrOffset and the behaviour. Since the AbbrOffset should point to the start of the table containing the corresponding abbrevs, it's a little unclear what the behaviour should be if the offset is nonsensical. It also prevents us having multiple abbrev tables as it stands. I think it's okay to add this test case for now, but I might suggest a change for the future, to split the abbrev section into distinct tables which can be referenced by some ID from the .debug_info. Different .debug_info tables can refer to the same or different abbrev tables that way. The offset would be auto-calculated to match, but could be overridden to a different value (the ID could still be used to actually identify how to write the values). jhenderson: There's a bit of tension here between the AbbrOffset and the behaviour. Since the AbbrOffset… | |||||
Yeah, the current implementation of the .debug_abbrev section doesn't support multiple tables. I deleted this test. I will it once generating multiple abbreviation tables is supported. Higuoxing: > I think it's okay to add this test case for now, but I might suggest a change for the future… | |||||
debug_info: | |||||
- Length: | |||||
TotalLength: 0x1234 | |||||
Version: 5 | |||||
UnitType: DW_UT_type | |||||
AbbrOffset: 0x1234 | |||||
AddrSize: 4 | |||||
Entries: | |||||
- AbbrCode: 1 | |||||
Values: | |||||
- Value: 0x1234 |
Probably "ignores the contents of entries with abbrev code 0". (I wouldn't use the full term "abbreviation" as I think it's not particularly common usage in this context).
I'd also move this case later in the sequence (possibly the last one), since we should allow a non-zero value to be the "First" abbrev.