[llvm] 40506d5 - [DWARFYAML][debug_info] Make the 'Values' field optional.

Xing GUO via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 05:44:33 PDT 2020


Author: Xing GUO
Date: 2020-08-06T20:43:52+08:00
New Revision: 40506d5e2fc5fb47badcb79a8ad9242c3bce60f3

URL: https://github.com/llvm/llvm-project/commit/40506d5e2fc5fb47badcb79a8ad9242c3bce60f3
DIFF: https://github.com/llvm/llvm-project/commit/40506d5e2fc5fb47badcb79a8ad9242c3bce60f3.diff

LOG: [DWARFYAML][debug_info] Make the 'Values' field optional.

This patch makes the 'Values' field optional. This is useful when we
handcraft the terminating entry of DIEs.

```
debug_info:
  - Version:  4
    ...
    Entries:
      - AbbrCode: 1
        Values:
          - Value: 0x1234
      - AbbrCode: 0 ## Termination
```

Reviewed By: jhenderson, grimar

Differential Revision: https://reviews.llvm.org/D85397

Added: 
    

Modified: 
    llvm/lib/ObjectYAML/DWARFYAML.cpp
    llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
    llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
    llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp
index a31df9499523..467127a9923d 100644
--- a/llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -156,7 +156,7 @@ void MappingTraits<DWARFYAML::Unit>::mapping(IO &IO, DWARFYAML::Unit &Unit) {
 
 void MappingTraits<DWARFYAML::Entry>::mapping(IO &IO, DWARFYAML::Entry &Entry) {
   IO.mapRequired("AbbrCode", Entry.AbbrCode);
-  IO.mapRequired("Values", Entry.Values);
+  IO.mapOptional("Values", Entry.Values);
 }
 
 void MappingTraits<DWARFYAML::FormValue>::mapping(

diff  --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
index 937c84b863a6..f260c24e3ded 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
@@ -438,7 +438,6 @@ DWARF:
             - Value:           0x0000000000000003
             - Value:           0x0000000000000067
         - AbbrCode:        0x00000000
-          Values:          
         - AbbrCode:        0x00000004
           Values:          
             - Value:           0x0000000000000085
@@ -456,7 +455,6 @@ DWARF:
             - Value:           0x0000000000000006
             - Value:           0x0000000000000001
         - AbbrCode:        0x00000000
-          Values:          
   debug_line:      
     - Length:          65
       Version:         2
@@ -556,7 +554,6 @@ DWARF:
 # 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 @@ DWARF:
 # 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
index c41348477a96..f8327826d589 100644
--- a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
+++ b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
@@ -439,7 +439,6 @@ DWARF:
             - Value:           0x0000000000000003
             - Value:           0x0000000000000067
         - AbbrCode:        0x00000000
-          Values:          
         - AbbrCode:        0x00000004
           Values:          
             - Value:           0x0000000000000085
@@ -457,7 +456,6 @@ DWARF:
             - Value:           0x0000000000000006
             - Value:           0x0000000000000001
         - AbbrCode:        0x00000000
-          Values:          
   debug_line:      
     - Length:          65
       Version:         2
@@ -557,7 +555,6 @@ DWARF:
 # 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 @@ DWARF:
 # 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
index 5cd2bca1b429..25b5a88b8410 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
@@ -842,3 +842,35 @@ DWARF:
             - 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' key for an 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


        


More information about the llvm-commits mailing list