[DWARFYAML] Make the 'Attributes' field optional.

This patch makes the 'Attributes' field optional. We don't need to
explicitly specify the 'Attributes' field in the future.

Reviewed By: jhenderson, grimar

Differential Revision: https://reviews.llvm.org/D86537
This commit is contained in:
Xing GUO 2020-08-25 22:37:40 +08:00
parent 39522b1e10
commit 1dc57ada0c
4 changed files with 14 additions and 21 deletions

View file

@ -116,7 +116,7 @@ void MappingTraits<DWARFYAML::Abbrev>::mapping(IO &IO,
IO.mapOptional("Code", Abbrev.Code);
IO.mapRequired("Tag", Abbrev.Tag);
IO.mapRequired("Children", Abbrev.Children);
IO.mapRequired("Attributes", Abbrev.Attributes);
IO.mapOptional("Attributes", Abbrev.Attributes);
}
void MappingTraits<DWARFYAML::AttributeAbbrev>::mapping(

View file

@ -4,7 +4,7 @@
# RUN: yaml2obj --docnum=1 %s -o %t1.o
# RUN: llvm-readobj --sections --section-data %t1.o | \
# RUN: FileCheck -DSIZE=54 -DADDRALIGN=1 %s --check-prefixes=SHDR,CONTENT
# RUN: FileCheck -DSIZE=59 -DADDRALIGN=1 %s --check-prefixes=SHDR,CONTENT
# SHDR: Index: 1
# SHDR-NEXT: Name: .debug_abbrev (1)
@ -51,12 +51,14 @@
## ^- DW_CHILDREN_yes 1-byte ^- abbreviation code ULEB128
## ^- DW_AT_producer ULEB128 ^- DW_TAG_subprogram ULEB128
## ^- DW_FORM_strp ULEB128
# CONTENT-NEXT: 0030: 01110100 0000 |......|
## ^- DW_CHILDREN_yes 1-byte
## ^- DW_AT_low_pc ULEB128
## ^- DW_FORM_addr UELB128
## ^---- attr terminator
## ^- abbrev table terminator
# CONTENT-NEXT: 0030: 01110100 00031100 000000 |...........|
## ^- DW_CHILDREN_yes 1-byte ^--- attr terminator
## ^- DW_AT_low_pc ULEB128 ^- abbrev table terminator
## ^- DW_FORM_addr UELB128
## ^---- attr terminator
## ^- abbrev code ULEB128 (0x03)
## ^- DW_TAG_compile_unit
## ^- DW_CHILDREN_no
# CONTENT-NEXT: )
--- !ELF
@ -116,6 +118,10 @@ DWARF:
Attributes:
- Attribute: DW_AT_low_pc
Form: DW_FORM_addr
## Test that if the 'Attributes' field is not specified, yaml2obj emits
## a terminating entry, 0 for the attribute, 0 for the form.
- Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
## b) Generate the .debug_abbrev section from raw section content.
@ -179,7 +185,6 @@ DWARF:
- Code: 1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes: []
## e) Test that yaml2obj emits an error message when both the "Content" and the
## "debug_abbrev" entry are specified at the same time.
@ -201,7 +206,6 @@ DWARF:
- Code: 1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes: []
## f) Test that all the properties can be overridden by the section header when
## the "debug_abbrev" entry doesn't exist.
@ -261,7 +265,6 @@ DWARF:
- Code: 1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes: []
## h) Test that yaml2obj automatically generates abbreviation codes for us.
@ -288,24 +291,18 @@ DWARF:
- Table:
- Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes: []
- Tag: DW_TAG_subprogram
Children: DW_CHILDREN_no
Attributes: []
- Code: 4
Tag: DW_TAG_subprogram
Children: DW_CHILDREN_no
Attributes: []
- Code: 4
Tag: DW_TAG_subprogram
Children: DW_CHILDREN_no
Attributes: []
- Tag: DW_TAG_subprogram
Children: DW_CHILDREN_no
Attributes: []
- Tag: DW_TAG_subprogram
Children: DW_CHILDREN_no
Attributes: []
## i) Test that yaml2obj emits an error message when there are non-empty compilation units
## and multiple abbrev tables are assigned the same ID.

View file

@ -446,7 +446,6 @@ DWARF:
- Code: 1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes: []
debug_info:
- Length: 0x1234
Version: 5
@ -474,7 +473,6 @@ DWARF:
- Code: 1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes: []
debug_info:
- Length: 0x1234
Version: 5
@ -540,7 +538,6 @@ DWARF:
- Code: 1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes: []
debug_info:
- Length: 0x1234
Version: 5

View file

@ -1367,7 +1367,6 @@ TEST(DWARFDebugInfo, TestEmptyChildren) {
" - Code: 0x00000001\n"
" Tag: DW_TAG_compile_unit\n"
" Children: DW_CHILDREN_yes\n"
" Attributes:\n"
"debug_info:\n"
" - Version: 4\n"
" AbbrOffset: 0\n"