8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file

Wed, 15 Feb 2017 17:39:29 +0000

author
poonam
date
Wed, 15 Feb 2017 17:39:29 +0000
changeset 8720
6bed084fd02f
parent 8719
f89cf87d867d
child 8721
575f637864df

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 file | annotate | diff | comparison | revisions
src/share/vm/prims/jvmtiRedefineClasses.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/vm_operations.hpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/events.cpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/events.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp	Tue Feb 14 20:51:31 2017 -0500
     1.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp	Wed Feb 15 17:39:29 2017 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -42,6 +42,7 @@
    1.11  #include "runtime/deoptimization.hpp"
    1.12  #include "runtime/relocator.hpp"
    1.13  #include "utilities/bitMap.inline.hpp"
    1.14 +#include "utilities/events.hpp"
    1.15  
    1.16  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    1.17  
    1.18 @@ -172,6 +173,9 @@
    1.19    // Free os::malloc allocated memory.
    1.20    os::free(_scratch_classes);
    1.21  
    1.22 +  // Reset the_class_oop to null for error printing.
    1.23 +  _the_class_oop = NULL;
    1.24 +
    1.25    if (RC_TRACE_ENABLED(0x00000004)) {
    1.26      // Used to have separate timers for "doit" and "all", but the timer
    1.27      // overhead skewed the measurements.
    1.28 @@ -4096,6 +4100,13 @@
    1.29      java_lang_Class::classRedefinedCount(the_class_mirror),
    1.30      os::available_memory() >> 10));
    1.31  
    1.32 +  {
    1.33 +    ResourceMark rm(THREAD);
    1.34 +    Events::log_redefinition(THREAD, "redefined class name=%s, count=%d",
    1.35 +                             the_class->external_name(),
    1.36 +                             java_lang_Class::classRedefinedCount(the_class_mirror));
    1.37 +
    1.38 +  }
    1.39    RC_TIMER_STOP(_timer_rsc_phase2);
    1.40  } // end redefine_single_class()
    1.41  
    1.42 @@ -4240,3 +4251,11 @@
    1.43      tty->cr();
    1.44    }
    1.45  }
    1.46 +
    1.47 +void VM_RedefineClasses::print_on_error(outputStream* st) const {
    1.48 +  VM_Operation::print_on_error(st);
    1.49 +  if (_the_class_oop != NULL) {
    1.50 +    ResourceMark rm;
    1.51 +    st->print_cr(", redefining class %s", _the_class_oop->external_name());
    1.52 +  }
    1.53 +}
     2.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.hpp	Tue Feb 14 20:51:31 2017 -0500
     2.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.hpp	Wed Feb 15 17:39:29 2017 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -538,5 +538,8 @@
    2.11    static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) {
    2.12      return cache == NULL ? NULL : cache->data;
    2.13    }
    2.14 +
    2.15 +  // Error printing
    2.16 +  void print_on_error(outputStream* st) const;
    2.17  };
    2.18  #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP
     3.1 --- a/src/share/vm/runtime/vm_operations.hpp	Tue Feb 14 20:51:31 2017 -0500
     3.2 +++ b/src/share/vm/runtime/vm_operations.hpp	Wed Feb 15 17:39:29 2017 +0000
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -183,7 +183,7 @@
    3.11    static const char* mode_to_string(Mode mode);
    3.12  
    3.13    // Debugging
    3.14 -  void print_on_error(outputStream* st) const;
    3.15 +  virtual void print_on_error(outputStream* st) const;
    3.16    const char* name() const { return _names[type()]; }
    3.17    static const char* name(int type) {
    3.18      assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type");
     4.1 --- a/src/share/vm/utilities/events.cpp	Tue Feb 14 20:51:31 2017 -0500
     4.2 +++ b/src/share/vm/utilities/events.cpp	Wed Feb 15 17:39:29 2017 +0000
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -36,6 +36,7 @@
    4.11  EventLog* Events::_logs = NULL;
    4.12  StringEventLog* Events::_messages = NULL;
    4.13  StringEventLog* Events::_exceptions = NULL;
    4.14 +StringEventLog* Events::_redefinitions = NULL;
    4.15  StringEventLog* Events::_deopt_messages = NULL;
    4.16  
    4.17  EventLog::EventLog() {
    4.18 @@ -65,6 +66,7 @@
    4.19    if (LogEvents) {
    4.20      _messages = new StringEventLog("Events");
    4.21      _exceptions = new StringEventLog("Internal exceptions");
    4.22 +    _redefinitions = new StringEventLog("Classes redefined");
    4.23      _deopt_messages = new StringEventLog("Deoptimization events");
    4.24    }
    4.25  }
     5.1 --- a/src/share/vm/utilities/events.hpp	Tue Feb 14 20:51:31 2017 -0500
     5.2 +++ b/src/share/vm/utilities/events.hpp	Wed Feb 15 17:39:29 2017 +0000
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -186,6 +186,9 @@
    5.11    // Deoptization related messages
    5.12    static StringEventLog* _deopt_messages;
    5.13  
    5.14 +  // Redefinition related messages
    5.15 +  static StringEventLog* _redefinitions;
    5.16 +
    5.17   public:
    5.18    static void print_all(outputStream* out);
    5.19  
    5.20 @@ -198,6 +201,8 @@
    5.21    // Log exception related message
    5.22    static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
    5.23  
    5.24 +  static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
    5.25 +
    5.26    static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
    5.27  
    5.28    // Register default loggers
    5.29 @@ -222,6 +227,15 @@
    5.30    }
    5.31  }
    5.32  
    5.33 +inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
    5.34 +  if (LogEvents) {
    5.35 +    va_list ap;
    5.36 +    va_start(ap, format);
    5.37 +    _redefinitions->logv(thread, format, ap);
    5.38 +    va_end(ap);
    5.39 +  }
    5.40 +}
    5.41 +
    5.42  inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
    5.43    if (LogEvents) {
    5.44      va_list ap;

mercurial