From fc2bb1ecc82f22d8317bc9c81d5ae4b8b1f816a6 Mon Sep 17 00:00:00 2001 From: poonam Date: Wed, 15 Feb 2017 17:39:29 +0000 Subject: [PATCH] 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file Summary: Use the Events::log function to save redefined classes for output to the hs_err file Reviewed-by: dholmes --- src/share/vm/prims/jvmtiRedefineClasses.cpp | 21 ++++++++++++++++++++- src/share/vm/prims/jvmtiRedefineClasses.hpp | 5 ++++- src/share/vm/runtime/vm_operations.hpp | 4 ++-- src/share/vm/utilities/events.cpp | 4 +++- src/share/vm/utilities/events.hpp | 16 +++++++++++++++- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/share/vm/prims/jvmtiRedefineClasses.cpp b/src/share/vm/prims/jvmtiRedefineClasses.cpp index 7903b1d96..f610db2b8 100644 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -42,6 +42,7 @@ #include "runtime/deoptimization.hpp" #include "runtime/relocator.hpp" #include "utilities/bitMap.inline.hpp" +#include "utilities/events.hpp" PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -172,6 +173,9 @@ void VM_RedefineClasses::doit_epilogue() { // Free os::malloc allocated memory. os::free(_scratch_classes); + // Reset the_class_oop to null for error printing. + _the_class_oop = NULL; + if (RC_TRACE_ENABLED(0x00000004)) { // Used to have separate timers for "doit" and "all", but the timer // overhead skewed the measurements. @@ -4096,6 +4100,13 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, java_lang_Class::classRedefinedCount(the_class_mirror), os::available_memory() >> 10)); + { + ResourceMark rm(THREAD); + Events::log_redefinition(THREAD, "redefined class name=%s, count=%d", + the_class->external_name(), + java_lang_Class::classRedefinedCount(the_class_mirror)); + + } RC_TIMER_STOP(_timer_rsc_phase2); } // end redefine_single_class() @@ -4240,3 +4251,11 @@ void VM_RedefineClasses::dump_methods() { tty->cr(); } } + +void VM_RedefineClasses::print_on_error(outputStream* st) const { + VM_Operation::print_on_error(st); + if (_the_class_oop != NULL) { + ResourceMark rm; + st->print_cr(", redefining class %s", _the_class_oop->external_name()); + } +} diff --git a/src/share/vm/prims/jvmtiRedefineClasses.hpp b/src/share/vm/prims/jvmtiRedefineClasses.hpp index a7d113610..d2611f2f0 100644 --- a/src/share/vm/prims/jvmtiRedefineClasses.hpp +++ b/src/share/vm/prims/jvmtiRedefineClasses.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -538,5 +538,8 @@ class VM_RedefineClasses: public VM_Operation { static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) { return cache == NULL ? NULL : cache->data; } + + // Error printing + void print_on_error(outputStream* st) const; }; #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP diff --git a/src/share/vm/runtime/vm_operations.hpp b/src/share/vm/runtime/vm_operations.hpp index 71118bef0..fb99be95c 100644 --- a/src/share/vm/runtime/vm_operations.hpp +++ b/src/share/vm/runtime/vm_operations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -183,7 +183,7 @@ class VM_Operation: public CHeapObj { static const char* mode_to_string(Mode mode); // Debugging - void print_on_error(outputStream* st) const; + virtual void print_on_error(outputStream* st) const; const char* name() const { return _names[type()]; } static const char* name(int type) { assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type"); diff --git a/src/share/vm/utilities/events.cpp b/src/share/vm/utilities/events.cpp index 4d17c9bba..45a11ef5c 100644 --- a/src/share/vm/utilities/events.cpp +++ b/src/share/vm/utilities/events.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -36,6 +36,7 @@ EventLog* Events::_logs = NULL; StringEventLog* Events::_messages = NULL; StringEventLog* Events::_exceptions = NULL; +StringEventLog* Events::_redefinitions = NULL; StringEventLog* Events::_deopt_messages = NULL; EventLog::EventLog() { @@ -65,6 +66,7 @@ void Events::init() { if (LogEvents) { _messages = new StringEventLog("Events"); _exceptions = new StringEventLog("Internal exceptions"); + _redefinitions = new StringEventLog("Classes redefined"); _deopt_messages = new StringEventLog("Deoptimization events"); } } diff --git a/src/share/vm/utilities/events.hpp b/src/share/vm/utilities/events.hpp index 71a4a4366..855b8bc50 100644 --- a/src/share/vm/utilities/events.hpp +++ b/src/share/vm/utilities/events.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -186,6 +186,9 @@ class Events : AllStatic { // Deoptization related messages static StringEventLog* _deopt_messages; + // Redefinition related messages + static StringEventLog* _redefinitions; + public: static void print_all(outputStream* out); @@ -198,6 +201,8 @@ class Events : AllStatic { // Log exception related message static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); // Register default loggers @@ -222,6 +227,15 @@ inline void Events::log_exception(Thread* thread, const char* format, ...) { } } +inline void Events::log_redefinition(Thread* thread, const char* format, ...) { + if (LogEvents) { + va_list ap; + va_start(ap, format); + _redefinitions->logv(thread, format, ap); + va_end(ap); + } +} + inline void Events::log_deopt_message(Thread* thread, const char* format, ...) { if (LogEvents) { va_list ap; -- GitLab