Skip to content

Commit 45e94b6

Browse files
Update debug info generation to DWARF 5, Move type info into type units, Bugfixes and cleanup for debug info generation
1 parent be67923 commit 45e94b6

27 files changed

+1692
-1284
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,10 @@
795795
"cflags": ["-Zi", "-O2", "-D_LITTLE_ENDIAN"],
796796
},
797797
"linux": {
798-
"cflags": ["-g", "-gdwarf-4", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
798+
"cflags": ["-g", "-gdwarf-5", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
799799
},
800800
"<others>": {
801-
"cflags": ["-g", "-gdwarf-4", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
801+
"cflags": ["-g", "-gdwarf-5", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
802802
},
803803
},
804804
"jacoco" : "exclude",
@@ -856,7 +856,7 @@
856856
"cflags": ["-g", "-fPIC", "-O2", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden"],
857857
},
858858
"linux": {
859-
"cflags": ["-g", "-gdwarf-4", "-fPIC", "-O2", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0", "-D_GNU_SOURCE"],
859+
"cflags": ["-g", "-gdwarf-5", "-fPIC", "-O2", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0", "-D_GNU_SOURCE"],
860860
},
861861
"<others>": {
862862
"ignore": "only darwin and linux are supported",

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ArrayTypeEntry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugArrayTypeInfo;
3030
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
3131
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
32-
import jdk.vm.ci.meta.ResolvedJavaType;
32+
3333
import jdk.graal.compiler.debug.DebugContext;
34+
import jdk.vm.ci.meta.ResolvedJavaType;
3435

3536
public class ArrayTypeEntry extends StructureTypeEntry {
3637
private TypeEntry elementType;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@
3030
import java.util.List;
3131
import java.util.stream.Stream;
3232

33+
import org.graalvm.collections.EconomicMap;
34+
3335
import com.oracle.objectfile.debugentry.range.PrimaryRange;
3436
import com.oracle.objectfile.debugentry.range.Range;
3537
import com.oracle.objectfile.debugentry.range.SubRange;
36-
import jdk.vm.ci.meta.ResolvedJavaMethod;
37-
import jdk.vm.ci.meta.ResolvedJavaType;
38-
import org.graalvm.collections.EconomicMap;
39-
import jdk.graal.compiler.debug.DebugContext;
40-
4138
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFieldInfo;
4239
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFrameSizeChange;
4340
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugInstanceTypeInfo;
@@ -47,6 +44,10 @@
4744
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
4845
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
4946

47+
import jdk.graal.compiler.debug.DebugContext;
48+
import jdk.vm.ci.meta.ResolvedJavaMethod;
49+
import jdk.vm.ci.meta.ResolvedJavaType;
50+
5051
/**
5152
* Track debug info associated with a Java class.
5253
*/

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/DebugInfoBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,8 @@ public String getCachePath() {
737737
return cachePath;
738738
}
739739

740-
public boolean isHubClassEntry(ClassEntry classEntry) {
741-
return classEntry.getTypeName().equals(DwarfDebugInfo.HUB_TYPE_NAME);
740+
public boolean isHubClassEntry(StructureTypeEntry typeEntry) {
741+
return typeEntry.getTypeName().equals(DwarfDebugInfo.HUB_TYPE_NAME);
742742
}
743743

744744
public ClassEntry getHubClassEntry() {

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/EnumClassEntry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626

2727
package com.oracle.objectfile.debugentry;
2828

29-
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
3029
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugEnumTypeInfo;
30+
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
3131
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
32+
3233
import jdk.graal.compiler.debug.DebugContext;
3334

3435
public class EnumClassEntry extends ClassEntry {

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ForeignTypeEntry.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
package com.oracle.objectfile.debugentry;
2828

2929
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
30-
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
3130
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugForeignTypeInfo;
32-
import jdk.vm.ci.meta.ResolvedJavaType;
31+
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
32+
3333
import jdk.graal.compiler.debug.DebugContext;
34+
import jdk.vm.ci.meta.ResolvedJavaType;
3435

3536
public class ForeignTypeEntry extends ClassEntry {
3637
private static final int FLAG_WORD = 1 << 0;
@@ -57,6 +58,10 @@ public DebugInfoProvider.DebugTypeInfo.DebugTypeKind typeKind() {
5758
return DebugInfoProvider.DebugTypeInfo.DebugTypeKind.FOREIGN;
5859
}
5960

61+
public void setLayoutTypeSignature(long typeSignature) {
62+
this.layoutTypeSignature = typeSignature;
63+
}
64+
6065
@Override
6166
public void addDebugInfo(DebugInfoBase debugInfoBase, DebugTypeInfo debugTypeInfo, DebugContext debugContext) {
6267
assert debugTypeInfo instanceof DebugForeignTypeInfo;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/HeaderTypeEntry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
package com.oracle.objectfile.debugentry;
2828

29-
import jdk.graal.compiler.debug.DebugContext;
30-
3129
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugHeaderTypeInfo;
3230
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
3331
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
3432

33+
import jdk.graal.compiler.debug.DebugContext;
34+
3535
public class HeaderTypeEntry extends StructureTypeEntry {
3636

3737
public HeaderTypeEntry(String typeName, int size) {

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/InterfaceClassEntry.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626

2727
package com.oracle.objectfile.debugentry;
2828

29+
import java.util.ArrayList;
30+
import java.util.List;
31+
import java.util.stream.Stream;
32+
2933
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugInterfaceTypeInfo;
3034
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
3135
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
32-
import jdk.graal.compiler.debug.DebugContext;
3336

34-
import java.util.ArrayList;
35-
import java.util.List;
36-
import java.util.stream.Stream;
37+
import jdk.graal.compiler.debug.DebugContext;
3738

3839
public class InterfaceClassEntry extends ClassEntry {
3940
private final List<ClassEntry> implementors;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/PrimitiveTypeEntry.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626

2727
package com.oracle.objectfile.debugentry;
2828

29+
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_INTEGRAL;
30+
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_NUMERIC;
31+
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_SIGNED;
32+
2933
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo;
3034
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
3135
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
32-
import jdk.graal.compiler.debug.DebugContext;
3336

34-
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_INTEGRAL;
35-
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_NUMERIC;
36-
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_SIGNED;
37+
import jdk.graal.compiler.debug.DebugContext;
3738

3839
public class PrimitiveTypeEntry extends TypeEntry {
3940
private char typeChar;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/StructureTypeEntry.java

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@
2626

2727
package com.oracle.objectfile.debugentry;
2828

29-
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFieldInfo;
30-
import jdk.vm.ci.meta.ResolvedJavaType;
31-
import jdk.graal.compiler.debug.DebugContext;
32-
3329
import java.lang.reflect.Modifier;
3430
import java.util.ArrayList;
3531
import java.util.List;
3632
import java.util.stream.Stream;
3733

34+
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
35+
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFieldInfo;
36+
import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo;
37+
38+
import jdk.graal.compiler.debug.DebugContext;
39+
import jdk.vm.ci.meta.ResolvedJavaType;
40+
3841
/**
3942
* An intermediate type that provides behaviour for managing fields. This unifies code for handling
4043
* header structures and Java instance and array classes that both support data members.
@@ -45,9 +48,25 @@ public abstract class StructureTypeEntry extends TypeEntry {
4548
*/
4649
protected final List<FieldEntry> fields;
4750

51+
/**
52+
* The type signature of this types' layout.
53+
*/
54+
protected long layoutTypeSignature;
55+
protected long indirectLayoutTypeSignature;
56+
4857
public StructureTypeEntry(String typeName, int size) {
4958
super(typeName, size);
5059
this.fields = new ArrayList<>();
60+
this.layoutTypeSignature = 0;
61+
this.indirectLayoutTypeSignature = 0;
62+
}
63+
64+
public long getLayoutTypeSignature() {
65+
return layoutTypeSignature;
66+
}
67+
68+
public long getIndirectLayoutTypeSignature() {
69+
return indirectLayoutTypeSignature;
5170
}
5271

5372
public Stream<FieldEntry> fields() {
@@ -118,4 +137,21 @@ String memberModifiers(int modifiers) {
118137

119138
return builder.toString();
120139
}
140+
141+
@Override
142+
public void addDebugInfo(@SuppressWarnings("unused") DebugInfoBase debugInfoBase, DebugInfoProvider.DebugTypeInfo debugTypeInfo, @SuppressWarnings("unused") DebugContext debugContext) {
143+
super.addDebugInfo(debugInfoBase, debugTypeInfo, debugContext);
144+
// header type does not have a separate layout type
145+
if (this instanceof HeaderTypeEntry) {
146+
this.layoutTypeSignature = typeSignature;
147+
} else {
148+
this.layoutTypeSignature = debugTypeInfo.typeSignature(DwarfDebugInfo.LAYOUT_PREFIX);
149+
}
150+
// header and foreign types are never stored compressed
151+
if (!debugInfoBase.useHeapBase() || this instanceof HeaderTypeEntry || this instanceof ForeignTypeEntry) {
152+
this.indirectLayoutTypeSignature = layoutTypeSignature;
153+
} else {
154+
this.indirectLayoutTypeSignature = debugTypeInfo.typeSignature(DwarfDebugInfo.INDIRECT_PREFIX + DwarfDebugInfo.LAYOUT_PREFIX);
155+
}
156+
}
121157
}

0 commit comments

Comments
 (0)