Skip to content

Commit a0c943c

Browse files
Further cleanups.
Changed how stack traces are printed for the failing thread.
1 parent 6aa2443 commit a0c943c

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.List;
3030

3131
import org.graalvm.compiler.api.replacements.Fold;
32-
import org.graalvm.compiler.core.common.CompressEncoding;
3332
import org.graalvm.compiler.core.common.SuppressFBWarnings;
3433
import org.graalvm.compiler.nodes.gc.BarrierSet;
3534
import org.graalvm.compiler.word.Word;
@@ -591,7 +590,7 @@ public Reference<?> getAndClearReferencePendingList() {
591590

592591
@Override
593592
public boolean printLocationInfo(Log log, UnsignedWord value, boolean allowJavaHeapAccess) {
594-
if (ImageSingletons.lookup(CompressEncoding.class).hasBase() && value.equal(KnownIntrinsics.heapBase())) {
593+
if (SubstrateOptions.SpawnIsolates.getValue() && value.equal(KnownIntrinsics.heapBase())) {
595594
log.string("is the heap base");
596595
return true;
597596
}
@@ -742,7 +741,7 @@ public void printDiagnostics(Log log, int invocationCount) {
742741

743742
log.string("Heap settings and statistics:").indent(true);
744743
log.string("Supports isolates: ").bool(SubstrateOptions.SpawnIsolates.getValue()).newline();
745-
if (SubstrateOptions.SpawnIsolates.getValue() && ImageSingletons.lookup(CompressEncoding.class).hasBase()) {
744+
if (SubstrateOptions.SpawnIsolates.getValue()) {
746745
log.string("Heap base: ").zhex(KnownIntrinsics.heapBase()).newline();
747746
}
748747
log.string("Object reference size: ").signed(ConfigurationValues.getObjectLayout().getReferenceSize()).newline();

substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/ErrHandlingAPI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.graalvm.nativeimage.c.struct.CStruct;
3636
import org.graalvm.nativeimage.c.type.CLongPointer;
3737
import org.graalvm.nativeimage.c.type.VoidPointer;
38-
import org.graalvm.nativeimage.c.type.WordPointer;
3938
import org.graalvm.word.PointerBase;
4039

4140
import com.oracle.svm.core.RegisterDumper;

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ private static long getTotalFrameSize0(CodePointer ip, CodeInfo codeInfo) {
224224
return CodeInfoAccess.lookupTotalFrameSize(codeInfo, CodeInfoAccess.relativeIP(codeInfo, ip));
225225
}
226226

227-
private static boolean printFrameAnchors(Log log, IsolateThread thread) {
228-
log.string("Java frame anchors:").indent(true);
227+
private static void logFrameAnchors(Log log, IsolateThread thread) {
229228
JavaFrameAnchor anchor = JavaFrameAnchors.getFrameAnchor(thread);
230229
if (anchor.isNull()) {
231230
log.string("No anchors").newline();
@@ -234,8 +233,6 @@ private static boolean printFrameAnchors(Log log, IsolateThread thread) {
234233
log.string("Anchor ").zhex(anchor.rawValue()).string(" LastJavaSP ").zhex(anchor.getLastJavaSP().rawValue()).string(" LastJavaIP ").zhex(anchor.getLastJavaIP().rawValue()).newline();
235234
anchor = anchor.getPreviousAnchor();
236235
}
237-
log.indent(false);
238-
return true;
239236
}
240237

241238
private static class PrintDiagnosticsState {
@@ -369,7 +366,7 @@ public int maxInvocations() {
369366
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while printing diagnostics.")
370367
public void printDiagnostics(Log log, int invocationCount) {
371368
if (DeoptimizationSupport.enabled()) {
372-
log.string("DeoptStubPointer address: ").zhex(DeoptimizationSupport.getDeoptStubPointer().rawValue()).newline().newline();
369+
log.string("DeoptStubPointer address: ").zhex(DeoptimizationSupport.getDeoptStubPointer()).newline().newline();
373370
}
374371
}
375372
}
@@ -388,13 +385,13 @@ public void printDiagnostics(Log log, int invocationCount) {
388385
Pointer sp = state.sp;
389386
CodePointer ip = state.ip;
390387

391-
log.string("TopFrame info:").indent(true);
388+
log.string("Top frame info:").indent(true);
392389
if (sp.isNonNull() && ip.isNonNull()) {
393390
long totalFrameSize = getTotalFrameSize(sp, ip);
394391
DeoptimizedFrame deoptFrame = Deoptimizer.checkDeoptimized(sp);
395392
if (deoptFrame != null) {
396-
log.string("RSP ").zhex(sp.rawValue()).string(" frame was deoptimized:").newline();
397-
log.string("SourcePC ").zhex(deoptFrame.getSourcePC().rawValue()).newline();
393+
log.string("RSP ").zhex(sp).string(" frame was deoptimized:").newline();
394+
log.string("SourcePC ").zhex(deoptFrame.getSourcePC()).newline();
398395
log.string("SourceTotalFrameSize ").signed(totalFrameSize).newline();
399396
} else if (totalFrameSize != -1) {
400397
log.string("TotalFrameSize in CodeInfoTable ").signed(totalFrameSize).newline();
@@ -408,11 +405,11 @@ public void printDiagnostics(Log log, int invocationCount) {
408405
}
409406

410407
if (anchor.isNonNull()) {
411-
log.string("Found matching Anchor:").zhex(anchor.rawValue()).newline();
408+
log.string("Found matching Anchor:").zhex(anchor).newline();
412409
Pointer lastSp = anchor.getLastJavaSP();
413-
log.string("LastJavaSP ").zhex(lastSp.rawValue()).newline();
410+
log.string("LastJavaSP ").zhex(lastSp).newline();
414411
CodePointer lastIp = anchor.getLastJavaIP();
415-
log.string("LastJavaIP ").zhex(lastIp.rawValue()).newline();
412+
log.string("LastJavaIP ").zhex(lastIp).newline();
416413
}
417414
}
418415
}
@@ -436,7 +433,7 @@ private static void dumpThreads(Log log, boolean accessThreadObject) {
436433
log.string("Threads:").indent(true);
437434
// Only used for diagnostics - iterate all threads without locking the thread mutex.
438435
for (IsolateThread thread = VMThreads.firstThreadUnsafe(); thread.isNonNull(); thread = VMThreads.nextThread(thread)) {
439-
log.zhex(thread.rawValue()).spaces(1).string(VMThreads.StatusSupport.getStatusString(thread));
436+
log.zhex(thread).spaces(1).string(VMThreads.StatusSupport.getStatusString(thread));
440437
if (accessThreadObject) {
441438
Thread threadObj = JavaThreads.fromVMThread(thread);
442439
log.string(" \"").string(threadObj.getName()).string("\" - ").object(threadObj);
@@ -467,11 +464,11 @@ private static void printThreadLocals(Log log, int invocationCount) {
467464
IsolateThread currentThread = CurrentIsolate.getCurrentThread();
468465
if (isThreadOnlyAttachedForCrashHandler(currentThread)) {
469466
if (invocationCount == 1) {
470-
log.string("The failing thread ").zhex(currentThread.rawValue()).string(" does not have a full set of VM thread locals as it is an unattached thread.").newline();
467+
log.string("The failing thread ").zhex(currentThread).string(" does not have a full set of VM thread locals as it is an unattached thread.").newline();
471468
log.newline();
472469
}
473470
} else {
474-
log.string("VM thread locals for the failing thread ").zhex(currentThread.rawValue()).string(":").indent(true);
471+
log.string("VM thread locals for the failing thread ").zhex(currentThread).string(":").indent(true);
475472
VMThreadLocalInfos.dumpToLog(log, currentThread, invocationCount == 1);
476473
log.indent(false);
477474
}
@@ -574,7 +571,10 @@ public int maxInvocations() {
574571
@Override
575572
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while printing diagnostics.")
576573
public void printDiagnostics(Log log, int invocationCount) {
577-
printFrameAnchors(log, CurrentIsolate.getCurrentThread());
574+
IsolateThread currentThread = CurrentIsolate.getCurrentThread();
575+
log.string("Java frame anchors for the failing thread ").zhex(currentThread).string(":").indent(true);
576+
logFrameAnchors(log, currentThread);
577+
log.indent(false);
578578
}
579579
}
580580

@@ -592,7 +592,7 @@ public int maxInvocations() {
592592
public void printDiagnostics(Log log, int invocationCount) {
593593
Pointer sp = state.sp;
594594
CodePointer ip = state.ip;
595-
log.string("Stacktrace:").indent(true);
595+
log.string("Stacktrace for the failing thread ").zhex(CurrentIsolate.getCurrentThread()).string(":").indent(true);
596596
ThreadStackPrinter.printStacktrace(sp, ip, PRINT_VISITORS[invocationCount - 1], log);
597597
log.indent(false);
598598
}
@@ -615,9 +615,9 @@ public void printDiagnostics(Log log, int invocationCount) {
615615
continue;
616616
}
617617
try {
618-
log.string("Thread ").zhex(vmThread.rawValue()).string(":").indent(true);
618+
log.string("Thread ").zhex(vmThread).string(":").indent(true);
619619
printFrameAnchors(log, vmThread);
620-
printStacktrace(log, vmThread);
620+
printStackTrace(log, vmThread);
621621
log.indent(false);
622622
} catch (Exception e) {
623623
dumpException(log, this, e);
@@ -626,8 +626,14 @@ public void printDiagnostics(Log log, int invocationCount) {
626626
}
627627
}
628628

629-
private static void printStacktrace(Log log, IsolateThread vmThread) {
630-
log.string("Full stacktrace:").indent(true);
629+
private static void printFrameAnchors(Log log, IsolateThread vmThread) {
630+
log.string("Frame anchors:").indent(true);
631+
logFrameAnchors(log, vmThread);
632+
log.indent(false);
633+
}
634+
635+
private static void printStackTrace(Log log, IsolateThread vmThread) {
636+
log.string("Stacktrace:").indent(true);
631637
JavaStackWalker.walkThread(vmThread, StackFramePrintVisitor.SINGLETON, log);
632638
log.redent(false);
633639
}

0 commit comments

Comments
 (0)