Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-56599] Create type units for types during debuginfo generation for referencing across multiple debug info files. #9802

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ At runtime, premain runtime options are set along with main class' arguments in
* (GR-57384) Preserve the origin of a resource included in a native image. The information is included in the report produced by -H:+GenerateEmbeddedResourcesFile.
* (GR-58000) Support for `GetStringUTFLengthAsLong` added in JNI_VERSION_24 ([JDK-8328877](https://bugs.openjdk.org/browse/JDK-8328877))
* (GR-58383) The length of the printed stack trace when using `-XX:MissingRegistrationReportingMode=Warn` can now be set with `-XX:MissingRegistrationWarnContextLines=` and its default length is now 8.
* (GR-56599) Update native image debuginfo from DWARF4 to DWARF5 and store type information for debugging in DWARF type units.

## GraalVM for JDK 23 (Internal Version 24.1.0)
* (GR-51520) The old class initialization strategy, which was deprecated in GraalVM for JDK 22, is removed. The option `StrictImageHeap` no longer has any effect.
Expand Down
6 changes: 3 additions & 3 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,10 @@
"cflags": ["-Zi", "-O2", "-D_LITTLE_ENDIAN"],
},
"linux": {
"cflags": ["-g", "-gdwarf-4", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
"cflags": ["-g", "-gdwarf-5", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
},
"<others>": {
"cflags": ["-g", "-gdwarf-4", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
"cflags": ["-g", "-gdwarf-5", "-fPIC", "-O2", "-D_LITTLE_ENDIAN", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0"],
},
},
"jacoco" : "exclude",
Expand Down Expand Up @@ -856,7 +856,7 @@
"cflags": ["-g", "-fPIC", "-O2", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden"],
},
"linux": {
"cflags": ["-g", "-gdwarf-4", "-fPIC", "-O2", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0", "-D_GNU_SOURCE"],
"cflags": ["-g", "-gdwarf-5", "-fPIC", "-O2", "-ffunction-sections", "-fdata-sections", "-fvisibility=hidden", "-D_FORTIFY_SOURCE=0", "-D_GNU_SOURCE"],
},
"<others>": {
"ignore": "only darwin and linux are supported",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugArrayTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
import jdk.vm.ci.meta.ResolvedJavaType;

import jdk.graal.compiler.debug.DebugContext;
import jdk.vm.ci.meta.ResolvedJavaType;

public class ArrayTypeEntry extends StructureTypeEntry {
private TypeEntry elementType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@
import java.util.List;
import java.util.stream.Stream;

import org.graalvm.collections.EconomicMap;

import com.oracle.objectfile.debugentry.range.PrimaryRange;
import com.oracle.objectfile.debugentry.range.Range;
import com.oracle.objectfile.debugentry.range.SubRange;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
import org.graalvm.collections.EconomicMap;
import jdk.graal.compiler.debug.DebugContext;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFieldInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFrameSizeChange;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugInstanceTypeInfo;
Expand All @@ -47,6 +44,10 @@
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;

import jdk.graal.compiler.debug.DebugContext;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;

/**
* Track debug info associated with a Java class.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ public String getCachePath() {
return cachePath;
}

public boolean isHubClassEntry(ClassEntry classEntry) {
return classEntry.getTypeName().equals(DwarfDebugInfo.HUB_TYPE_NAME);
public boolean isHubClassEntry(StructureTypeEntry typeEntry) {
return typeEntry.getTypeName().equals(DwarfDebugInfo.HUB_TYPE_NAME);
}

public ClassEntry getHubClassEntry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

package com.oracle.objectfile.debugentry;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugEnumTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;

import jdk.graal.compiler.debug.DebugContext;

public class EnumClassEntry extends ClassEntry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
package com.oracle.objectfile.debugentry;

import com.oracle.objectfile.debuginfo.DebugInfoProvider;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugForeignTypeInfo;
import jdk.vm.ci.meta.ResolvedJavaType;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;

import jdk.graal.compiler.debug.DebugContext;
import jdk.vm.ci.meta.ResolvedJavaType;

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

public void setLayoutTypeSignature(long typeSignature) {
this.layoutTypeSignature = typeSignature;
}

@Override
public void addDebugInfo(DebugInfoBase debugInfoBase, DebugTypeInfo debugTypeInfo, DebugContext debugContext) {
assert debugTypeInfo instanceof DebugForeignTypeInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

package com.oracle.objectfile.debugentry;

import jdk.graal.compiler.debug.DebugContext;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugHeaderTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;

import jdk.graal.compiler.debug.DebugContext;

public class HeaderTypeEntry extends StructureTypeEntry {

public HeaderTypeEntry(String typeName, int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@

package com.oracle.objectfile.debugentry;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugInterfaceTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
import jdk.graal.compiler.debug.DebugContext;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import jdk.graal.compiler.debug.DebugContext;

public class InterfaceClassEntry extends ClassEntry {
private final List<ClassEntry> implementors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@

package com.oracle.objectfile.debugentry;

import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_INTEGRAL;
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_NUMERIC;
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_SIGNED;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
import jdk.graal.compiler.debug.DebugContext;

import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_INTEGRAL;
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_NUMERIC;
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_SIGNED;
import jdk.graal.compiler.debug.DebugContext;

public class PrimitiveTypeEntry extends TypeEntry {
private char typeChar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@

package com.oracle.objectfile.debugentry;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFieldInfo;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.graal.compiler.debug.DebugContext;

import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import com.oracle.objectfile.debuginfo.DebugInfoProvider;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFieldInfo;
import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo;

import jdk.graal.compiler.debug.DebugContext;
import jdk.vm.ci.meta.ResolvedJavaType;

/**
* An intermediate type that provides behaviour for managing fields. This unifies code for handling
* header structures and Java instance and array classes that both support data members.
Expand All @@ -45,9 +48,25 @@ public abstract class StructureTypeEntry extends TypeEntry {
*/
protected final List<FieldEntry> fields;

/**
* The type signature of this types' layout.
*/
protected long layoutTypeSignature;
protected long indirectLayoutTypeSignature;

public StructureTypeEntry(String typeName, int size) {
super(typeName, size);
this.fields = new ArrayList<>();
this.layoutTypeSignature = 0;
this.indirectLayoutTypeSignature = 0;
}

public long getLayoutTypeSignature() {
return layoutTypeSignature;
}

public long getIndirectLayoutTypeSignature() {
return indirectLayoutTypeSignature;
}

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

return builder.toString();
}

@Override
public void addDebugInfo(@SuppressWarnings("unused") DebugInfoBase debugInfoBase, DebugInfoProvider.DebugTypeInfo debugTypeInfo, @SuppressWarnings("unused") DebugContext debugContext) {
super.addDebugInfo(debugInfoBase, debugTypeInfo, debugContext);
// header type does not have a separate layout type
if (this instanceof HeaderTypeEntry) {
this.layoutTypeSignature = typeSignature;
} else {
this.layoutTypeSignature = debugTypeInfo.typeSignature(DwarfDebugInfo.LAYOUT_PREFIX);
}
// header and foreign types are never stored compressed
if (!debugInfoBase.useHeapBase() || this instanceof HeaderTypeEntry || this instanceof ForeignTypeEntry) {
this.indirectLayoutTypeSignature = layoutTypeSignature;
} else {
this.indirectLayoutTypeSignature = debugTypeInfo.typeSignature(DwarfDebugInfo.INDIRECT_PREFIX + DwarfDebugInfo.LAYOUT_PREFIX);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@

package com.oracle.objectfile.debugentry;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
import jdk.graal.compiler.debug.DebugContext;

import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind.ARRAY;
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind.ENUM;
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind.FOREIGN;
Expand All @@ -38,12 +34,24 @@
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind.INTERFACE;
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind.PRIMITIVE;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo;

import jdk.graal.compiler.debug.DebugContext;

public abstract class TypeEntry {
/**
* The name of this type.
*/
protected final String typeName;

/**
* The type signature of this type.
*/
protected long typeSignature;
protected long indirectTypeSignature;

/**
* The offset of the java.lang.Class instance for this class in the image heap or -1 if no such
* object exists.
Expand All @@ -59,6 +67,16 @@ protected TypeEntry(String typeName, int size) {
this.typeName = typeName;
this.size = size;
this.classOffset = -1;
this.typeSignature = 0;
this.indirectTypeSignature = 0;
}

public long getTypeSignature() {
return typeSignature;
}

public long getIndirectTypeSignature() {
return indirectTypeSignature;
}

public long getClassOffset() {
Expand Down Expand Up @@ -127,5 +145,12 @@ public boolean isStructure() {
public void addDebugInfo(@SuppressWarnings("unused") DebugInfoBase debugInfoBase, DebugTypeInfo debugTypeInfo, @SuppressWarnings("unused") DebugContext debugContext) {
/* Record the location of the Class instance in the heap if there is one */
this.classOffset = debugTypeInfo.classOffset();
this.typeSignature = debugTypeInfo.typeSignature("");
// primitives, header and foreign types are never stored compressed
if (!debugInfoBase.useHeapBase() || this instanceof PrimitiveTypeEntry || this instanceof HeaderTypeEntry || this instanceof ForeignTypeEntry) {
this.indirectTypeSignature = typeSignature;
} else {
this.indirectTypeSignature = debugTypeInfo.typeSignature(DwarfDebugInfo.INDIRECT_PREFIX);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ public String toString() {
*/
String typeName();

/**
* @return a 64bit type signature to uniquely identify the type
*/
long typeSignature(String prefix);

DebugTypeKind typeKind();

/**
Expand Down
Loading
Loading