mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8364004: Expose VMError::controlledCrash via Whitebox
Reviewed-by: kbarrett, mbaesken, dholmes
This commit is contained in:
parent
965b68107f
commit
0226c0298f
@ -102,6 +102,7 @@
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/nativeCallStack.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
#include "utilities/vmError.hpp"
|
||||
#if INCLUDE_G1GC
|
||||
#include "gc/g1/g1Arguments.hpp"
|
||||
#include "gc/g1/g1CollectedHeap.inline.hpp"
|
||||
@ -2728,6 +2729,14 @@ WB_ENTRY(jlong, WB_Rss(JNIEnv* env, jobject o))
|
||||
return os::rss();
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(void, WB_ControlledCrash(JNIEnv* env, jobject o, jint how))
|
||||
#ifdef ASSERT
|
||||
VMError::controlled_crash(how);
|
||||
#else
|
||||
THROW_MSG(vmSymbols::java_lang_UnsupportedOperationException(), "Only available in debug builds");
|
||||
#endif
|
||||
WB_END
|
||||
|
||||
#define CC (char*)
|
||||
|
||||
static JNINativeMethod methods[] = {
|
||||
@ -3019,10 +3028,10 @@ static JNINativeMethod methods[] = {
|
||||
{CC"lockAndStuckInSafepoint", CC"()V", (void*)&WB_TakeLockAndHangInSafepoint},
|
||||
{CC"wordSize", CC"()J", (void*)&WB_WordSize},
|
||||
{CC"rootChunkWordSize", CC"()J", (void*)&WB_RootChunkWordSize},
|
||||
{CC"isStatic", CC"()Z", (void*)&WB_IsStaticallyLinked}
|
||||
{CC"isStatic", CC"()Z", (void*)&WB_IsStaticallyLinked},
|
||||
{CC"controlledCrash",CC"(I)V", (void*)&WB_ControlledCrash},
|
||||
};
|
||||
|
||||
|
||||
#undef CC
|
||||
|
||||
JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
|
||||
|
||||
@ -30,11 +30,15 @@
|
||||
* @requires vm.flagless
|
||||
* @requires vm.debug == true & (os.family == "linux" | os.family == "windows")
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @build jdk.test.whitebox.WhiteBox
|
||||
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
|
||||
* @run driver ShowEventsOnCrashTest
|
||||
*/
|
||||
|
||||
// Note: this test can only run on debug since it relies on VMError::controlled_crash() which
|
||||
// only exists in debug builds.
|
||||
|
||||
import jdk.test.whitebox.WhiteBox;
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -45,10 +49,17 @@ public class ShowEventsOnCrashTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
if (args.length > 0 && args[0].equals("test")) {
|
||||
Thread.sleep(2000); // Wait to accumulate log entries
|
||||
WhiteBox.getWhiteBox().controlledCrash(2);
|
||||
throw new RuntimeException("Still alive?");
|
||||
}
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
|
||||
"-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash",
|
||||
"-XX:ErrorHandlerTest=2",
|
||||
"-version");
|
||||
"-Xbootclasspath/a:.",
|
||||
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
||||
"-Xmx100M", "-XX:-CreateCoredumpOnCrash",
|
||||
ShowEventsOnCrashTest.class.getName(), "test");
|
||||
|
||||
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
|
||||
|
||||
|
||||
@ -851,4 +851,7 @@ public class WhiteBox {
|
||||
public native long rss();
|
||||
|
||||
public native boolean isStatic();
|
||||
|
||||
// Force a controlled crash (debug builds only)
|
||||
public native void controlledCrash(int how);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user