mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 03:24:38 +02:00
8143157: Convert TraceVMOperation to Unified Logging
The former -XX:+TraceVMOperation flag is updated to the unified logging framework and is now replaced with -Xlog:vmoperation in product mode. Reviewed-by: coleenp, dholmes, mockner
This commit is contained in:
parent
961fbacd76
commit
c67974cf0f
5 changed files with 103 additions and 9 deletions
|
@ -33,7 +33,8 @@
|
||||||
#define LOG_TAG_LIST \
|
#define LOG_TAG_LIST \
|
||||||
LOG_TAG(defaultmethods) \
|
LOG_TAG(defaultmethods) \
|
||||||
LOG_TAG(logging) \
|
LOG_TAG(logging) \
|
||||||
LOG_TAG(safepoint)
|
LOG_TAG(safepoint) \
|
||||||
|
LOG_TAG(vmoperation)
|
||||||
|
|
||||||
#define PREFIX_LOG_TAG(T) (LogTag::T)
|
#define PREFIX_LOG_TAG(T) (LogTag::T)
|
||||||
|
|
||||||
|
|
|
@ -1073,9 +1073,6 @@ public:
|
||||||
develop(bool, BreakAtWarning, false, \
|
develop(bool, BreakAtWarning, false, \
|
||||||
"Execute breakpoint upon encountering VM warning") \
|
"Execute breakpoint upon encountering VM warning") \
|
||||||
\
|
\
|
||||||
develop(bool, TraceVMOperation, false, \
|
|
||||||
"Trace VM operations") \
|
|
||||||
\
|
|
||||||
develop(bool, UseFakeTimers, false, \
|
develop(bool, UseFakeTimers, false, \
|
||||||
"Tell whether the VM should use system time or a fake timer") \
|
"Tell whether the VM should use system time or a fake timer") \
|
||||||
\
|
\
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "code/codeCacheExtensions.hpp"
|
#include "code/codeCacheExtensions.hpp"
|
||||||
#include "compiler/compileBroker.hpp"
|
#include "compiler/compileBroker.hpp"
|
||||||
#include "gc/shared/isGCActiveMark.hpp"
|
#include "gc/shared/isGCActiveMark.hpp"
|
||||||
|
#include "logging/log.hpp"
|
||||||
#include "memory/heapInspection.hpp"
|
#include "memory/heapInspection.hpp"
|
||||||
#include "memory/resourceArea.hpp"
|
#include "memory/resourceArea.hpp"
|
||||||
#include "oops/symbol.hpp"
|
#include "oops/symbol.hpp"
|
||||||
|
@ -55,13 +56,19 @@ void VM_Operation::set_calling_thread(Thread* thread, ThreadPriority priority) {
|
||||||
|
|
||||||
void VM_Operation::evaluate() {
|
void VM_Operation::evaluate() {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
if (TraceVMOperation) {
|
outputStream* debugstream;
|
||||||
tty->print("[");
|
bool enabled = log_is_enabled(Debug, vmoperation);
|
||||||
NOT_PRODUCT(print();)
|
if (enabled) {
|
||||||
|
debugstream = LogHandle(vmoperation)::debug_stream();
|
||||||
|
debugstream->print("begin ");
|
||||||
|
print_on_error(debugstream);
|
||||||
|
debugstream->cr();
|
||||||
}
|
}
|
||||||
doit();
|
doit();
|
||||||
if (TraceVMOperation) {
|
if (enabled) {
|
||||||
tty->print_cr("]");
|
debugstream->print("end ");
|
||||||
|
print_on_error(debugstream);
|
||||||
|
debugstream->cr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
46
hotspot/test/runtime/logging/VMOperationTest.java
Normal file
46
hotspot/test/runtime/logging/VMOperationTest.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8143157
|
||||||
|
* @summary vmoperation=debug should have logging output
|
||||||
|
* @library /testlibrary
|
||||||
|
* @compile VMOperationTestMain.java
|
||||||
|
* @modules java.base/sun.misc
|
||||||
|
* java.management
|
||||||
|
* @run main VMOperationTest
|
||||||
|
*/
|
||||||
|
|
||||||
|
import jdk.test.lib.*;
|
||||||
|
|
||||||
|
public class VMOperationTest {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||||
|
"-Xlog:vmoperation=debug", "-Xmx64m", "-Xms64m", "VMOperationTestMain");
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldContain("VM_Operation (");
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
43
hotspot/test/runtime/logging/VMOperationTestMain.java
Normal file
43
hotspot/test/runtime/logging/VMOperationTestMain.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
public class VMOperationTestMain {
|
||||||
|
public static byte[] garbage;
|
||||||
|
public static volatile WeakReference<Object> weakref;
|
||||||
|
|
||||||
|
public static void createweakref() {
|
||||||
|
Object o = new Object();
|
||||||
|
weakref = new WeakReference<>(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop until a GC runs.
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
createweakref();
|
||||||
|
while (weakref.get() != null) {
|
||||||
|
garbage = new byte[8192];
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue