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.
I would suggest modifying the test case (c) by duplicating entries in abbrev tables and in compilation units in llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml rather than creating a standalone test case here.
I think the following YAML is a good candidate that replaces the one in test case (c). Please ping me if it doesn't work.
--- !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: 45 offset: 528 align: 0 reloff: 0x00000000 nreloc: 0 flags: 0x00000000 reserved1: 0x00000000 reserved2: 0x00000000 reserved3: 0x00000000 - sectname: __debug_info segname: __DWARF addr: 0x00 size: 90 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 - Code: 2 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 - 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 Tag: DW_TAG_compile_unit Children: DW_CHILDREN_no Attributes: - Attribute: DW_AT_low_pc Form: DW_FORM_udata - Code: 2 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 Entries: - AbbrCode: 1 Values: - Value: 0x1234 - AbbrCode: 2 Values: - Value: 0x1234 - Version: 4 AbbrevTableID: 2 Entries: - AbbrCode: 1 Values: - Value: 0x4321 - AbbrCode: 2 Values: - Value: 0x4321 - Version: 4 AbbrevTableID: 0 Entries: - AbbrCode: 1 Values: - Value: 0x5678 - AbbrCode: 2 Values: - Value: 0x5678 - Version: 4 AbbrevTableID: 1 Entries: - AbbrCode: 1 Values: - Value: 0x8765 - AbbrCode: 2 Values: - Value: 0x8765