Skip to content

Commit d364591

Browse files
committed
[GR-44007] Ensure NativeImageDebugDataInfo methods are used by logging are only called if needed.
PullRequest: graal/14588
2 parents bdba00a + 1686506 commit d364591

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,22 @@
3434
import java.util.List;
3535
import java.util.Map;
3636

37-
import com.oracle.objectfile.debugentry.range.PrimaryRange;
38-
import com.oracle.objectfile.debugentry.range.Range;
39-
import com.oracle.objectfile.debugentry.range.SubRange;
40-
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFileInfo;
41-
import jdk.vm.ci.meta.ResolvedJavaType;
4237
import org.graalvm.collections.EconomicMap;
4338
import org.graalvm.compiler.debug.DebugContext;
4439

40+
import com.oracle.objectfile.debugentry.range.PrimaryRange;
41+
import com.oracle.objectfile.debugentry.range.Range;
42+
import com.oracle.objectfile.debugentry.range.SubRange;
4543
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
4644
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugCodeInfo;
47-
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocationInfo;
45+
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFileInfo;
4846
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo;
47+
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocationInfo;
4948
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind;
5049
import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo;
5150

51+
import jdk.vm.ci.meta.ResolvedJavaType;
52+
5253
/**
5354
* An abstract class which indexes the information presented by the DebugInfoProvider in an
5455
* organization suitable for use by subclasses targeting a specific binary format.
@@ -349,13 +350,15 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
349350
}));
350351

351352
debugInfoProvider.dataInfoProvider().forEach(debugDataInfo -> debugDataInfo.debugContext((debugContext) -> {
352-
String provenance = debugDataInfo.getProvenance();
353-
String typeName = debugDataInfo.getTypeName();
354-
String partitionName = debugDataInfo.getPartition();
355-
/* Address is heap-register relative pointer. */
356-
long address = debugDataInfo.getAddress();
357-
long size = debugDataInfo.getSize();
358-
debugContext.log(DebugContext.INFO_LEVEL, "Data: address 0x%x size 0x%x type %s partition %s provenance %s ", address, size, typeName, partitionName, provenance);
353+
if (debugContext.isLogEnabled(DebugContext.INFO_LEVEL)) {
354+
String provenance = debugDataInfo.getProvenance();
355+
String typeName = debugDataInfo.getTypeName();
356+
String partitionName = debugDataInfo.getPartition();
357+
/* Address is heap-register relative pointer. */
358+
long address = debugDataInfo.getAddress();
359+
long size = debugDataInfo.getSize();
360+
debugContext.log(DebugContext.INFO_LEVEL, "Data: address 0x%x size 0x%x type %s partition %s provenance %s ", address, size, typeName, partitionName, provenance);
361+
}
359362
}));
360363
}
361364

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoProvider.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,63 +2528,53 @@ public Type getType() {
25282528
}
25292529

25302530
private class NativeImageDebugDataInfo implements DebugDataInfo {
2531-
HostedClass hostedClass;
2532-
ImageHeapPartition partition;
2533-
long offset;
2534-
long address;
2535-
long size;
2536-
String typeName;
2537-
String provenance;
2531+
private final NativeImageHeap.ObjectInfo objectInfo;
25382532

25392533
@SuppressWarnings("try")
25402534
@Override
25412535
public void debugContext(Consumer<DebugContext> action) {
2542-
try (DebugContext.Scope s = debugContext.scope("DebugDataInfo", provenance)) {
2536+
try (DebugContext.Scope s = debugContext.scope("DebugDataInfo")) {
25432537
action.accept(debugContext);
25442538
} catch (Throwable e) {
25452539
throw debugContext.handle(e);
25462540
}
25472541
}
25482542

2543+
/* Accessors. */
2544+
25492545
NativeImageDebugDataInfo(ObjectInfo objectInfo) {
2550-
hostedClass = objectInfo.getClazz();
2551-
partition = objectInfo.getPartition();
2552-
offset = objectInfo.getOffset();
2553-
address = objectInfo.getAddress();
2554-
size = objectInfo.getSize();
2555-
provenance = objectInfo.toString();
2556-
typeName = hostedClass.toJavaName();
2546+
this.objectInfo = objectInfo;
25572547
}
25582548

2559-
/* Accessors. */
25602549
@Override
25612550
public String getProvenance() {
2562-
return provenance;
2551+
return objectInfo.toString();
25632552
}
25642553

25652554
@Override
25662555
public String getTypeName() {
2567-
return typeName;
2556+
return objectInfo.getClazz().toJavaName();
25682557
}
25692558

25702559
@Override
25712560
public String getPartition() {
2561+
ImageHeapPartition partition = objectInfo.getPartition();
25722562
return partition.getName() + "{" + partition.getSize() + "}@" + partition.getStartOffset();
25732563
}
25742564

25752565
@Override
25762566
public long getOffset() {
2577-
return offset;
2567+
return objectInfo.getOffset();
25782568
}
25792569

25802570
@Override
25812571
public long getAddress() {
2582-
return address;
2572+
return objectInfo.getAddress();
25832573
}
25842574

25852575
@Override
25862576
public long getSize() {
2587-
return size;
2577+
return objectInfo.getSize();
25882578
}
25892579
}
25902580

0 commit comments

Comments
 (0)