Skip to content

Commit

Permalink
Fix DWARF debug information emitted for empty enum (dotnet#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara authored Jun 16, 2023
1 parent dd51247 commit 167a9c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ void Dump(MCObjectStreamer *Streamer, uint16_t DwarfVersion, unsigned TargetPoin
dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
0, 0,

EnumerationTypeNoChildren,
dwarf::DW_TAG_enumeration_type, dwarf::DW_CHILDREN_no,
dwarf::DW_AT_name, dwarf::DW_FORM_strp,
dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
0, 0,

Enumerator1,
dwarf::DW_TAG_enumerator, dwarf::DW_CHILDREN_no,
dwarf::DW_AT_name, dwarf::DW_FORM_strp,
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum DwarfAbbrev : uint16_t
CompileUnit = 0x1,
BaseType,
EnumerationType,
EnumerationTypeNoChildren,
Enumerator1,
Enumerator2,
Enumerator4,
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void DwarfEnumTypeInfo::DumpStrings(MCObjectStreamer *Streamer) {

void DwarfEnumTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) {
// Abbrev Number
Streamer->emitULEB128IntValue(DwarfAbbrev::EnumerationType);
Streamer->emitULEB128IntValue(HasChildren() ? DwarfAbbrev::EnumerationType : DwarfAbbrev::EnumerationTypeNoChildren);

// DW_AT_name
EmitSectionOffset(Streamer, StrSymbol, 4);
Expand Down

0 comments on commit 167a9c5

Please sign in to comment.