1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

Fix debug_abbrev emitter to only assign table id once

While generating yamls for my tests I noticed that the new debug_abbrev format (with multiple table support) was incorrectly assigning id's to the table because it was generating one per abbrev entry in the table. For instance, the first table would get id 4 when 5 abbrev entries existed in the table. By itself this is not a problem but the corresponding debug_info sections were still referencing id 0. This was introduced here: https://reviews.llvm.org/D83116.

Maybe a better fix is to actually correctly calculate the table id when emitting debug info? From a quick glance it seems to me the ID is just being calculated as the distance between the first DWARFAbbreviationDeclarationSet and the one the debug info entry points to, which means it's just its index and not the actual table id that was generated when emitting the debug_abbrev tables. With my fix I guess this is fine but on the diff that introduced this Pavel mentioned that he would like to have some sort of unique id between them but not necessarily +1 increasing, but for that to work we need to actually find the table ID, I guess by going directly to Y.DebugAbbrev but to honest I have no idea how to link the DWARFAbbreviationDeclarationSet and the Y.DebugAbbrev, so I just did this simple fix.

I also realized there's barely any tests for MachO so it might useful to invest on that if the tool is being reworked on.

Reviewed By: Higuoxing, jhenderson

Differential Revision: https://reviews.llvm.org/D87179
This commit is contained in:
António Afonso 2020-11-08 18:09:32 -08:00
parent 5df05c4c9a
commit b3e4704ff5
2 changed files with 17 additions and 7 deletions

View File

@ -699,6 +699,12 @@ DWARF:
# MULTI-TABLES-NEXT: Attributes:
# MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc
# MULTI-TABLES-NEXT: Form: DW_FORM_data4
# MULTI-TABLES-NEXT: - Code: 0x0000000000000002
# 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
@ -707,6 +713,7 @@ DWARF:
# MULTI-TABLES-NEXT: Attributes:
# MULTI-TABLES-NEXT: - Attribute: DW_AT_low_pc
# MULTI-TABLES-NEXT: Form: DW_FORM_udata
# MULTI-TABLES-NEXT: - ID: 3
# MULTI-TABLES-NEXT: debug_info:
# MULTI-TABLES-NEXT: - Length: 0x000000000000000C
# MULTI-TABLES-NEXT: Version: 4
@ -738,7 +745,7 @@ DWARF:
# MULTI-TABLES-NEXT: - Length: 0x000000000000000B
# MULTI-TABLES-NEXT: Version: 4
# MULTI-TABLES-NEXT: AbbrevTableID: 2
# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000010
# MULTI-TABLES-NEXT: AbbrOffset: 0x0000000000000017
# MULTI-TABLES-NEXT: AddrSize: 8
# MULTI-TABLES-NEXT: Entries:
# MULTI-TABLES-NEXT: - AbbrCode: 0x00000001
@ -772,7 +779,7 @@ LoadCommands:
- sectname: __debug_abbrev
segname: __DWARF
addr: 0x00
size: 24
size: 32
offset: 528
align: 0
reloff: 0x00000000
@ -810,6 +817,12 @@ DWARF:
Attributes:
- Attribute: DW_AT_low_pc
Form: DW_FORM_data4
- Code: 2
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes:
- Attribute: DW_AT_low_pc
Form: DW_FORM_data4
- ID: 1
Table:
- Code: 1
@ -818,31 +831,28 @@ DWARF:
Attributes:
- Attribute: DW_AT_low_pc
Form: DW_FORM_udata
- ID: 3
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:

View File

@ -26,6 +26,7 @@ void dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) {
uint64_t AbbrevTableID = 0;
for (auto AbbrvDeclSet : *AbbrevSetPtr) {
Y.DebugAbbrev.emplace_back();
Y.DebugAbbrev.back().ID = AbbrevTableID++;
for (auto AbbrvDecl : AbbrvDeclSet.second) {
DWARFYAML::Abbrev Abbrv;
Abbrv.Code = AbbrvDecl.getCode();
@ -40,7 +41,6 @@ void dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) {
AttAbrv.Value = Attribute.getImplicitConstValue();
Abbrv.Attributes.push_back(AttAbrv);
}
Y.DebugAbbrev.back().ID = AbbrevTableID++;
Y.DebugAbbrev.back().Table.push_back(Abbrv);
}
}