8041626: Shutdown tracing event

Reviewed-by: dholmes, alanb, rriggs
This commit is contained in:
Robin Westberg 2018-02-13 15:48:23 +01:00
parent 5287d9a366
commit f2c21c058d
10 changed files with 47 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
JVM_ActiveProcessorCount
JVM_ArrayCopy
JVM_AssertionStatusDirectives
JVM_BeforeHalt
JVM_CallStackWalk
JVM_Clone
JVM_ConstantPoolGetClassAt

View File

@ -207,6 +207,7 @@ SUNWprivate_1.1 {
Java_java_lang_Runtime_totalMemory;
Java_java_lang_Runtime_availableProcessors;
Java_java_lang_SecurityManager_getClassContext;
Java_java_lang_Shutdown_beforeHalt;
Java_java_lang_Shutdown_halt0;
Java_java_lang_StackTraceElement_initStackTraceElement;
Java_java_lang_StackTraceElement_initStackTraceElements;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -118,6 +118,9 @@ JVM_InitProperties(JNIEnv *env, jobject p);
/*
* java.lang.Runtime
*/
JNIEXPORT void JNICALL
JVM_BeforeHalt();
JNIEXPORT void JNICALL
JVM_Halt(jint code);

View File

@ -434,6 +434,16 @@ JVM_END
extern volatile jint vm_created;
JVM_ENTRY_NO_ENV(void, JVM_BeforeHalt())
JVMWrapper("JVM_BeforeHalt");
EventShutdown event;
if (event.should_commit()) {
event.set_reason("Shutdown requested from Java");
event.commit();
}
JVM_END
JVM_ENTRY_NO_ENV(void, JVM_Halt(jint code))
before_exit(thread);
vm_exit(code);

View File

@ -4216,6 +4216,12 @@ bool Threads::destroy_vm() {
Mutex::_as_suspend_equivalent_flag);
}
EventShutdown e;
if (e.should_commit()) {
e.set_reason("No remaining non-daemon Java threads");
e.commit();
}
// Hang forever on exit if we are reporting an error.
if (ShowMessageBoxOnError && VMError::is_error_reported()) {
os::infinite_sleep();

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@ -628,6 +628,11 @@ Declares a structure type that can be used in other events.
<value type="INTEGER" field="safepointId" label="Safepoint Identifier" description="The safepoint (if any) under which this operation was completed" relation="SafepointId"/>
</event>
<event id="Shutdown" path="vm/runtime/shutdown" label="VM Shutdown"
description="VM shutting down" has_thread="true" has_stacktrace="true" is_instant="true">
<value type="STRING" field="reason" label="Reason" description="Reason for VM shutdown"/>
</event>
<!-- Allocation events -->
<event id="ObjectAllocationInNewTLAB" path="java/object_alloc_in_new_TLAB" label="Allocation in new TLAB"
description="Allocation in new Thread Local Allocation Buffer" has_thread="true" has_stacktrace="true" is_instant="true">

View File

@ -1305,6 +1305,12 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
// are handled properly.
reset_signal_handlers();
EventShutdown e;
if (e.should_commit()) {
e.set_reason("VM Error");
e.commit();
}
TRACE_VM_ERROR();
} else {

View File

@ -280,6 +280,7 @@ public class Runtime {
if (sm != null) {
sm.checkExit(status);
}
Shutdown.beforeHalt();
Shutdown.halt(status);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -130,6 +130,9 @@ class Shutdown {
}
}
/* Notify the VM that it's time to halt. */
static native void beforeHalt();
/* The halt method is synchronized on the halt lock
* to avoid corruption of the delete-on-shutdown file list.
* It invokes the true native halt method.
@ -209,6 +212,7 @@ class Shutdown {
/* Synchronize on the class object, causing any other thread
* that attempts to initiate shutdown to stall indefinitely
*/
beforeHalt();
sequence();
halt(status);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,11 @@
#include "java_lang_Shutdown.h"
JNIEXPORT void JNICALL
Java_java_lang_Shutdown_beforeHalt(JNIEnv *env, jclass ignored)
{
JVM_BeforeHalt();
}
JNIEXPORT void JNICALL
Java_java_lang_Shutdown_halt0(JNIEnv *env, jclass ignored, jint code)