Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DWARFLibrary] Add support to re-construct cu-index
Summary: According to DWARF5 specification and gnu specification for DWARF4 the offset entry in the CU/TU Index is 32 bits. This presents a problem when .debug_info.dwo in DWP file grows beyond 4GB. The CU Index becomes partially corrupted. This diff adds manual parsing of .debug_info.dwo/.debug_abbrev.dwo to reconstruct CU index in general, and TU index for DWARF5. This is a work around until DWARF6 spec is finalized. Next patch will change internal CU/TU struct to 64 bit, and change uses as necessary. The plan is to land all the patches in one go after all are approved. This patch originates from the discussion in: https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 Differential Revision: https://reviews.llvm.org/D137882
- Loading branch information
Showing
8 changed files
with
226 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# This test checks if we can correctly parse manull cu and tu index for DWARF5. | ||
|
||
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o \ | ||
# RUN: -split-dwarf-file=%t.dwo -dwarf-version=5 | ||
# RUN: llvm-dwp %t.dwo -o %t.dwp | ||
# RUN: llvm-dwarfdump -debug-info -debug-cu-index -debug-tu-index %t.dwp | FileCheck -check-prefix=CHECK %s | ||
# RUN: llvm-dwarfdump -debug-info -debug-cu-index -debug-tu-index -manaully-generate-unit-index %t.dwp | FileCheck -check-prefix=CHECK2 %s | ||
|
||
## Note: In order to check whether the type unit index is generated | ||
## there is no need to add the missing DIEs for the structure type of the type unit. | ||
|
||
# CHECK-DAG: .debug_info.dwo contents: | ||
# CHECK: 0x00000000: Type Unit: length = 0x00000017, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_type, abbr_offset = 0x0000, addr_size = 0x08, name = '', type_signature = [[TUID1:.*]], type_offset = 0x0019 (next unit at 0x0000001b) | ||
# CHECK: 0x0000001b: Type Unit: length = 0x00000017, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_type, abbr_offset = 0x0000, addr_size = 0x08, name = '', type_signature = [[TUID2:.*]], type_offset = 0x0019 (next unit at 0x00000036) | ||
# CHECK: 0x00000036: Compile Unit: length = 0x00000011, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_compile, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = [[CUID1:.*]] (next unit at 0x0000004b) | ||
# CHECK-DAG: .debug_cu_index contents: | ||
# CHECK: version = 5, units = 1, slots = 2 | ||
# CHECK: Index Signature INFO ABBREV | ||
# CHECK: 1 [[CUID1]] [0x0000000000000036, 0x000000000000004b) [0x00000000, 0x00000010) | ||
# CHECK-DAG: .debug_tu_index contents: | ||
# CHECK: version = 5, units = 2, slots = 4 | ||
# CHECK: Index Signature INFO ABBREV | ||
# CHECK: 1 [[TUID1]] [0x0000000000000000, 0x000000000000001b) [0x00000000, 0x00000010) | ||
# CHECK: 4 [[TUID2]] [0x000000000000001b, 0x0000000000000036) [0x00000000, 0x00000010) | ||
|
||
# CHECK2-DAG: .debug_info.dwo contents: | ||
# CHECK2: 0x00000000: Type Unit: length = 0x00000017, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_type, abbr_offset = 0x0000, addr_size = 0x08, name = '', type_signature = [[TUID1:.*]], type_offset = 0x0019 (next unit at 0x0000001b) | ||
# CHECK2: 0x0000001b: Type Unit: length = 0x00000017, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_type, abbr_offset = 0x0000, addr_size = 0x08, name = '', type_signature = [[TUID2:.*]], type_offset = 0x0019 (next unit at 0x00000036) | ||
# CHECK2: 0x00000036: Compile Unit: length = 0x00000011, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_compile, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = [[CUID1:.*]] (next unit at 0x0000004b) | ||
# CHECK2-DAG: .debug_cu_index contents: | ||
# CHECK2: version = 5, units = 1, slots = 2 | ||
# CHECK2: Index Signature INFO ABBREV | ||
# CHECK2: 1 [[CUID1]] [0x0000000000000036, 0x000000000000004b) [0x00000000, 0x00000010) | ||
# CHECK2-DAG: .debug_tu_index contents: | ||
# CHECK2: version = 5, units = 2, slots = 4 | ||
# CHECK2: Index Signature INFO ABBREV | ||
# CHECK2: 1 [[TUID1]] [0x0000000000000000, 0x000000000000001b) [0x00000000, 0x00000010) | ||
# CHECK2: 4 [[TUID2]] [0x000000000000001b, 0x0000000000000036) [0x00000000, 0x00000010) | ||
|
||
.section .debug_info.dwo,"e",@progbits | ||
.long .Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit | ||
.Ldebug_info_dwo_start0: | ||
.short 5 # DWARF version number | ||
.byte 6 # DWARF Unit Type (DW_UT_split_type) | ||
.byte 8 # Address Size (in bytes) | ||
.long 0 # Offset Into Abbrev. Section | ||
.quad 5657452045627120676 # Type Signature | ||
.long 25 # Type DIE Offset | ||
.byte 2 # Abbrev [2] DW_TAG_type_unit | ||
.byte 3 # Abbrev [3] DW_TAG_structure_type | ||
.byte 0 # End Of Children Mark | ||
.Ldebug_info_dwo_end0: | ||
.section .debug_info.dwo,"e",@progbits | ||
.long .Ldebug_info_dwo_end1-.Ldebug_info_dwo_start1 # Length of Unit | ||
.Ldebug_info_dwo_start1: | ||
.short 5 # DWARF version number | ||
.byte 6 # DWARF Unit Type (DW_UT_split_type) | ||
.byte 8 # Address Size (in bytes) | ||
.long 0 # Offset Into Abbrev. Section | ||
.quad -8528522068957683993 # Type Signature | ||
.long 25 # Type DIE Offset | ||
.byte 4 # Abbrev [4] DW_TAG_type_unit | ||
.byte 5 # Abbrev [5] DW_TAG_structure_type | ||
.byte 0 # End Of Children Mark | ||
.Ldebug_info_dwo_end1: | ||
.section .debug_info.dwo,"e",@progbits | ||
.long .Ldebug_info_dwo_end2-.Ldebug_info_dwo_start2 # Length of Unit | ||
.Ldebug_info_dwo_start2: | ||
.short 5 # DWARF version number | ||
.byte 5 # DWARF Unit Type (DW_UT_split_compile) | ||
.byte 8 # Address Size (in bytes) | ||
.long 0 # Offset Into Abbrev. Section | ||
.quad 1152943841751211454 | ||
.byte 1 # Abbrev [1] DW_TAG_compile_unit | ||
.Ldebug_info_dwo_end2: | ||
.section .debug_abbrev.dwo,"e",@progbits | ||
.byte 1 # Abbreviation Code | ||
.byte 17 # DW_TAG_compile_unit | ||
.byte 0 # DW_CHILDREN_no | ||
.byte 0 # EOM(1) | ||
.byte 0 # EOM(2) | ||
.byte 2 # Abbreviation Code | ||
.byte 65 # DW_TAG_type_unit | ||
.byte 1 # DW_CHILDREN_yes | ||
.byte 0 # EOM | ||
.byte 0 # EOM | ||
.byte 4 # Abbreviation Code | ||
.byte 65 # DW_TAG_type_unit | ||
.byte 1 # DW_CHILDREN_yes | ||
.byte 0 # EOM | ||
.byte 0 # EOM | ||
.byte 0 # EOM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters