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 @@ -35,7 +35,6 @@
import com.oracle.objectfile.ObjectFile.ProgbitsSectionImpl;
import com.oracle.objectfile.ObjectFile.RelocatableSectionImpl;
import com.oracle.objectfile.ObjectFile.RelocationKind;
import com.oracle.objectfile.ObjectFile.RelocationRecord;
import com.oracle.objectfile.ObjectFile.Section;

/**
Expand Down Expand Up @@ -114,15 +113,15 @@ public List<Section> getElements() {
}

@Override
public RelocationRecord markRelocationSite(int offset, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
return ((RelocatableSectionImpl) getElement()).markRelocationSite(offset, ByteBuffer.wrap(getContent()).order(getOwner().getByteOrder()), k, symbolName, useImplicitAddend,
public void markRelocationSite(int offset, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
((RelocatableSectionImpl) getElement()).markRelocationSite(offset, ByteBuffer.wrap(getContent()).order(getOwner().getByteOrder()), k, symbolName, useImplicitAddend,
explicitAddend);
}

@Override
public final RelocationRecord markRelocationSite(int offset, ByteBuffer bb, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
public final void markRelocationSite(int offset, ByteBuffer bb, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
assert getContent() == null || bb.array() == getContent();
return ((RelocatableSectionImpl) getElement()).markRelocationSite(offset, bb, k, symbolName, useImplicitAddend, explicitAddend);
((RelocatableSectionImpl) getElement()).markRelocationSite(offset, bb, k, symbolName, useImplicitAddend, explicitAddend);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,8 @@ public interface RelocatableSectionImpl extends ElementImpl {
* bytes
* @param useImplicitAddend whether the current bytes are to be used as an addend
* @param explicitAddend a full-width addend, or null if useImplicitAddend is true
* @return the relocation record created (or found, if it exists already)
*/
RelocationRecord markRelocationSite(int offset, ByteBuffer bb, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend);
void markRelocationSite(int offset, ByteBuffer bb, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend);

/**
* Force the creation of a relocation section/element for this section, and return it. This
Expand Down Expand Up @@ -441,7 +440,7 @@ public interface ProgbitsSectionImpl extends RelocatableSectionImpl {
* passed a buffer. It uses the byte array accessed by {@link #getContent} and
* {@link #setContent}.
*/
RelocationRecord markRelocationSite(int offset, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend);
void markRelocationSite(int offset, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend);
}

public interface NobitsSectionImpl extends ElementImpl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.oracle.objectfile.ObjectFile.Element;
import com.oracle.objectfile.ObjectFile.ProgbitsSectionImpl;
import com.oracle.objectfile.ObjectFile.RelocationKind;
import com.oracle.objectfile.ObjectFile.RelocationRecord;
import com.oracle.objectfile.io.AssemblyBuffer;
import com.oracle.objectfile.io.OutputAssembler;

Expand Down Expand Up @@ -125,12 +124,12 @@ public Element getOrCreateRelocationElement(boolean useImplicitAddend) {
}

@Override
public RelocationRecord markRelocationSite(int offset, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
public void markRelocationSite(int offset, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
throw new UnsupportedOperationException("can't mark relocaction sites in string section");
}

@Override
public RelocationRecord markRelocationSite(int offset, ByteBuffer bb, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
public void markRelocationSite(int offset, ByteBuffer bb, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) {
throw new UnsupportedOperationException("can't mark relocaction sites in string section");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
Expand All @@ -40,6 +39,7 @@
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFrameSizeChange;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugInstanceTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugMethodInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugRangeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;

Expand Down Expand Up @@ -97,10 +97,7 @@ public ClassEntry(String className, FileEntry fileEntry, int size) {
super(className, size);
this.interfaces = new ArrayList<>();
this.fileEntry = fileEntry;
// methods is a sorted list and we want to be able to add more elements to it while keeping
// it sorted,
// so a LinkedList seems more appropriate than an ArrayList. (see getMethodEntry)
this.methods = new LinkedList<>();
this.methods = new ArrayList<>();
this.primaryEntries = new ArrayList<>();
this.primaryIndex = new HashMap<>();
this.localFiles = new ArrayList<>();
Expand Down Expand Up @@ -140,7 +137,7 @@ public void addDebugInfo(DebugInfoBase debugInfoBase, DebugTypeInfo debugTypeInf
/* Add details of fields and field types */
debugInstanceTypeInfo.fieldInfoProvider().forEach(debugFieldInfo -> this.processField(debugFieldInfo, debugInfoBase, debugContext));
/* Add details of methods and method types */
debugInstanceTypeInfo.methodInfoProvider().forEach(methodFieldInfo -> this.methods.add(this.processMethod(methodFieldInfo, debugInfoBase, debugContext)));
debugInstanceTypeInfo.methodInfoProvider().forEach(methodFieldInfo -> this.methods.add(this.processMethod(methodFieldInfo, debugInfoBase, debugContext, false)));
/* Sort methods to improve lookup speed */
this.methods.sort(MethodEntry::compareTo);
}
Expand All @@ -157,8 +154,9 @@ public void indexPrimary(Range primary, List<DebugFrameSizeChange> frameSizeInfo
assert includesDeoptTarget == false;
}
FileEntry primaryFileEntry = primary.getFileEntry();
assert primaryFileEntry != null;
indexLocalFileEntry(primaryFileEntry);
if (primaryFileEntry != null) {
indexLocalFileEntry(primaryFileEntry);
}
}
}

Expand Down Expand Up @@ -275,7 +273,7 @@ private void processInterface(String interfaceName, DebugInfoBase debugInfoBase,
interfaceClassEntry.addImplementor(this, debugContext);
}

protected MethodEntry processMethod(DebugMethodInfo debugMethodInfo, DebugInfoBase debugInfoBase, DebugContext debugContext) {
protected MethodEntry processMethod(DebugMethodInfo debugMethodInfo, DebugInfoBase debugInfoBase, DebugContext debugContext, boolean fromRangeInfo) {
String methodName = debugInfoBase.uniqueDebugString(debugMethodInfo.name());
String resultTypeName = TypeEntry.canonicalize(debugMethodInfo.valueType());
int modifiers = debugMethodInfo.modifiers();
Expand All @@ -294,15 +292,13 @@ protected MethodEntry processMethod(DebugMethodInfo debugMethodInfo, DebugInfoBa
paramTypeArray[idx++] = paramType;
}
paramNameArray = paramNames.toArray(paramNameArray);
String fileName = debugMethodInfo.fileName();
Path filePath = debugMethodInfo.filePath();
Path cachePath = debugMethodInfo.cachePath();
/*
* n.b. the method file may differ from the owning class file when the method is a
* substitution
*/
FileEntry methodFileEntry = debugInfoBase.ensureFileEntry(fileName, filePath, cachePath);
return new MethodEntry(methodFileEntry, methodName, this, resultType, paramTypeArray, paramNameArray, modifiers, debugMethodInfo.isDeoptTarget());
FileEntry methodFileEntry = debugInfoBase.ensureFileEntry(debugMethodInfo);
return new MethodEntry(methodFileEntry, debugMethodInfo.symbolNameForMethod(), methodName, this, resultType,
paramTypeArray, paramNameArray, modifiers, debugMethodInfo.isDeoptTarget(), fromRangeInfo);
}

@Override
Expand Down Expand Up @@ -343,32 +339,28 @@ public ClassEntry getSuperClass() {
return superClass;
}

public Range makePrimaryRange(String symbolName, StringTable stringTable, MethodEntry method, int lo, int hi, int primaryLine) {
FileEntry fileEntryToUse = method.fileEntry;
if (fileEntryToUse == null) {
/* Last chance is the class's file entry. */
fileEntryToUse = this.fileEntry;
}
return new Range(symbolName, stringTable, method, fileEntryToUse, lo, hi, primaryLine);
}

public MethodEntry getMethodEntry(DebugMethodInfo debugMethodInfo, DebugInfoBase debugInfoBase, DebugContext debugContext) {
public MethodEntry ensureMethodEntryForDebugRangeInfo(DebugRangeInfo debugRangeInfo, DebugInfoBase debugInfoBase, DebugContext debugContext) {
assert listIsSorted(methods);
String methodName = debugInfoBase.uniqueDebugString(debugMethodInfo.name());
String paramSignature = debugMethodInfo.paramSignature();
String returnTypeName = debugMethodInfo.valueType();
ListIterator<MethodEntry> methodIterator = methods.listIterator();
String methodName = debugInfoBase.uniqueDebugString(debugRangeInfo.name());
String paramSignature = debugRangeInfo.paramSignature();
String returnTypeName = debugRangeInfo.valueType();
while (methodIterator.hasNext()) {
MethodEntry methodEntry = methodIterator.next();
int comparisonResult = methodEntry.compareTo(methodName, paramSignature, returnTypeName);
if (comparisonResult == 0) {
methodEntry.setInRangeAndUpdateFileEntry(debugInfoBase, debugRangeInfo);
if (methodEntry.fileEntry != null) {
/* Ensure that the methodEntry's fileEntry is present in the localsFileIndex */
indexLocalFileEntry(methodEntry.fileEntry);
}
return methodEntry;
} else if (comparisonResult > 0) {
methodIterator.previous();
break;
}
}
MethodEntry newMethodEntry = processMethod(debugMethodInfo, debugInfoBase, debugContext);
MethodEntry newMethodEntry = processMethod(debugRangeInfo, debugInfoBase, debugContext, true);
methodIterator.add(newMethodEntry);
return newMethodEntry;
}
Expand All @@ -378,4 +370,8 @@ private static boolean listIsSorted(List<MethodEntry> list) {
copy.sort(MethodEntry::compareTo);
return list.equals(copy);
}

public List<MethodEntry> getMethods() {
return methods;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.List;
import java.util.Map;

import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFileInfo;
import org.graalvm.compiler.debug.DebugContext;

import com.oracle.objectfile.debuginfo.DebugInfoProvider;
Expand Down Expand Up @@ -239,23 +240,21 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
Path filePath = debugCodeInfo.filePath();
String className = TypeEntry.canonicalize(debugCodeInfo.ownerType());
String methodName = debugCodeInfo.name();
String symbolName = debugCodeInfo.symbolNameForMethod();
int lo = debugCodeInfo.addressLo();
int hi = debugCodeInfo.addressHi();
int primaryLine = debugCodeInfo.line();

/* Search for a method defining this primary range. */
ClassEntry classEntry = ensureClassEntry(className);
MethodEntry methodEntry = classEntry.getMethodEntry(debugCodeInfo, this, debugContext);
Range primaryRange = classEntry.makePrimaryRange(symbolName, stringTable, methodEntry, lo, hi, primaryLine);
MethodEntry methodEntry = classEntry.ensureMethodEntryForDebugRangeInfo(debugCodeInfo, this, debugContext);
Range primaryRange = new Range(stringTable, methodEntry, lo, hi, primaryLine);
debugContext.log(DebugContext.INFO_LEVEL, "PrimaryRange %s.%s %s %s:%d [0x%x, 0x%x]", className, methodName, filePath, fileName, primaryLine, lo, hi);
classEntry.indexPrimary(primaryRange, debugCodeInfo.getFrameSizeChanges(), debugCodeInfo.getFrameSize());
debugCodeInfo.lineInfoProvider().forEach(debugLineInfo -> {
String fileNameAtLine = debugLineInfo.fileName();
Path filePathAtLine = debugLineInfo.filePath();
String classNameAtLine = TypeEntry.canonicalize(debugLineInfo.ownerType());
String methodNameAtLine = debugLineInfo.name();
String symbolNameAtLine = debugLineInfo.symbolNameForMethod();
int loAtLine = lo + debugLineInfo.addressLo();
int hiAtLine = lo + debugLineInfo.addressHi();
int line = debugLineInfo.line();
Expand All @@ -264,8 +263,8 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
* symbol for them and don't see a break in the address range.
*/
ClassEntry subClassEntry = ensureClassEntry(classNameAtLine);
MethodEntry subMethodEntry = subClassEntry.getMethodEntry(debugLineInfo, this, debugContext);
Range subRange = new Range(symbolNameAtLine, stringTable, subMethodEntry, loAtLine, hiAtLine, line, primaryRange);
MethodEntry subMethodEntry = subClassEntry.ensureMethodEntryForDebugRangeInfo(debugLineInfo, this, debugContext);
Range subRange = new Range(stringTable, subMethodEntry, loAtLine, hiAtLine, line, primaryRange);
classEntry.indexSubRange(subRange);
try (DebugContext.Scope s = debugContext.scope("Subranges")) {
debugContext.log(DebugContext.VERBOSE_LEVEL, "SubRange %s.%s %s %s:%d 0x%x, 0x%x]", classNameAtLine, methodNameAtLine, filePathAtLine, fileNameAtLine, line, loAtLine, hiAtLine);
Expand Down Expand Up @@ -390,10 +389,12 @@ private FileEntry addFileEntry(String fileName, Path filePath, Path cachePath) {
return fileEntry;
}

protected FileEntry ensureFileEntry(String fileName, Path filePath, Path cachePath) {
protected FileEntry ensureFileEntry(DebugFileInfo debugFileInfo) {
String fileName = debugFileInfo.fileName();
if (fileName == null || fileName.length() == 0) {
return null;
}
Path filePath = debugFileInfo.filePath();
Path fileAsPath;
if (filePath == null) {
fileAsPath = Paths.get(fileName);
Expand All @@ -403,7 +404,7 @@ protected FileEntry ensureFileEntry(String fileName, Path filePath, Path cachePa
/* Reuse any existing entry. */
FileEntry fileEntry = findFile(fileAsPath);
if (fileEntry == null) {
fileEntry = addFileEntry(fileName, filePath, cachePath);
fileEntry = addFileEntry(fileName, filePath, debugFileInfo.cachePath());
}
return fileEntry;
}
Expand Down
Loading