8165226: Bad -Xloggc: arguments crashes the VM
authormlarsson
Wed, 07 Sep 2016 14:36:44 +0200
changeset 40924 226073476e18
parent 40922 d9f1eaf18f9a
child 40925 04b19236aa98
8165226: Bad -Xloggc: arguments crashes the VM Reviewed-by: dsamersoff, sjohanss
hotspot/src/share/vm/logging/logConfiguration.cpp
hotspot/src/share/vm/prims/jvmtiEnv.cpp
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/services/classLoadingService.cpp
--- a/hotspot/src/share/vm/logging/logConfiguration.cpp	Wed Sep 07 09:20:10 2016 +0200
+++ b/hotspot/src/share/vm/logging/logConfiguration.cpp	Wed Sep 07 14:36:44 2016 +0200
@@ -385,6 +385,7 @@
                                            const char* decoratorstr,
                                            const char* output_options,
                                            outputStream* errstream) {
+  assert(errstream != NULL, "errstream can not be NULL");
   if (outputstr == NULL || strlen(outputstr) == 0) {
     outputstr = "stdout";
   }
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Wed Sep 07 09:20:10 2016 +0200
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Wed Sep 07 14:36:44 2016 +0200
@@ -649,18 +649,14 @@
 
 jvmtiError
 JvmtiEnv::SetVerboseFlag(jvmtiVerboseFlag flag, jboolean value) {
+  LogLevelType level = value == 0 ? LogLevel::Off : LogLevel::Info;
   switch (flag) {
   case JVMTI_VERBOSE_OTHER:
     // ignore
     break;
   case JVMTI_VERBOSE_CLASS:
-    if (value == 0) {
-      LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL);
-      LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL);
-    } else {
-      LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL);
-      LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL);
-    }
+    LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, unload));
+    LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, load));
     break;
   case JVMTI_VERBOSE_GC:
     if (value == 0) {
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed Sep 07 09:20:10 2016 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Sep 07 14:36:44 2016 +0200
@@ -33,8 +33,9 @@
 #include "gc/shared/referenceProcessor.hpp"
 #include "gc/shared/taskqueue.hpp"
 #include "logging/log.hpp"
+#include "logging/logConfiguration.hpp"
+#include "logging/logStream.hpp"
 #include "logging/logTag.hpp"
-#include "logging/logConfiguration.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/universe.inline.hpp"
 #include "oops/oop.inline.hpp"
@@ -4176,7 +4177,10 @@
   if (_gc_log_filename != NULL) {
     // -Xloggc was used to specify a filename
     const char* gc_conf = PrintGCDetails ? "gc*" : "gc";
-    return  LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, NULL);
+
+    LogTarget(Error, logging) target;
+    LogStreamCHeap errstream(target);
+    return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, &errstream);
   } else if (PrintGC || PrintGCDetails) {
     LogConfiguration::configure_stdout(LogLevel::Info, !PrintGCDetails, LOG_TAGS(gc));
   }
--- a/hotspot/src/share/vm/services/classLoadingService.cpp	Wed Sep 07 09:20:10 2016 +0200
+++ b/hotspot/src/share/vm/services/classLoadingService.cpp	Wed Sep 07 14:36:44 2016 +0200
@@ -183,11 +183,8 @@
 bool ClassLoadingService::set_verbose(bool verbose) {
   MutexLocker m(Management_lock);
   // verbose will be set to the previous value
-  if (verbose) {
-    LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL);
-  } else {
-    LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL);
-  }
+  LogLevelType level = verbose ? LogLevel::Info : LogLevel::Off;
+  LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, load));
   reset_trace_class_unloading();
   return verbose;
 }
@@ -196,11 +193,8 @@
 void ClassLoadingService::reset_trace_class_unloading() {
   assert(Management_lock->owned_by_self(), "Must own the Management_lock");
   bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose();
-  if (value) {
-    LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL);
-  } else {
-    LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL);
-  }
+  LogLevelType level = value ? LogLevel::Info : LogLevel::Off;
+  LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, unload));
 }
 
 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL;