Skip to content

Commit

Permalink
Record activity when generating debuginfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Aug 31, 2023
1 parent dfa3469 commit f755789
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
Path filePath = debugTypeInfo.filePath();
addTypeEntry(idType, typeName, fileName, filePath, byteSize, typeKind);
}));
debugInfoProvider.recordActivity();

/* Now we can cross reference static and instance field details. */
debugInfoProvider.typeInfoProvider().forEach(debugTypeInfo -> debugTypeInfo.debugContext((debugContext) -> {
Expand All @@ -310,6 +311,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
TypeEntry typeEntry = (idType != null ? lookupTypeEntry(idType) : lookupHeaderType());
typeEntry.addDebugInfo(this, debugTypeInfo, debugContext);
}));
debugInfoProvider.recordActivity();

debugInfoProvider.codeInfoProvider().forEach(debugCodeInfo -> debugCodeInfo.debugContext((debugContext) -> {
/*
Expand All @@ -336,6 +338,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
EconomicMap<DebugLocationInfo, SubRange> subRangeIndex = EconomicMap.create();
debugCodeInfo.locationInfoProvider().forEach(debugLocationInfo -> addSubrange(debugLocationInfo, primaryRange, classEntry, subRangeIndex, debugContext));
}));
debugInfoProvider.recordActivity();

debugInfoProvider.dataInfoProvider().forEach(debugDataInfo -> debugDataInfo.debugContext((debugContext) -> {
if (debugContext.isLogEnabled(DebugContext.INFO_LEVEL)) {
Expand All @@ -348,10 +351,13 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
debugContext.log(DebugContext.INFO_LEVEL, "Data: address 0x%x size 0x%x type %s partition %s provenance %s ", address, size, typeName, partitionName, provenance);
}
}));
debugInfoProvider.recordActivity();

// populate a file and dir list and associated index for each class entry
getInstanceClasses().forEach(classEntry -> {
collectFilesAndDirs(classEntry);
});
debugInfoProvider.recordActivity();
}

private TypeEntry createTypeEntry(String typeName, String fileName, Path filePath, int size, DebugTypeKind typeKind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,6 @@ enum Type {
Stream<DebugDataInfo> dataInfoProvider();

Path getCachePath();

void recordActivity();
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public void beforeImageWrite(BeforeImageWriteAccess access) {
var accessImpl = (FeatureImpl.BeforeImageWriteAccessImpl) access;
var image = accessImpl.getImage();
var debugContext = new DebugContext.Builder(HostedOptionValues.singleton(), new GraalDebugHandlersFactory(GraalAccess.getOriginalSnippetReflection())).build();
DebugInfoProvider provider = new NativeImageDebugInfoProvider(debugContext, image.getCodeCache(), image.getHeap(), image.getNativeLibs(), accessImpl.getHostedMetaAccess());
DebugInfoProvider provider = new NativeImageDebugInfoProvider(debugContext, image.getCodeCache(), image.getHeap(), image.getNativeLibs(), accessImpl.getHostedMetaAccess(),
accessImpl.getImageClassLoader().watchdog::recordActivity);
var objectFile = image.getObjectFile();
objectFile.installDebugInfo(provider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@
class NativeImageDebugInfoProvider extends NativeImageDebugInfoProviderBase implements DebugInfoProvider {
private final DebugContext debugContext;
private final Set<HostedMethod> allOverrides;
private final Runnable heartbeatCallback;

NativeImageDebugInfoProvider(DebugContext debugContext, NativeImageCodeCache codeCache, NativeImageHeap heap, NativeLibraries nativeLibs, HostedMetaAccess metaAccess) {
NativeImageDebugInfoProvider(DebugContext debugContext, NativeImageCodeCache codeCache, NativeImageHeap heap, NativeLibraries nativeLibs, HostedMetaAccess metaAccess, Runnable heartbeatCallback) {
super(codeCache, heap, nativeLibs, metaAccess);
this.debugContext = debugContext;
/* Calculate the set of all HostedMethods that are overrides. */
Expand All @@ -129,6 +130,7 @@ class NativeImageDebugInfoProvider extends NativeImageDebugInfoProviderBase impl
.flatMap(m -> Arrays.stream(m.getImplementations())
.filter(Predicate.not(m::equals)))
.collect(Collectors.toSet());
this.heartbeatCallback = heartbeatCallback;
}

@Override
Expand Down Expand Up @@ -2704,4 +2706,9 @@ private boolean acceptObjectInfo(ObjectInfo objectInfo) {
private DebugDataInfo createDebugDataInfo(ObjectInfo objectInfo) {
return new NativeImageDebugDataInfo(objectInfo);
}

@Override
public void recordActivity() {
heartbeatCallback.run();
}
}

0 comments on commit f755789

Please sign in to comment.