Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@

package com.oracle.objectfile.debugentry;

import com.oracle.objectfile.debuginfo.DebugInfoProvider;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo;
import org.graalvm.compiler.debug.DebugContext;

import java.nio.ByteOrder;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import org.graalvm.compiler.debug.DebugContext;

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

/**
* An abstract class which indexes the information presented by the DebugInfoProvider in an
* organization suitable for use by subclasses targeting a specific binary format.
Expand Down Expand Up @@ -126,6 +127,10 @@ public abstract class DebugInfoBase {
* Number of bytes used to store an oop reference.
*/
private int oopReferenceSize;
/**
* Number of bytes used to store a raw pointer.
*/
private int pointerSize;
/**
* Alignment of object memory area (and, therefore, of any oop) in bytes.
*/
Expand All @@ -141,6 +146,7 @@ public DebugInfoBase(ByteOrder byteOrder) {
this.oopTagsCount = 0;
this.oopCompressShift = 0;
this.oopReferenceSize = 0;
this.pointerSize = 0;
this.oopAlignment = 0;
this.oopAlignShift = 0;
}
Expand Down Expand Up @@ -185,6 +191,9 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
/* Save number of bytes in a reference field. */
oopReferenceSize = debugInfoProvider.oopReferenceSize();

/* Save pointer size of current target. */
pointerSize = debugInfoProvider.pointerSize();

/* Save alignment of a reference. */
oopAlignment = debugInfoProvider.oopAlignment();

Expand Down Expand Up @@ -484,6 +493,10 @@ public int oopReferenceSize() {
return oopReferenceSize;
}

public int pointerSize() {
return pointerSize;
}

public int oopAlignment() {
return oopAlignment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public interface DebugInfoProvider {
*/
int oopReferenceSize();

/**
* Number of bytes used to store a raw pointer.
*/
int pointerSize();

/**
* Alignment of object memory area (and, therefore, of any oop) in bytes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@

package com.oracle.objectfile.elf.dwarf;

import java.lang.reflect.Modifier;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;

import org.graalvm.compiler.debug.DebugContext;

import com.oracle.objectfile.BuildDependency;
import com.oracle.objectfile.LayoutDecision;
import com.oracle.objectfile.LayoutDecisionMap;
Expand All @@ -41,15 +48,8 @@
import com.oracle.objectfile.debugentry.Range;
import com.oracle.objectfile.debugentry.StructureTypeEntry;
import com.oracle.objectfile.debugentry.TypeEntry;
import com.oracle.objectfile.elf.ELFObjectFile;
import org.graalvm.compiler.debug.DebugContext;

import java.lang.reflect.Modifier;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo;
import com.oracle.objectfile.elf.ELFObjectFile;

/**
* Section generator for debug_info section.
Expand Down Expand Up @@ -851,9 +851,9 @@ private int writeClassType(DebugContext context, ClassEntry classEntry, byte[] b
int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_class_pointer;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int byteSize = dwarfSections.oopReferenceSize();
log(context, " [0x%08x] byte_size 0x%x", pos, byteSize);
pos = writeAttrData1((byte) byteSize, buffer, pos);
int pointerSize = dwarfSections.pointerSize();
log(context, " [0x%08x] byte_size 0x%x", pos, pointerSize);
pos = writeAttrData1((byte) pointerSize, buffer, pos);
int layoutOffset = getLayoutIndex(classEntry);
log(context, " [0x%08x] type 0x%x", pos, layoutOffset);
pos = writeAttrRefAddr(layoutOffset, buffer, pos);
Expand All @@ -865,8 +865,9 @@ private int writeClassType(DebugContext context, ClassEntry classEntry, byte[] b
abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_pointer;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] byte_size 0x%x", pos, byteSize);
pos = writeAttrData1((byte) byteSize, buffer, pos);
int oopReferenceSize = dwarfSections.oopReferenceSize();
log(context, " [0x%08x] byte_size 0x%x", pos, oopReferenceSize);
pos = writeAttrData1((byte) oopReferenceSize, buffer, pos);
layoutOffset = getIndirectLayoutIndex(classEntry);
log(context, " [0x%08x] type 0x%x", pos, layoutOffset);
pos = writeAttrRefAddr(layoutOffset, buffer, pos);
Expand All @@ -887,9 +888,9 @@ private int writeInterfaceType(DebugContext context, InterfaceClassEntry interfa
int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_interface_pointer;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int byteSize = dwarfSections.oopReferenceSize();
log(context, " [0x%08x] byte_size 0x%x", pos, byteSize);
pos = writeAttrData1((byte) byteSize, buffer, pos);
int pointerSize = dwarfSections.pointerSize();
log(context, " [0x%08x] byte_size 0x%x", pos, pointerSize);
pos = writeAttrData1((byte) pointerSize, buffer, pos);
int layoutOffset = getLayoutIndex(interfaceClassEntry);
log(context, " [0x%08x] type 0x%x", pos, layoutOffset);
pos = writeAttrRefAddr(layoutOffset, buffer, pos);
Expand All @@ -901,6 +902,7 @@ private int writeInterfaceType(DebugContext context, InterfaceClassEntry interfa
abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_pointer;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int byteSize = dwarfSections.oopReferenceSize();
log(context, " [0x%08x] byte_size 0x%x", pos, byteSize);
pos = writeAttrData1((byte) byteSize, buffer, pos);
layoutOffset = getIndirectLayoutIndex(interfaceClassEntry);
Expand Down Expand Up @@ -1155,9 +1157,9 @@ private int writeArrayTypes(DebugContext context, ArrayTypeEntry arrayTypeEntry,
int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_array_pointer;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int byteSize = dwarfSections.oopReferenceSize();
log(context, " [0x%08x] byte_size 0x%x", pos, byteSize);
pos = writeAttrData1((byte) byteSize, buffer, pos);
int pointerSize = dwarfSections.pointerSize();
log(context, " [0x%08x] byte_size 0x%x", pos, pointerSize);
pos = writeAttrData1((byte) pointerSize, buffer, pos);
log(context, " [0x%08x] type (pointer) 0x%x (%s)", pos, layoutOffset, name);
pos = writeAttrRefAddr(layoutOffset, buffer, pos);

Expand All @@ -1168,6 +1170,7 @@ private int writeArrayTypes(DebugContext context, ArrayTypeEntry arrayTypeEntry,
abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_pointer;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int byteSize = dwarfSections.oopReferenceSize();
log(context, " [0x%08x] byte_size 0x%x", pos, byteSize);
pos = writeAttrData1((byte) byteSize, buffer, pos);
log(context, " [0x%08x] type (pointer) 0x%x (%s)", pos, indirectLayoutOffset, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Integer o
}
};

private static void defaultDebugInfoValueUpdateHandler(EconomicMap<OptionKey<?>, Object> values, @SuppressWarnings("unused") Integer oldValue, Integer newValue) {
public static void defaultDebugInfoValueUpdateHandler(EconomicMap<OptionKey<?>, Object> values, @SuppressWarnings("unused") Integer oldValue, Integer newValue) {
// force update of TrackNodeSourcePosition and DeleteLocalSymbols
TrackNodeSourcePosition.update(values, newValue > 0);
DeleteLocalSymbols.update(values, newValue == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ private void doRun(Map<Method, CEntryPointData> entryPoints,
featureHandler.forEachFeature(feature -> feature.afterHeapLayout(config));

this.image = AbstractBootImage.create(k, hUniverse, hMetaAccess, nativeLibraries, heap, codeCache, hostedEntryPoints, loader.getClassLoader());
image.build(debug);
image.build(imageName, debug);
if (NativeImageOptions.PrintUniverse.getValue()) {
/*
* This debug output must be printed _after_ and not _during_ image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public NativeLibraries getNativeLibs() {
* Build the image. Calling this method is a precondition to calling {@link #write}. It
* typically finalizes content of the object. It does not build debug information.
*/
public abstract void build(DebugContext debug);
public abstract void build(String imageName, DebugContext debug);

/**
* Write the image to the named file. This also writes debug information -- either to the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.util.Timer;
import com.oracle.objectfile.BasicProgbitsSectionImpl;
import com.oracle.objectfile.BuildDependency;
import com.oracle.objectfile.LayoutDecision;
Expand Down Expand Up @@ -400,7 +401,7 @@ private ObjectFile.Symbol defineRelocationForSymbol(String name, long position)
*/
@Override
@SuppressWarnings("try")
public void build(DebugContext debug) {
public void build(String imageName, DebugContext debug) {
try (DebugContext.Scope buildScope = debug.scope("NativeBootImage.build")) {
final CGlobalDataFeature cGlobals = CGlobalDataFeature.singleton();

Expand Down Expand Up @@ -450,9 +451,11 @@ public void build(DebugContext debug) {
* If we constructed debug info give the object file a chance to install it
*/
if (SubstrateOptions.GenerateDebugInfo.getValue(HostedOptionValues.singleton()) > 0) {
ImageSingletons.add(SourceManager.class, new SourceManager());
DebugInfoProvider provider = new NativeImageDebugInfoProvider(debug, codeCache, heap);
objectFile.installDebugInfo(provider);
try (Timer.StopTimer t = new Timer(imageName, "dbginfo").start()) {
ImageSingletons.add(SourceManager.class, new SourceManager());
DebugInfoProvider provider = new NativeImageDebugInfoProvider(debug, codeCache, heap);
objectFile.installDebugInfo(provider);
}
}
// - Write the heap to its own section.
// Dynamic linkers/loaders generally don't ensure any alignment to more than page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@
import java.util.function.Consumer;
import java.util.stream.Stream;

import org.graalvm.compiler.code.CompilationResult;
import org.graalvm.compiler.code.SourceMapping;
import org.graalvm.compiler.core.common.CompressEncoding;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.nativeimage.ImageSingletons;

import com.oracle.graal.pointsto.infrastructure.OriginalClassProvider;
import com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.objectfile.debuginfo.DebugInfoProvider;

import com.oracle.svm.core.StaticFieldsSupport;
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.config.ConfigurationValues;
Expand All @@ -57,26 +63,19 @@
import com.oracle.svm.hosted.meta.HostedArrayClass;
import com.oracle.svm.hosted.meta.HostedClass;
import com.oracle.svm.hosted.meta.HostedField;
import com.oracle.svm.hosted.meta.HostedMethod;
import com.oracle.svm.hosted.meta.HostedType;
import com.oracle.svm.hosted.meta.HostedInstanceClass;
import com.oracle.svm.hosted.meta.HostedInterface;
import com.oracle.svm.hosted.meta.HostedMethod;
import com.oracle.svm.hosted.meta.HostedPrimitiveType;

import com.oracle.svm.hosted.meta.HostedType;
import com.oracle.svm.hosted.substitute.InjectedFieldsType;
import com.oracle.svm.hosted.substitute.SubstitutionField;
import com.oracle.svm.hosted.substitute.SubstitutionMethod;
import com.oracle.svm.hosted.substitute.SubstitutionType;
import jdk.vm.ci.meta.ResolvedJavaField;
import org.graalvm.compiler.code.CompilationResult;
import org.graalvm.compiler.code.SourceMapping;
import org.graalvm.compiler.core.common.CompressEncoding;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.nativeimage.ImageSingletons;

import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.LineNumberTable;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.meta.Signature;
Expand All @@ -93,6 +92,7 @@ class NativeImageDebugInfoProvider implements DebugInfoProvider {
int compressShift;
int tagsMask;
int referenceSize;
int pointerSize;
int referenceAlignment;
int primitiveStartOffset;
int referenceStartOffset;
Expand All @@ -115,6 +115,7 @@ class NativeImageDebugInfoProvider implements DebugInfoProvider {
this.compressShift = 0;
}
this.referenceSize = getObjectLayout().getReferenceSize();
this.pointerSize = ConfigurationValues.getTarget().wordSize;
this.referenceAlignment = getObjectLayout().getAlignment();
/* Offsets need to be adjusted relative to the heap base plus partition-specific offset. */
primitiveStartOffset = (int) primitiveFields.getOffset();
Expand All @@ -136,6 +137,11 @@ public int oopReferenceSize() {
return referenceSize;
}

@Override
public int pointerSize() {
return pointerSize;
}

@Override
public int oopAlignment() {
return referenceAlignment;
Expand Down