Skip to content

Commit ed622d4

Browse files
Further minor fixes.
1 parent 45a67d3 commit ed622d4

File tree

7 files changed

+31
-30
lines changed

7 files changed

+31
-30
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ UnsignedWord possibleCollectionPrologue() {
10651065
}
10661066

10671067
/**
1068-
* Do whatever is necessary if a collection occurred since the a call to
1068+
* Do whatever is necessary if a collection occurred since the call to
10691069
* {@link #possibleCollectionPrologue()}. Note that this method may get called by several
10701070
* threads for the same collection.
10711071
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.Collections;
3535
import java.util.List;
3636

37+
import com.oracle.svm.core.log.Log;
3738
import org.graalvm.compiler.word.Word;
3839
import org.graalvm.nativeimage.ImageSingletons;
3940
import org.graalvm.nativeimage.Platform;
@@ -170,7 +171,7 @@ public static int runCore() {
170171
*/
171172
RuntimeSupport.getRuntimeSupport().shutdown();
172173

173-
Counter.logValues();
174+
Counter.logValues(Log.log());
174175
}
175176
return exitCode;
176177
}

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ public static void printInformation(Log log, Pointer sp, CodePointer ip) {
130130
}
131131

132132
/**
133-
* This method prints diagnostic information. This method prints less information than
134-
* {@link #printFatalError} as it only uses reasonably safe operations and memory accesses. So,
135-
* as long as all parts of Native Image are fully functional, calling this method will never
136-
* cause a crash.
133+
* Prints less detailed information than {@link #printFatalError} but this method guarantees
134+
* that it won't cause a crash if all parts of Native Image are fully functional.
137135
*/
138136
public static void printInformation(Log log, Pointer sp, CodePointer ip, RegisterDumper.Context registerContext, boolean frameHasCalleeSavedRegisters) {
139137
// Stack allocate an error context.
@@ -162,18 +160,17 @@ public static boolean printFatalError(Log log, Pointer sp, CodePointer ip) {
162160
}
163161

164162
/**
165-
* This method prints extensive diagnostic information and is only called for fatal errors. This
166-
* method may use operations and memory accesses that are not necessarily 100% safe. So, even if
167-
* all parts of Native Image are fully functional, this method may cause crashes.
163+
* Used to print extensive diagnostic information in case of a fatal error. This method may use
164+
* operations and memory accesses that are not necessarily 100% safe. So, even if all parts of
165+
* Native Image are fully functional, this method may cause crashes.
168166
* <p>
169-
* If a segfault handler is present, then this method will be called recursively multiple times
167+
* If a segfault handler is present, then this method may be called recursively multiple times
170168
* if further errors happen while printing diagnostics. On each recursive invocation, the level
171-
* of detail of the diagnostic output will be reduced gradually. This recursion will terminate
172-
* once the maximum amount of information is printed.
169+
* of detail of the diagnostic output will be reduced gradually.
173170
* <p>
174171
* In scenarios without a segfault handler, it can happen that this method reliably causes a
175172
* subsequent error that crashes Native Image. In such a case, try to reduce the level of detail
176-
* of the diagnostic output (see {@link SubstrateOptions#DiagnosticDetails} to get a reasonably
173+
* of the diagnostic output (see {@link SubstrateOptions#DiagnosticDetails}) to get a reasonably
177174
* complete diagnostic output.
178175
*/
179176
public static boolean printFatalError(Log log, Pointer sp, CodePointer ip, RegisterDumper.Context registerContext, boolean frameHasCalleeSavedRegisters) {
@@ -346,6 +343,7 @@ private static int parseInvocationCount(String entry, int pos) {
346343
try {
347344
initialInvocationCount = Integer.parseInt(entry.substring(pos + 1));
348345
} catch (NumberFormatException e) {
346+
// handled below
349347
}
350348

351349
if (initialInvocationCount < 1) {
@@ -514,25 +512,29 @@ public int maxInvocationCount() {
514512
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while printing diagnostics.")
515513
public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLevel, int invocationCount) {
516514
Pointer sp = context.getStackPointer();
515+
UnsignedWord stackBase = VMThreads.StackBase.get();
517516
log.string("Top of stack (sp=").zhex(sp).string("):").indent(true);
518517

519-
UnsignedWord stackBase = VMThreads.StackBase.get();
518+
int bytesToPrint = computeBytesToPrint(sp, stackBase);
519+
log.hexdump(sp, 8, bytesToPrint / 8);
520+
log.indent(false).newline();
521+
}
522+
523+
private static int computeBytesToPrint(Pointer sp, UnsignedWord stackBase) {
520524
if (stackBase.equal(0)) {
521525
/*
522526
* We have to be careful here and not dump too much of the stack: if there are not
523527
* many frames on the stack, we segfault when going past the beginning of the stack.
524528
*/
525-
log.hexdump(sp, 8, 16);
526-
} else {
527-
int bytesToPrint = 512;
528-
UnsignedWord availableBytes = stackBase.subtract(sp);
529-
if (availableBytes.belowThan(bytesToPrint)) {
530-
bytesToPrint = NumUtil.safeToInt(availableBytes.rawValue());
531-
}
529+
return 128;
530+
}
532531

533-
log.hexdump(sp, 8, bytesToPrint / 8);
532+
int bytesToPrint = 512;
533+
UnsignedWord availableBytes = stackBase.subtract(sp);
534+
if (availableBytes.belowThan(bytesToPrint)) {
535+
bytesToPrint = NumUtil.safeToInt(availableBytes.rawValue());
534536
}
535-
log.indent(false).newline();
537+
return bytesToPrint;
536538
}
537539
}
538540

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ private static int getHostPageSize() {
606606
}
607607
}
608608

609-
@Option(help = "Allows to specify how many details should be printed for certain diagnostic thunk, e.g.: 'DumpThreads:1,DumpRegisters:2'. " +
610-
"A value of 1 will result in the maximum amount of information, higher values will result in less information. " +
609+
@Option(help = "Specifies how many details are printed for certain diagnostic thunks, e.g.: 'DumpThreads:1,DumpRegisters:2'. " +
610+
"A value of 1 will result in the maximum amount of information, higher values will print less information. " +
611611
"By default, the most detailed output is enabled for all diagnostic thunks. Wildcards (*) are supported in the name of the diagnostic thunk.", type = Expert)//
612612
public static final RuntimeOptionKey<String> DiagnosticDetails = new RuntimeOptionKey<String>("") {
613613
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public interface Thunk {
252252
void invoke();
253253
}
254254

255-
/** Prints extensive diagnostic information to the given Log. */
255+
/** Prints extensive diagnostic information for a fatal error to the given log. */
256256
public static boolean printDiagnostics(Log log, Pointer sp, CodePointer ip) {
257257
return SubstrateDiagnostics.printFatalError(log, sp, ip, WordFactory.nullPointer(), false);
258258
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public static boolean printLocationInfo(Log log, UnsignedWord value, boolean all
582582

583583
if (allowUnsafeOperations || VMOperation.isInProgressAtSafepoint()) {
584584
// If we are not at a safepoint, then it is unsafe to access thread locals of
585-
// another thread is unsafe as the IsolateThread could be freed at any time.
585+
// another thread as the IsolateThread could be freed at any time.
586586
UnsignedWord stackBase = StackBase.get(thread);
587587
UnsignedWord stackEnd = StackEnd.get(thread);
588588
if (value.belowThan(stackBase) && value.aboveOrEqual(stackEnd)) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstrateDiagnosticFeature.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626

2727
import java.lang.reflect.Field;
2828

29-
import com.oracle.svm.core.SubstrateDiagnostics;
30-
import com.oracle.svm.core.SubstrateDiagnostics.FatalErrorState;
31-
import com.sun.tools.javac.util.FatalError;
3229
import org.graalvm.nativeimage.ImageSingletons;
3330
import org.graalvm.nativeimage.hosted.Feature;
3431

3532
import com.oracle.graal.pointsto.meta.AnalysisField;
3633
import com.oracle.svm.core.SubstrateDiagnostics.DiagnosticThunkRegister;
34+
import com.oracle.svm.core.SubstrateDiagnostics.FatalErrorState;
3735
import com.oracle.svm.core.SubstrateOptions;
3836
import com.oracle.svm.core.annotate.AutomaticFeature;
3937
import com.oracle.svm.core.util.VMError;

0 commit comments

Comments
 (0)