aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ObjectYAML/DWARFYAML.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-08-12[dwarf2yaml] Correctly emit type and split unit headers (#102471)Pavel Labath1-2/+18
(DWARFv5) split units have an extra `dwo_id` field in the header. Type units have `type_signature` and `type_offset`.
2024-02-12[DWARFYAML] Implement debug_names support (#79666)Felipe de Azevedo Piovezan1-0/+29
This commit brings support for debug_names in DWARFYAML. It parses YAML and generates emits a DWARF5 Accelerator table with the following limitations: 1. All forms must have a fixed length (zero length is also ok). 2. Hard-coded support for DWARF 5 and DWARF32. 3. The generated table does not contain a hash index All of these limitations can be lifted in the future, but for now this is good enough to enable testing.
2023-03-13[ADT][NFCI] Do not use non-const lvalue-refs with enumerate in llvm/Jakub Kuderski1-7/+5
Replace references to `enumerate` results with either const lvalue rerences or structured bindings. I did not use structured bindings everywhere as it wasn't clear to me it would improve readability. This is in preparation to the switch to `zip` semantics which won't support non-const lvalue reference to elements: https://reviews.llvm.org/D144503. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D145987
2022-06-18[llvm] Use value_or instead of getValueOr (NFC)Kazu Hirata1-1/+1
2020-10-20Reland "[yaml2obj][ELF] - Simplify the code that performs sections validation."Georgii Rymar1-2/+2
This reverts commit 1b589f4d4db27e3fcd81fdc5abeb9407753ab790 and relands the D89463 with the fix: update `MappingTraits<FileFilter>::validate()` in ClangTidyOptions.cpp to match the new signature (change the return type to "std::string" from "StringRef"). Original commit message: This: Changes the return type of MappingTraits<T>>::validate to std::string instead of StringRef. It allows to create more complex error messages. It introduces std::vector<std::pair<StringRef, bool>> getEntries(): a new virtual method of Section, which is the base class for all sections. It returns names of special section specific keys (e.g. "Entries") and flags that says if them exist in a YAML. The code in validate() uses this list of entries descriptions to generalize validation. This approach was discussed in the D89039 thread. Differential revision: https://reviews.llvm.org/D89463
2020-10-20Revert "[yaml2obj][ELF] - Simplify the code that performs sections validation."Georgii Rymar1-2/+2
This reverts commit b9e2b59680ad1bbfd2b9110b3ebf3d2b22cad51b.
2020-10-20[yaml2obj][ELF] - Simplify the code that performs sections validation.Georgii Rymar1-2/+2
This: 1) Changes the return type of `MappingTraits<T>>::validate` to `std::string` instead of `StringRef`. It allows to create more complex error messages. 2) It introduces std::vector<std::pair<StringRef, bool>> getEntries(): a new virtual method of Section, which is the base class for all sections. It returns names of special section specific keys (e.g. "Entries") and flags that says if them exist in a YAML. The code in validate() uses this list of entries descriptions to generalize validation. This approach was discussed in the D89039 thread. Differential revision: https://reviews.llvm.org/D89463
2020-10-09[DWARFYAML] Make the opcode_base and the standard_opcode_lengths fields ↵Xing GUO1-2/+2
optional. This patch makes the opcode_base and the standard_opcode_lengths fields of the line table optional. When both of them are not specified, yaml2obj emits them according to the line table's version. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D88355
2020-09-24[DWARFYAML] Make the ExtLen field of extended opcodes optional.Xing GUO1-1/+1
This patch makes the 'ExtLen' field of extended opcodes optional. We don't need to manually calculate it in the future. Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D88136
2020-09-18[DWARFYAML] Make the include_directories, file_names and opcodes fields of ↵Xing GUO1-3/+3
the line table optional. This patch makes the include_directories, file_names and opcodes fields of the line table optional. This helps us simplify some tests. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D87878
2020-09-08[DWARFYAML] Make the debug_ranges section optional.Xing GUO1-3/+2
This patch makes the debug_ranges section optional. When we specify an empty debug_ranges section, yaml2obj only emits the section header. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D87263
2020-09-07[DWARFYAML] Make the debug_addr section optional.Xing GUO1-1/+1
This patch makes the debug_addr section optional. When an empty debug_addr section is specified, yaml2obj only emits a section header for it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D87205
2020-09-01[DWARFYAML] Make the debug_str section optional.Xing GUO1-1/+1
This patch makes the debug_str section optional. When the debug_str section exists but doesn't contain anything, yaml2obj will emit a section header for it. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D86860
2020-08-29[DWARFYAML] Make the debug_abbrev_offset field optional.Xing GUO1-8/+14
This patch helps make the debug_abbrev_offset field optional. We don't need to calculate the value of this field in the future. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86614
2020-08-26[DWARFYAML] Make the unit_length and header_length fields optional.Xing GUO1-2/+2
This patch makes the unit_length and header_length fields of line tables optional. yaml2obj is able to infer them for us. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86590
2020-08-25[DWARFYAML] Make the 'Attributes' field optional.Xing GUO1-1/+1
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
2020-08-21Recommit: [DWARFYAML] Add support for referencing different abbrev tables.Xing GUO1-0/+29
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
2020-08-21Revert "[DWARFYAML] Add support for referencing different abbrev tables."Xing GUO1-29/+0
This reverts commit f7ff0ace96db9164dcde232c36cab6519ea4fce8. This change is causing build failure. http://lab.llvm.org:8011/builders/clang-cmake-armv7-global-isel/builds/10400
2020-08-21[DWARFYAML] Add support for referencing different abbrev tables.Xing GUO1-0/+29
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
2020-08-21[DWARFYAML] Add support for emitting multiple abbrev tables.Xing GUO1-2/+7
This patch adds support for emitting multiple abbrev tables. Currently, compilation units will always reference the first abbrev table. Reviewed By: jhenderson, labath Differential Revision: https://reviews.llvm.org/D86194
2020-08-15[DWARFYAML] Simplify isEmpty(). NFC.Xing GUO1-3/+1
2020-08-13[DWARFYAML] Replace InitialLength with Format and Length. NFC.Xing GUO1-7/+1
This change replaces the InitialLength of pub-tables with Format and Length. All the InitialLength fields have been removed. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85880
2020-08-12[DWARFYAML] Make the address size of compilation units optional.Xing GUO1-1/+1
This patch makes the 'AddrSize' field optional. If the address size is missing, yaml2obj will infer it from the object file. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85805
2020-08-11[macho2yaml] Refactor the DWARF section dumpers.Xing GUO1-1/+1
This patch refactors the DWARF section dumpers. When dumping a DWARF section, if the DWARF parser fails to parse the section, we will dump it as a raw content section. This patch also fixes a bug in DWARFYAML::Data::isEmpty(). Finally, a test case that tests dumping the __debug_aranges section is added. Reviewed By: jhenderson, grimar Differential Revision: https://reviews.llvm.org/D85506
2020-08-06[DWARFYAML][debug_info] Make the 'Values' field optional.Xing GUO1-1/+1
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
2020-08-06[DWARFYAML][debug_info] Pull out dwarf::FormParams from DWARFYAML::Unit.Xing GUO1-4/+4
Unit.Format, Unit.Version and Unit.AddrSize are replaced with dwarf::FormParams in D84496 to get rid of unnecessary functions getOffsetSize() and getRefSize(). However, that change makes it difficult to make AddrSize optional (Optional<uint8_t>). This change pulls out dwarf::FormParams from DWARFYAML::Unit and use it as a helper struct in DWARFYAML::emitDebugInfo(). Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D85296
2020-08-03[DWARFYAML] Implement the .debug_loclists section.Xing GUO1-0/+17
This patch implements the .debug_loclists section. There are only two DWARF expressions are implemented in this patch (DW_OP_consts, DW_OP_stack_value). We will implement more in the future. The YAML description of the .debug_loclists section is: ``` debug_loclists: - Format: DWARF32 ## Optional Length: 0x1234 ## Optional Version: 5 ## Optional (5 by default) AddressSize: 8 ## Optional SegmentSelectorSize: 0 ## Optional (0 by default) OffsetEntryCount: 1 ## Optional Offsets: [ 1 ] ## Optional Lists: - Entries: - Operator: DW_LLE_startx_endx Values: [ 0x1234, 0x4321 ] DescriptorsLength: 0x1234 ## Optional Descriptors: - Operator: DW_OP_consts Values: [ 0x1234 ] ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84234
2020-08-02[DWARFYAML][debug_aranges] Make the 'Descriptors' field optional.Xing GUO1-1/+1
2020-07-31[DWARFYAML] Make the debug_aranges entry optional.Xing GUO1-4/+3
This patch makes the 'debug_aranges' entry optional. If the entry is empty, yaml2obj will only emit the header for it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84921
2020-07-30[DWARFYAML] Make the 'Length' field of the address range table optional.Xing GUO1-1/+1
This patch makes the 'Length' field of the address range table optional. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84911
2020-07-30[DWARFYAML] Make the 'AddressSize', 'SegmentSelectorSize' fields optional.Xing GUO1-2/+2
This patch makes the 'AddressSize' and 'SegmentSelectorSize' fields of address range table optional. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84907
2020-07-29[DWARFYAML] Make the field names consistent with the DWARF spec. NFC.Xing GUO1-2/+2
This patch replaces 'AddrSize'/'SegSize' with 'AddressSize'/'SegmentSelectorSize'. NFC.
2020-07-28[DWARFYAML] Add support for emitting custom range list content.Xing GUO1-0/+9
This patch adds support for emitting custom range list content. We are able to handcraft a custom range list via the following syntax. ``` debug_rnglists: - Lists: - Entries: - Operator: DW_RLE_startx_endx Values: [ 0x1234, 0x1234 ] - Content: '1234567890abcdef' - Content: 'abcdef1234567890' ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84618
2020-07-26[DWARFYAML] Rename getUsedSectionNames() to getNonEmptySectionNames().Xing GUO1-1/+1
This patch renames getUsedSectionNames() to getNonEmptySectionNames. NFC.
2020-07-24[DWARFYAML] Replace 'Format', 'Version', etc with 'FormParams'. NFC.Xing GUO1-4/+4
This patch replaces 'Format', 'Version' fields, etc with 'FormParams' to simplify codes. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D84496
2020-07-23[DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.Xing GUO1-1/+1
This patch refactors `emitDebugInfo()` to make the length field be inferred from its content. Besides, the `Visitor` class is removed in this patch. The original `Visitor` class helps us determine an appropriate length and emit the .debug_info section. These two processes can be merged into one process. Besides, the length field should be inferred when it's missing rather than when it's zero. Reviewed By: jhenderson, labath Differential Revision: https://reviews.llvm.org/D84008
2020-07-23[DWARFYAML] Refactor range list table to hold more data structure.Xing GUO1-13/+15
This patch refactors the range list table to hold both the range list table and the location list table. Reviewed By: jhenderson, labath Differential Revision: https://reviews.llvm.org/D84239
2020-07-22[DWARFYAML] Make the length field of compilation units optional. NFC.Xing GUO1-1/+1
This patch makes the length field of compilation units optional (0 by default).
2020-07-20[DWARFYAML] Implement the .debug_rnglists section.Xing GUO1-0/+26
This patch implements the .debug_rnglists section. We are able to produce the .debug_rnglists section by the following syntax. ``` debug_rnglists: - Format: DWARF32 ## Optional Length: 0x1234 ## Optional Version: 5 ## Optional AddressSize: 0x08 ## Optional SegmentSelectorSize: 0x00 ## Optional OffsetEntryCount: 2 ## Optional Offsets: [1, 2] ## Optional Lists: - Entries: - Operator: DW_RLE_base_address Values: [ 0x1234 ] ``` The generated .debug_rnglists is verified by llvm-dwarfdump, except for the operator DW_RLE_startx_endx, since llvm-dwarfdump doesn't support it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D83624
2020-07-16[DWARFYAML] Implement the .debug_str_offsets section.Xing GUO1-0/+12
This patch helps add support for emitting the .debug_str_offsets section to yaml2elf. Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D83853
2020-07-03[ObjectYAML][ELF] Add support for emitting the .debug_gnu_pubnames/pubtypes ↵Xing GUO1-0/+4
sections. This patch helps add support for emitting the .debug_gnu_pubnames and .debug_gnu_pubtypes sections. The .debug_gnu_pub* sections is verified by llvm-dwarfdump. Known issues: - Doesn't support emitting multiple pub-tables. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D82367
2020-07-03[DWARFYAML][debug_gnu_*] Add the missing context `IsGNUStyle`. NFC.Xing GUO1-6/+6
This patch helps add the missing context `IsGNUStyle`. Before this patch, yaml2obj cannot parse the YAML description of 'debug_gnu_pubnames' and 'debug_gnu_pubtypes' correctly due to the missing context. In other words, if we have ``` DWARF: debug_gnu_pubtypes: Length: TotalLength: 0x1234 Version: 2 UnitOffset: 0x1234 UnitSize: 0x4321 Entries: - DieOffset: 0x12345678 Name: abc Descriptor: 0x00 ## Descriptor can never be mapped into Entry.Descriptor ``` yaml2obj will complain that "error: unknown key 'Descriptor'". This patch helps resolve this problem. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D82435
2020-06-30[DWARFYAML][debug_info] Replace 'InitialLength' with 'Format' and 'Length'.Xing GUO1-0/+1
'InitialLength' is replaced with 'Format' (DWARF32 by default) and 'Length' in this patch. Besides, test cases for DWARFv4 and DWARFv5, DWARF32 and DWARF64 is added. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D82622
2020-06-24[ObjectYAML][DWARF] Remove unused context. NFC.Xing GUO1-3/+0
The context is unused. This patch helps remove it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D82351
2020-06-24[ObjectYAML][ELF] Add support for emitting the .debug_pubtypes section.Xing GUO1-0/+2
This patch helps add support for emitting the .debug_pubtypes section. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D82347
2020-06-23[ObjectYAML][ELF] Add support for emitting the .debug_pubnames section.Xing GUO1-0/+2
This patch helps add support for emitting the .debug_pubnames section to yaml2elf. Known issues: - Current implementation doesn't support emitting multiple sets of entries. - Doesn't support DWARF64. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D82296
2020-06-20[ObjectYAML][ELF] Add support for emitting the .debug_info section.Xing GUO1-0/+2
This patch helps add support for emitting the .debug_info section to yaml2elf. Reviewed By: jhenderson, grimar, MaskRay Differential Revision: https://reviews.llvm.org/D82073
2020-06-18[DWARFYAML][debug_abbrev] Make the abbreviation code optional.Xing GUO1-1/+1
This patch helps make the `Code` optional in abbreviations table. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D81826
2020-06-18[ObjectYAML][ELF] Add support for emitting the .debug_abbrev section.Xing GUO1-0/+2
This patch enables yaml2elf emit the .debug_abbrev section. The generated .debug_abbrev is verified using `llvm-dwarfdump`. Known issues that will be addressed later: - Current implementation doesn't support generating multiple abbreviation tables in one .debug_abbrev section. Reviewed By: jhenderson, grimar Differential Revision: https://reviews.llvm.org/D81820
2020-06-16[ObjectYAML][DWARF] Implement the .debug_addr section.Xing GUO1-0/+19
This patch implements the .debug_addr section. Reviewed By: jhenderson, grimar Differential Revision: https://reviews.llvm.org/D81541