diff options
author | Xing GUO <higuoxing@gmail.com> | 2020-08-21 19:01:35 +0800 |
---|---|---|
committer | Xing GUO <higuoxing@gmail.com> | 2020-08-21 19:02:10 +0800 |
commit | f5643dc3dce201a5c9b43cb68370bdbb4254495a (patch) | |
tree | 880b377011ac5d83b710b001c27d43a82dc20539 /llvm/test/ObjectYAML | |
parent | 1dd85e9d0e0d655f42f6c3072bae9b8195906e36 (diff) | |
download | llvm-f5643dc3dce201a5c9b43cb68370bdbb4254495a.zip llvm-f5643dc3dce201a5c9b43cb68370bdbb4254495a.tar.gz llvm-f5643dc3dce201a5c9b43cb68370bdbb4254495a.tar.bz2 |
Recommit: [DWARFYAML] Add support for referencing different abbrev tables.
The original commit (7ff0ace96db9164dcde232c36cab6519ea4fce8) was causing
build failure and was reverted in 6d242a73264ef1e3e128547f00e0fe2d20d3ada0
==================== Original Commit Message ====================
This patch adds support for referencing different abbrev tables. We use
'ID' to distinguish abbrev tables and use 'AbbrevTableID' to explicitly
assign an abbrev table to compilation units.
The syntax is:
```
debug_abbrev:
- ID: 0
Table:
...
- ID: 1
Table:
...
debug_info:
- ...
AbbrevTableID: 1 ## Reference the second abbrev table.
- ...
AbbrevTableID: 0 ## Reference the first abbrev table.
```
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D83116
Diffstat (limited to 'llvm/test/ObjectYAML')
-rw-r--r-- | llvm/test/ObjectYAML/MachO/DWARF-debug_abbrev.yaml | 71 | ||||
-rw-r--r-- | llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml | 227 | ||||
-rw-r--r-- | llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml | 3 |
3 files changed, 300 insertions, 1 deletions
diff --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_abbrev.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_abbrev.yaml index 607d6eb..91af7bdf 100644 --- a/llvm/test/ObjectYAML/MachO/DWARF-debug_abbrev.yaml +++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_abbrev.yaml @@ -1,4 +1,7 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s +## a) Test that yaml2obj is able to emit the __debug_abbrev section and obj2yaml is +## able to convert it back. + +# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s --- !mach-o FileHeader: @@ -420,3 +423,69 @@ DWARF: #CHECK: Attributes: #CHECK: - Attribute: DW_AT_type #CHECK: Form: DW_FORM_ref4 + +## b) Test that yaml2obj emits an error message when there are non-empty compilation +## units and multiple abbrev tables are assigned the same ID. + +# RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=ID-COLLISION + +# ID-COLLISION: yaml2obj: error: the ID (1) of abbrev table with index 1 has been used by abbrev table with index 0 + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x0000000A + ncmds: 1 + sizeofcmds: 232 + flags: 0x00000000 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 232 + segname: __DWARF + vmaddr: 0x00 + vmsize: 0x00 + fileoff: 0x00 + filesize: 0x00 + maxprot: 0 + initprot: 0 + nsects: 2 + flags: 0 + Sections: + - sectname: __debug_abbrev + segname: __DWARF + addr: 0x00 + size: 24 + offset: 528 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_info + segname: __DWARF + addr: 0x00 + size: 64 + offset: 1070 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 +DWARF: + debug_abbrev: + - ID: 1 + - ID: 1 + debug_info: + - Version: 4 + AbbrOffset: 0x00 + Entries: + - AbbrCode: 1 + Values: + - Value: 0x1234 diff --git a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml index 46bf522..7b9d5fa 100644 --- a/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml +++ b/llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml @@ -514,6 +514,7 @@ DWARF: # DWARF32: debug_info: # DWARF32-NEXT: - Length: 0x0000000000000075 # DWARF32-NEXT: Version: 4 +# DWARF32-NEXT: AbbrevTableID: 0 # DWARF32-NEXT: AbbrOffset: 0 # DWARF32-NEXT: AddrSize: 8 # DWARF32-NEXT: Entries: @@ -583,6 +584,7 @@ DWARF: # DWARF32-YAML: debug_info: # DWARF32-YAML-NEXT: - Length: 0x000000000000000C # DWARF32-YAML-NEXT: Version: 4 +# DWARF32-YAML-NEXT: AbbrevTableID: 0 # DWARF32-YAML-NEXT: AbbrOffset: 0 # DWARF32-YAML-NEXT: AddrSize: 8 # DWARF32-YAML-NEXT: Entries: @@ -666,9 +668,234 @@ DWARF: # DWARF64-YAML-NEXT: - Format: DWARF64 # DWARF64-YAML-NEXT: Length: 0x000000000000000C # DWARF64-YAML-NEXT: Version: 4 +# DWARF64-YAML-NEXT: AbbrevTableID: 0 # DWARF64-YAML-NEXT: AbbrOffset: 0 # DWARF64-YAML-NEXT: AddrSize: 8 # DWARF64-YAML-NEXT: Entries: # DWARF64-YAML-NEXT: - AbbrCode: 0x00000001 # DWARF64-YAML-NEXT: Values: # DWARF64-YAML-NEXT: - Value: 0x0000000000001234 + +## c) Test that yaml2obj is able to generate compilation units according to the +## associated abbrev table that is referenced by the 'AbbrevTableID' and obj2yaml +## is able to convert it back. + +# RUN: yaml2obj --docnum=3 %s | obj2yaml | FileCheck %s --check-prefix=MULTI-TABLES + +# MULTI-TABLES: DWARF: +# MULTI-TABLES-NEXT: debug_abbrev: +# MULTI-TABLES-NEXT: - ID: 0 +# MULTI-TABLES-NEXT: Table: +# MULTI-TABLES-NEXT: - Code: 0x0000000000000001 +# MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit +# MULTI-TABLES-NEXT: Children: DW_CHILDREN_no +# MULTI-TABLES-NEXT: Attributes: +# MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc +# MULTI-TABLES-NEXT: Form: DW_FORM_addr +# MULTI-TABLES-NEXT: - ID: 1 +# MULTI-TABLES-NEXT: Table: +# MULTI-TABLES-NEXT: - Code: 0x0000000000000001 +# MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit +# MULTI-TABLES-NEXT: Children: DW_CHILDREN_no +# MULTI-TABLES-NEXT: Attributes: +# MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc +# MULTI-TABLES-NEXT: Form: DW_FORM_data4 +# MULTI-TABLES-NEXT: - ID: 2 +# MULTI-TABLES-NEXT: Table: +# MULTI-TABLES-NEXT: - Code: 0x0000000000000001 +# MULTI-TABLES-NEXT: Tag: DW_TAG_compile_unit +# MULTI-TABLES-NEXT: Children: DW_CHILDREN_no +# MULTI-TABLES-NEXT: Attributes: +# MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc +# MULTI-TABLES-NEXT: Form: DW_FORM_udata +# MULTI-TABLES-NEXT: debug_info: +# MULTI-TABLES-NEXT: - Length: 0x000000000000000C +# MULTI-TABLES-NEXT: Version: 4 +# MULTI-TABLES-NEXT: AbbrevTableID: 1 +# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000008 +# MULTI-TABLES-NEXT: AddrSize: 8 +# MULTI-TABLES-NEXT: Entries: +# MULTI-TABLES-NEXT: - AbbrCode: 0x00000001 +# MULTI-TABLES-NEXT: Values: +# MULTI-TABLES-NEXT: - Value: 0x0000000000001234 +# MULTI-TABLES-NEXT: - Length: 0x000000000000000C +# MULTI-TABLES-NEXT: Version: 4 +# MULTI-TABLES-NEXT: AbbrevTableID: 1 +# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000008 +# MULTI-TABLES-NEXT: AddrSize: 8 +# MULTI-TABLES-NEXT: Entries: +# MULTI-TABLES-NEXT: - AbbrCode: 0x00000001 +# MULTI-TABLES-NEXT: Values: +# MULTI-TABLES-NEXT: - Value: 0x0000000000004321 +# MULTI-TABLES-NEXT: - Length: 0x0000000000000010 +# MULTI-TABLES-NEXT: Version: 4 +# MULTI-TABLES-NEXT: AbbrevTableID: 0 +# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000000 +# MULTI-TABLES-NEXT: AddrSize: 8 +# MULTI-TABLES-NEXT: Entries: +# MULTI-TABLES-NEXT: - AbbrCode: 0x00000001 +# MULTI-TABLES-NEXT: Values: +# MULTI-TABLES-NEXT: - Value: 0x0000000000005678 +# MULTI-TABLES-NEXT: - Length: 0x000000000000000B +# MULTI-TABLES-NEXT: Version: 4 +# MULTI-TABLES-NEXT: AbbrevTableID: 2 +# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000010 +# MULTI-TABLES-NEXT: AddrSize: 8 +# MULTI-TABLES-NEXT: Entries: +# MULTI-TABLES-NEXT: - AbbrCode: 0x00000001 +# MULTI-TABLES-NEXT: Values: +# MULTI-TABLES-NEXT: - Value: 0x0000000000008765 +# MULTI-TABLES-NEXT: ... + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x0000000A + ncmds: 1 + sizeofcmds: 232 + flags: 0x00000000 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 232 + segname: __DWARF + vmaddr: 0x00 + vmsize: 0x00 + fileoff: 0x00 + filesize: 0x00 + maxprot: 0 + initprot: 0 + nsects: 2 + flags: 0 + Sections: + - sectname: __debug_abbrev + segname: __DWARF + addr: 0x00 + size: 24 + offset: 528 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_info + segname: __DWARF + addr: 0x00 + size: 67 + offset: 1070 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 +DWARF: + debug_abbrev: + - Table: + - Code: 1 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - ID: 2 + Table: + - Code: 1 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_data4 + - ID: 1 + Table: + - Code: 1 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_udata + debug_info: + - Version: 4 + AbbrevTableID: 2 + AbbrOffset: 8 + Entries: + - AbbrCode: 1 + Values: + - Value: 0x1234 + - Version: 4 + AbbrevTableID: 2 + AbbrOffset: 8 + Entries: + - AbbrCode: 1 + Values: + - Value: 0x4321 + - Version: 4 + AbbrevTableID: 0 + AbbrOffset: 0 + Entries: + - AbbrCode: 1 + Values: + - Value: 0x5678 + - Version: 4 + AbbrevTableID: 1 + AbbrOffset: 16 + Entries: + - AbbrCode: 1 + Values: + - Value: 0x8765 + +## d) Test that yaml2obj emits an error message when a compilation unit doesn't have +## an associated abbrev table. + +# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=MISSING-ABBREV + +# MISSING-ABBREV: yaml2obj: error: cannot find abbrev table whose ID is 0 for compilation unit with index 0 + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x0000000A + ncmds: 1 + sizeofcmds: 232 + flags: 0x00000000 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 152 + segname: __DWARF + vmaddr: 0x00 + vmsize: 0x00 + fileoff: 0x00 + filesize: 0x00 + maxprot: 0 + initprot: 0 + nsects: 2 + flags: 0 + Sections: + - sectname: __debug_info + segname: __DWARF + addr: 0x00 + size: 64 + offset: 1070 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 +DWARF: + debug_info: + - Version: 4 + AbbrOffset: 0x00 + Entries: + - AbbrCode: 1 + Values: + - Value: 0x1234 diff --git a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml index d63be60..d016b8c 100644 --- a/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml +++ b/llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml @@ -515,6 +515,7 @@ DWARF: # DWARF32-NEXT: - Length: 0x0000000000000076 # DWARF32-NEXT: Version: 5 # DWARF32-NEXT: UnitType: DW_UT_compile +# DWARF32-NEXT: AbbrevTableID: 0 # DWARF32-NEXT: AbbrOffset: 0 # DWARF32-NEXT: AddrSize: 8 # DWARF32-NEXT: Entries: @@ -585,6 +586,7 @@ DWARF: # DWARF32-YAML-NEXT: - Length: 0x000000000000000C # DWARF32-YAML-NEXT: Version: 5 # DWARF32-YAML-NEXT: UnitType: DW_UT_compile +# DWARF32-YAML-NEXT: AbbrevTableID: 0 # DWARF32-YAML-NEXT: AbbrOffset: 0x0000000000000000 # DWARF32-YAML-NEXT: AddrSize: 8 # DWARF32-YAML-NEXT: Entries: @@ -670,6 +672,7 @@ DWARF: # DWARF64-YAML-NEXT: Length: 0x0000000000000014 # DWARF64-YAML-NEXT: Version: 5 # DWARF64-YAML-NEXT: UnitType: DW_UT_compile +# DWARF64-YAML-NEXT: AbbrevTableID: 0 # DWARF64-YAML-NEXT: AbbrOffset: 0x0000000000000000 # DWARF64-YAML-NEXT: AddrSize: 8 # DWARF64-YAML-NEXT: Entries: |