--- old/src/share/vm/runtime/arguments.hpp 2016-01-11 11:51:31.901522020 -0500 +++ new/src/share/vm/runtime/arguments.hpp 2016-01-11 11:51:31.719088576 -0500 @@ -30,7 +30,8 @@ #include "runtime/perfData.hpp" #include "utilities/debug.hpp" #include "utilities/top.hpp" - +#include "logging/logTag.hpp" +#include "logging/logLevel.hpp" // Arguments parses the command line and recognizes options // Invocation API hook typedefs (these should really be defined in jni.hpp) @@ -223,6 +224,14 @@ // Helper class for controlling the lifetime of JavaVMInitArgs objects. class ScopedVMInitArgs; +// Most logging functions require 5 tags. Some of them may be _NO_TAG. +typedef struct { + const char* alias_name; + LogLevelType level; + bool exactMatch; + LogTagType tag; +} AliasedLoggingFlag; + class Arguments : AllStatic { friend class VMStructs; friend class JvmtiExport; @@ -446,7 +455,7 @@ // Return NULL if the arg has expired. static const char* handle_aliases_and_deprecation(const char* arg, bool warn); static bool lookup_logging_aliases(const char* arg, char* buffer); - + static AliasedLoggingFlag catch_logging_aliases(const char* name); static short CompileOnlyClassesNum; static short CompileOnlyClassesMax; static char** CompileOnlyClasses; --- old/src/share/vm/logging/logTag.hpp 2016-01-11 11:51:31.915675577 -0500 +++ new/src/share/vm/logging/logTag.hpp 2016-01-11 11:51:31.734934042 -0500 @@ -89,10 +89,14 @@ // If too many tags are given, a static assert in the log class will fail. #define LOG_TAGS_EXPANDED(T0, T1, T2, T3, T4, T5, ...) PREFIX_LOG_TAG(T0), PREFIX_LOG_TAG(T1), PREFIX_LOG_TAG(T2), \ PREFIX_LOG_TAG(T3), PREFIX_LOG_TAG(T4), PREFIX_LOG_TAG(T5) +// Generate a comma separated list of the first 6 tags. +#define VAR_LOG_TAGS_EXPANDED(V0, V1, V2, V3, V4, V5, ...) V0, V1, V2, V3, V4, V5 // The EXPAND_VARARGS macro is required for MSVC, or it will resolve the LOG_TAGS_EXPANDED macro incorrectly. #define EXPAND_VARARGS(x) x +#define VAR_LOG_TAGS(...) EXPAND_VARARGS(VAR_LOG_TAGS_EXPANDED(__VA_ARGS__, PREFIX_LOG_TAG(_NO_TAG), PREFIX_LOG_TAG(_NO_TAG), \ + PREFIX_LOG_TAG(_NO_TAG), PREFIX_LOG_TAG(_NO_TAG), \ + PREFIX_LOG_TAG(_NO_TAG), PREFIX_LOG_TAG(_NO_TAG))) #define LOG_TAGS(...) EXPAND_VARARGS(LOG_TAGS_EXPANDED(__VA_ARGS__, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG)) - // Log tags are used to classify log messages. // Each log message can be assigned between 1 to LogTag::MaxTags number of tags. // Specifying multiple tags for a log message means that only outputs configured --- old/src/share/vm/runtime/arguments.cpp 2016-01-11 11:51:31.915574653 -0500 +++ new/src/share/vm/runtime/arguments.cpp 2016-01-11 11:51:31.734831893 -0500 @@ -33,6 +33,7 @@ #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/taskqueue.hpp" #include "logging/log.hpp" +#include "logging/logTag.hpp" #include "logging/logConfiguration.hpp" #include "memory/allocation.inline.hpp" #include "memory/universe.inline.hpp" @@ -399,14 +400,11 @@ { NULL, NULL} }; -static AliasedFlag const aliased_jvm_logging_flags[] = { - { "-XX:+TraceClassResolution", "-Xlog:classresolve=info"}, - { "-XX:-TraceClassResolution", "-Xlog:classresolve=off"}, - { "-XX:+TraceExceptions", "-Xlog:exceptions=info" }, - { "-XX:-TraceExceptions", "-Xlog:exceptions=off" }, - { "-XX:+TraceMonitorInflation", "-Xlog:monitorinflation=debug" }, - { "-XX:-TraceMonitorInflation", "-Xlog:monitorinflation=off" }, - { NULL, NULL } +static AliasedLoggingFlag const aliased_logging_flags[] = { + { "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve }, + { "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions }, + { "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation }, + { NULL, LogLevel::Off, false, LogTag::__NO_TAG } }; // Return true if "v" is less than "other", where "other" may be "undefined". @@ -939,18 +937,15 @@ return NULL; } -// lookup_logging_aliases -// Called from parse_each_vm_init_arg(). Should be called on -XX options before specific cases are checked. -// If arg matches any aliased_jvm_logging_flags entry, look up the real name and copy it into buffer. -bool Arguments::lookup_logging_aliases(const char* arg, char* buffer) { - for (size_t i = 0; aliased_jvm_logging_flags[i].alias_name != NULL; i++) { - const AliasedFlag& flag_status = aliased_jvm_logging_flags[i]; - if (strcmp(flag_status.alias_name, arg) == 0) { - strcpy(buffer, flag_status.real_name); - return true; +AliasedLoggingFlag Arguments::catch_logging_aliases(const char* name){ + for (size_t i = 0; aliased_logging_flags[i].alias_name != NULL; i++) { + const AliasedLoggingFlag& alf = aliased_logging_flags[i]; + if (strcmp(alf.alias_name, name) == 0) { + return alf; } } - return false; + AliasedLoggingFlag a = {NULL, LogLevel::Off, false, LogTag::__NO_TAG}; + return a; } bool Arguments::parse_argument(const char* arg, Flag::Flags origin) { @@ -962,8 +957,14 @@ char dummy; const char* real_name; bool warn_if_deprecated = true; + AliasedLoggingFlag alf; if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { + alf = catch_logging_aliases(name); + if (alf.alias_name != NULL){ + LogConfiguration::configure_stdout(LogLevel::Off, alf.exactMatch, VAR_LOG_TAGS(alf.tag)); + return true; + } real_name = handle_aliases_and_deprecation(name, warn_if_deprecated); if (real_name == NULL) { return false; @@ -971,6 +972,11 @@ return set_bool_flag(real_name, false, origin); } if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { + alf = catch_logging_aliases(name); + if (alf.alias_name != NULL){ + LogConfiguration::configure_stdout(alf.level, alf.exactMatch, VAR_LOG_TAGS(alf.tag)); + return true; + } real_name = handle_aliases_and_deprecation(name, warn_if_deprecated); if (real_name == NULL) { return false; @@ -2629,7 +2635,7 @@ for (int index = 0; index < args->nOptions; index++) { bool is_absolute_path = false; // for -agentpath vs -agentlib - JavaVMOption* option = args->options + index; + const JavaVMOption* option = args->options + index; if (!match_option(option, "-Djava.class.path", &tail) && !match_option(option, "-Dsun.java.command", &tail) && @@ -2643,16 +2649,6 @@ build_jvm_args(option->optionString); } - // char buffer to store looked up logging option. - char aliased_logging_option[256]; - - // Catch -XX options which are aliased to Unified logging commands. - if (match_option(option, "-XX:", &tail)) { - if (lookup_logging_aliases(option->optionString, aliased_logging_option)) { - option->optionString = aliased_logging_option; - } - } - // -verbose:[class/gc/jni] if (match_option(option, "-verbose", &tail)) { if (!strcmp(tail, ":class") || !strcmp(tail, "")) {