Skip to content

Commit 690c6e9

Browse files
dominikmascherbauerolpaw
authored andcommitted
[GR-62835] Assertion error when loading native image debug info in GDB 16.
PullRequest: graal/20252
2 parents 365d215 + 475ed56 commit 690c6e9

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfAbbrevSectionImpl.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ private int writeClassLayoutAbbrevs(@SuppressWarnings("unused") DebugContext con
11161116
int pos = p;
11171117
pos = writeClassLayoutAbbrev(context, AbbrevCode.CLASS_LAYOUT_1, buffer, pos);
11181118
pos = writeClassLayoutAbbrev(context, AbbrevCode.CLASS_LAYOUT_3, buffer, pos);
1119+
pos = writeClassLayoutAbbrev(context, AbbrevCode.CLASS_LAYOUT_4, buffer, pos);
11191120
if (!dwarfSections.useHeapBase()) {
11201121
pos = writeClassLayoutAbbrev(context, AbbrevCode.CLASS_LAYOUT_2, buffer, pos);
11211122
}
@@ -1130,21 +1131,23 @@ private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont
11301131
pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
11311132
pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
11321133
pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
1133-
if (abbrevCode == AbbrevCode.CLASS_LAYOUT_3) {
1134+
if (abbrevCode == AbbrevCode.CLASS_LAYOUT_3 || abbrevCode == AbbrevCode.CLASS_LAYOUT_4) {
11341135
pos = writeAttrType(DwarfAttribute.DW_AT_declaration, buffer, pos);
11351136
pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
11361137
pos = writeAttrType(DwarfAttribute.DW_AT_signature, buffer, pos);
11371138
pos = writeAttrForm(DwarfForm.DW_FORM_ref_sig8, buffer, pos);
1139+
if (abbrevCode == AbbrevCode.CLASS_LAYOUT_4) {
1140+
pos = writeAttrType(DwarfAttribute.DW_AT_decl_file, buffer, pos);
1141+
pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
1142+
/*-
1143+
* At present we definitely don't have a line number for the class itself.
1144+
pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
1145+
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
1146+
*/
1147+
}
11381148
} else {
11391149
pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
11401150
pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
1141-
pos = writeAttrType(DwarfAttribute.DW_AT_decl_file, buffer, pos);
1142-
pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
1143-
/*-
1144-
* At present we definitely don't have a line number for the class itself.
1145-
pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
1146-
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
1147-
*/
11481151
if (abbrevCode == AbbrevCode.CLASS_LAYOUT_2) {
11491152
pos = writeAttrType(DwarfAttribute.DW_AT_data_location, buffer, pos);
11501153
pos = writeAttrForm(DwarfForm.DW_FORM_expr_loc, buffer, pos);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfDebugInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ enum AbbrevCode {
7070
CLASS_LAYOUT_1,
7171
CLASS_LAYOUT_2,
7272
CLASS_LAYOUT_3,
73+
CLASS_LAYOUT_4,
7374
TYPE_POINTER_SIG,
7475
TYPE_POINTER,
7576
FOREIGN_TYPEDEF,

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfInfoSectionImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public int generateContent(DebugContext context, byte[] buffer) {
162162
private int writeSkeletonClassLayout(DebugContext context, ClassEntry classEntry, byte[] buffer, int p) {
163163
int pos = p;
164164
log(context, " [0x%08x] class layout", pos);
165-
AbbrevCode abbrevCode = AbbrevCode.CLASS_LAYOUT_3;
165+
AbbrevCode abbrevCode = AbbrevCode.CLASS_LAYOUT_4;
166166
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode.ordinal());
167167
pos = writeAbbrevCode(abbrevCode, buffer, pos);
168168
String name = classEntry.getTypeName();
@@ -173,6 +173,9 @@ private int writeSkeletonClassLayout(DebugContext context, ClassEntry classEntry
173173
long typeSignature = classEntry.getLayoutTypeSignature();
174174
log(context, " [0x%08x] type specification 0x%x", pos, typeSignature);
175175
pos = writeTypeSignature(typeSignature, buffer, pos);
176+
int fileIdx = classEntry.getFileIdx();
177+
log(context, " [0x%08x] file 0x%x (%s)", pos, fileIdx, classEntry.getFileName());
178+
pos = writeAttrData2((short) fileIdx, buffer, pos);
176179

177180
pos = writeStaticFieldDeclarations(context, classEntry, buffer, pos);
178181
pos = writeMethodDeclarations(context, classEntry, buffer, pos);
@@ -646,9 +649,6 @@ private int writeClassLayoutTypeUnit(DebugContext context, ClassEntry classEntry
646649
int size = classEntry.getSize();
647650
log(context, " [0x%08x] byte_size 0x%x", pos, size);
648651
pos = writeAttrData2((short) size, buffer, pos);
649-
int fileIdx = classEntry.getFileIdx();
650-
log(context, " [0x%08x] file 0x%x (%s)", pos, fileIdx, classEntry.getFileName());
651-
pos = writeAttrData2((short) fileIdx, buffer, pos);
652652
if (abbrevCode == AbbrevCode.CLASS_LAYOUT_2) {
653653
/* Write a data location expression to mask and/or rebase oop pointers. */
654654
log(context, " [0x%08x] data_location", pos);

0 commit comments

Comments
 (0)