changeset 54965:31e3aa9c0c71

8204551: Event descriptions are truncated in logs Reviewed-by: coleenp, coleenp
author ysuenaga
date Sat, 16 Feb 2019 11:40:34 +0900
parents 72709e703abd
children d230a0406623
files src/hotspot/share/utilities/events.cpp src/hotspot/share/utilities/events.hpp src/hotspot/share/utilities/exceptions.hpp
diffstat 3 files changed, 33 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/utilities/events.cpp	Fri Feb 15 11:46:15 2019 -0300
+++ b/src/hotspot/share/utilities/events.cpp	Sat Feb 16 11:40:34 2019 +0900
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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,7 +36,7 @@
 
 EventLog* Events::_logs = NULL;
 StringEventLog* Events::_messages = NULL;
-StringEventLog* Events::_exceptions = NULL;
+ExtendedStringEventLog* Events::_exceptions = NULL;
 StringEventLog* Events::_redefinitions = NULL;
 UnloadingEventLog* Events::_class_unloading = NULL;
 StringEventLog* Events::_deopt_messages = NULL;
@@ -67,7 +67,7 @@
 void Events::init() {
   if (LogEvents) {
     _messages = new StringEventLog("Events");
-    _exceptions = new StringEventLog("Internal exceptions");
+    _exceptions = new ExtendedStringEventLog("Internal exceptions");
     _redefinitions = new StringEventLog("Classes redefined");
     _class_unloading = new UnloadingEventLog("Classes unloaded");
     _deopt_messages = new StringEventLog("Deoptimization events");
--- a/src/hotspot/share/utilities/events.hpp	Fri Feb 15 11:46:15 2019 -0300
+++ b/src/hotspot/share/utilities/events.hpp	Sat Feb 16 11:40:34 2019 +0900
@@ -135,37 +135,43 @@
 };
 
 // A simple wrapper class for fixed size text messages.
-class StringLogMessage : public FormatBuffer<256> {
+template <size_t bufsz>
+class FormatStringLogMessage : public FormatBuffer<bufsz> {
  public:
   // Wrap this buffer in a stringStream.
   stringStream stream() {
-    return stringStream(_buf, size());
+    return stringStream(this->_buf, this->size());
   }
 };
+typedef FormatStringLogMessage<256> StringLogMessage;
+typedef FormatStringLogMessage<512> ExtendedStringLogMessage;
 
 // A simple ring buffer of fixed size text messages.
-class StringEventLog : public EventLogBase<StringLogMessage> {
+template <size_t bufsz>
+class FormatStringEventLog : public EventLogBase< FormatStringLogMessage<bufsz> > {
  public:
-  StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {}
+  FormatStringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase< FormatStringLogMessage<bufsz> >(name, count) {}
 
   void logv(Thread* thread, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0) {
-    if (!should_log()) return;
+    if (!this->should_log()) return;
 
-    double timestamp = fetch_timestamp();
-    MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag);
-    int index = compute_log_index();
-    _records[index].thread = thread;
-    _records[index].timestamp = timestamp;
-    _records[index].data.printv(format, ap);
+    double timestamp = this->fetch_timestamp();
+    MutexLockerEx ml(&this->_mutex, Mutex::_no_safepoint_check_flag);
+    int index = this->compute_log_index();
+    this->_records[index].thread = thread;
+    this->_records[index].timestamp = timestamp;
+    this->_records[index].data.printv(format, ap);
   }
 
   void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(3, 4) {
     va_list ap;
     va_start(ap, format);
-    logv(thread, format, ap);
+    this->logv(thread, format, ap);
     va_end(ap);
   }
 };
+typedef FormatStringEventLog<256> StringEventLog;
+typedef FormatStringEventLog<512> ExtendedStringEventLog;
 
 class InstanceKlass;
 
@@ -189,7 +195,7 @@
 
   // A log for internal exception related messages, like internal
   // throws and implicit exceptions.
-  static StringEventLog* _exceptions;
+  static ExtendedStringEventLog* _exceptions;
 
   // Deoptization related messages
   static StringEventLog* _deopt_messages;
@@ -307,6 +313,13 @@
   out->cr();
 }
 
+// Implement a printing routine for the ExtendedStringLogMessage
+template <>
+inline void EventLogBase<ExtendedStringLogMessage>::print(outputStream* out, ExtendedStringLogMessage& lm) {
+  out->print_raw(lm);
+  out->cr();
+}
+
 // Place markers for the beginning and end up of a set of events.
 // These end up in the default log.
 class EventMark : public StackObj {
--- a/src/hotspot/share/utilities/exceptions.hpp	Fri Feb 15 11:46:15 2019 -0300
+++ b/src/hotspot/share/utilities/exceptions.hpp	Sat Feb 16 11:40:34 2019 +0900
@@ -237,7 +237,11 @@
 // visible within the scope containing the THROW. Usually this is achieved by declaring the function
 // with a TRAPS argument.
 
+#ifdef THIS_FILE
+#define THREAD_AND_LOCATION                      THREAD, THIS_FILE, __LINE__
+#else
 #define THREAD_AND_LOCATION                      THREAD, __FILE__, __LINE__
+#endif
 
 #define THROW_OOP(e)                                \
   { Exceptions::_throw_oop(THREAD_AND_LOCATION, e);                             return;  }