diff --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp --- a/llvm/lib/ObjectYAML/DWARFYAML.cpp +++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp @@ -156,7 +156,7 @@ void MappingTraits::mapping(IO &IO, DWARFYAML::Entry &Entry) { IO.mapRequired("AbbrCode", Entry.AbbrCode); - IO.mapRequired("Values", Entry.Values); + IO.mapOptional("Values", Entry.Values); } void MappingTraits::mapping( diff --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml --- a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml +++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml @@ -438,7 +438,6 @@ - Value: 0x0000000000000003 - Value: 0x0000000000000067 - AbbrCode: 0x00000000 - Values: - AbbrCode: 0x00000004 Values: - Value: 0x0000000000000085 @@ -456,7 +455,6 @@ - Value: 0x0000000000000006 - Value: 0x0000000000000001 - AbbrCode: 0x00000000 - Values: debug_line: - Length: 65 Version: 2 @@ -556,7 +554,6 @@ # DWARF32-NEXT: - Value: 0x0000000000000003 # DWARF32-NEXT: - Value: 0x0000000000000067 # DWARF32-NEXT: - AbbrCode: 0x00000000 -# DWARF32-NEXT: Values: # DWARF32-NEXT: - AbbrCode: 0x00000004 # DWARF32-NEXT: Values: # DWARF32-NEXT: - Value: 0x0000000000000085 @@ -574,7 +571,6 @@ # DWARF32-NEXT: - Value: 0x0000000000000006 # DWARF32-NEXT: - Value: 0x0000000000000001 # DWARF32-NEXT: - AbbrCode: 0x00000000 -# DWARF32-NEXT: Values: ## b) Test that yaml2obj emits a correct unit header and obj2yaml is able to convert it back. diff --git a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml --- a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml +++ b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml @@ -439,7 +439,6 @@ - Value: 0x0000000000000003 - Value: 0x0000000000000067 - AbbrCode: 0x00000000 - Values: - AbbrCode: 0x00000004 Values: - Value: 0x0000000000000085 @@ -457,7 +456,6 @@ - Value: 0x0000000000000006 - Value: 0x0000000000000001 - AbbrCode: 0x00000000 - Values: debug_line: - Length: 65 Version: 2 @@ -557,7 +555,6 @@ # DWARF32-NEXT: - Value: 0x0000000000000003 # DWARF32-NEXT: - Value: 0x0000000000000067 # DWARF32-NEXT: - AbbrCode: 0x00000000 -# DWARF32-NEXT: Values: # DWARF32-NEXT: - AbbrCode: 0x00000004 # DWARF32-NEXT: Values: # DWARF32-NEXT: - Value: 0x0000000000000085 @@ -575,7 +572,6 @@ # DWARF32-NEXT: - Value: 0x0000000000000006 # DWARF32-NEXT: - Value: 0x0000000000000001 # DWARF32-NEXT: - AbbrCode: 0x00000000 -# DWARF32-NEXT: Values: ## b) Test that yaml2obj emits a correct unit header and obj2yaml is able to convert it back. diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml --- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml +++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml @@ -842,3 +842,35 @@ - Value: 0x1120 ## DW_AT_low_pc [DW_FORM_addr] - Value: 0x06 ## DW_AT_high_pc [DW_FORM_data4] - Value: 0x38 ## DW_AT_name [DW_FORM_strp] + +## l) Test that if we don't specify the 'Values' entry, yaml2obj will only emit the abbrev_code. + +# RUN: yaml2obj --docnum=14 %s -o %t14.o +# RUN: llvm-readelf --hex-dump=.debug_info %t14.o | \ +# RUN: FileCheck %s --check-prefix=NO-VALUES + +# NO-VALUES: Hex dump of section '.debug_info': +# NO-VALUES-NEXT: 0x00000000 0a000000 04000000 00000801 0002 .............. +## ^------- unit_length (4-byte) +## ^--- version (2-byte) +## ^-------- debug_abbrev_offset (4-byte) +## ^- address_size (1-byte) +## ^- abbrev_code (ULEB128) 0x01 +## ^- abbrev_code (ULEB128) 0x00 +## ^- abbrev_code (ULEB128) 0x02 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +DWARF: + debug_info: + - Version: 4 + AbbrOffset: 0x00 + AddrSize: 0x08 + Entries: + - AbbrCode: 1 + - AbbrCode: 0 + - AbbrCode: 2