hotspot/src/share/vm/logging/logTag.hpp
author mockner
Thu, 25 Feb 2016 13:09:17 -0500
changeset 36364 5971776598e5
parent 36355 dd339cbafd31
child 36381 b9ed6bef9364
permissions -rw-r--r--
8150103: Convert TraceClassPaths to Unified Logging Summary: TraceClassPaths has been reimplemented with Unified Logging Reviewed-by: coleenp, dholmes, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     1
/*
36178
9739f8c767da 8148630: Convert TraceStartupTime to Unified Logging
rprotacio
parents: 35925
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     4
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     7
 * published by the Free Software Foundation.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     8
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    13
 * accompanied this code).
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    14
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    18
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    21
 * questions.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    22
 *
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    23
 */
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    24
#ifndef SHARE_VM_LOGGING_LOGTAG_HPP
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    25
#define SHARE_VM_LOGGING_LOGTAG_HPP
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    26
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    27
#include "memory/allocation.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    29
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    30
// List of available logging tags. New tags should be added here.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    31
// (The tags 'all', 'disable' and 'help' are special tags that can
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    32
// not be used in log calls, and should not be listed below.)
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    33
#define LOG_TAG_LIST \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    34
  LOG_TAG(alloc) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    35
  LOG_TAG(age) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    36
  LOG_TAG(barrier) \
36186
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents: 36178
diff changeset
    37
  LOG_TAG(biasedlocking) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    38
  LOG_TAG(bot) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    39
  LOG_TAG(census) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    40
  LOG_TAG(classhisto) \
35219
b9ef87beb87c 8144874: Reimplement TraceClassResolution with Unified Logging.
mockner
parents: 35216
diff changeset
    41
  LOG_TAG(classresolve) \
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents: 33763
diff changeset
    42
  LOG_TAG(classinit) \
35917
463d67f86eaa 8079408: Reimplement TraceClassLoading, TraceClassUnloading, and TraceClassLoaderData with Unified Logging.
mockner
parents: 35884
diff changeset
    43
  LOG_TAG(classload) /* Trace all classes loaded */ \
463d67f86eaa 8079408: Reimplement TraceClassLoading, TraceClassUnloading, and TraceClassLoaderData with Unified Logging.
mockner
parents: 35884
diff changeset
    44
  LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \
463d67f86eaa 8079408: Reimplement TraceClassLoading, TraceClassUnloading, and TraceClassLoaderData with Unified Logging.
mockner
parents: 35884
diff changeset
    45
  LOG_TAG(classunload) /* Trace unloading of classes */ \
36364
5971776598e5 8150103: Convert TraceClassPaths to Unified Logging
mockner
parents: 36355
diff changeset
    46
  LOG_TAG(classpath) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    47
  LOG_TAG(compaction) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    48
  LOG_TAG(cpu) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    49
  LOG_TAG(cset) \
33736
1b3950243443 8139564: Convert TraceDefaultMethods to Unified Logging
rprotacio
parents: 33097
diff changeset
    50
  LOG_TAG(defaultmethods) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    51
  LOG_TAG(ergo) \
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35171
diff changeset
    52
  LOG_TAG(exceptions) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    53
  LOG_TAG(exit) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    54
  LOG_TAG(freelist) \
34150
ec723a529700 8144016: Add the gc tag to the logging framework
brutisso
parents: 33763
diff changeset
    55
  LOG_TAG(gc) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    56
  LOG_TAG(heap) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    57
  LOG_TAG(humongous) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    58
  LOG_TAG(ihop) \
35463
b32e362563bb 8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents: 35219
diff changeset
    59
  LOG_TAG(itables) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    60
  LOG_TAG(jni) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    61
  LOG_TAG(liveness) \
33763
cec2333f839c 8140348: Convert TraceSafepoint to Unified Logging
rprotacio
parents: 33736
diff changeset
    62
  LOG_TAG(logging) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    63
  LOG_TAG(marking) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    64
  LOG_TAG(metaspace) \
35171
cf7d5a1d0662 8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents: 35061
diff changeset
    65
  LOG_TAG(monitorinflation) \
35884
ec439aaca107 6515172: Runtime.availableProcessors() ignores Linux taskset command
dholmes
parents: 35463
diff changeset
    66
  LOG_TAG(os) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    67
  LOG_TAG(phases) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    68
  LOG_TAG(plab) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    69
  LOG_TAG(promotion) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    70
  LOG_TAG(ref) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    71
  LOG_TAG(refine) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    72
  LOG_TAG(region) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    73
  LOG_TAG(remset) \
34262
43560e879d6d 8143157: Convert TraceVMOperation to Unified Logging
rprotacio
parents: 33763
diff changeset
    74
  LOG_TAG(safepoint) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    75
  LOG_TAG(scavenge) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    76
  LOG_TAG(scrub) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    77
  LOG_TAG(start) \
36178
9739f8c767da 8148630: Convert TraceStartupTime to Unified Logging
rprotacio
parents: 35925
diff changeset
    78
  LOG_TAG(startuptime) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    79
  LOG_TAG(state) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    80
  LOG_TAG(stats) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    81
  LOG_TAG(stringdedup) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    82
  LOG_TAG(survivor) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    83
  LOG_TAG(sweep) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    84
  LOG_TAG(task) \
36355
dd339cbafd31 8149036: Add tracing for thread related events at os level
stuefe
parents: 36186
diff changeset
    85
  LOG_TAG(thread) \
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    86
  LOG_TAG(tlab) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    87
  LOG_TAG(time) \
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34656
diff changeset
    88
  LOG_TAG(verify) \
35463
b32e362563bb 8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents: 35219
diff changeset
    89
  LOG_TAG(vmoperation) \
b32e362563bb 8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents: 35219
diff changeset
    90
  LOG_TAG(vtables)
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    91
34656
501b8f1784c4 8144146: Unified Logging tags cannot be reserved keywords
mlarsson
parents: 34629
diff changeset
    92
#define PREFIX_LOG_TAG(T) (LogTag::_##T)
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    93
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    94
// Expand a set of log tags to their prefixed names.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    95
// For error detection purposes, the macro passes one more tag than what is supported.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    96
// If too many tags are given, a static assert in the log class will fail.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    97
#define LOG_TAGS_EXPANDED(T0, T1, T2, T3, T4, T5, ...)  PREFIX_LOG_TAG(T0), PREFIX_LOG_TAG(T1), PREFIX_LOG_TAG(T2), \
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    98
                                                        PREFIX_LOG_TAG(T3), PREFIX_LOG_TAG(T4), PREFIX_LOG_TAG(T5)
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
    99
// The EXPAND_VARARGS macro is required for MSVC, or it will resolve the LOG_TAGS_EXPANDED macro incorrectly.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   100
#define EXPAND_VARARGS(x) x
34656
501b8f1784c4 8144146: Unified Logging tags cannot be reserved keywords
mlarsson
parents: 34629
diff changeset
   101
#define LOG_TAGS(...) EXPAND_VARARGS(LOG_TAGS_EXPANDED(__VA_ARGS__, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG))
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   102
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   103
// Log tags are used to classify log messages.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   104
// Each log message can be assigned between 1 to LogTag::MaxTags number of tags.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   105
// Specifying multiple tags for a log message means that only outputs configured
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   106
// for those exact tags, or a subset of the tags with a wildcard, will see the logging.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   107
// Multiple tags should be comma separated, e.g. log_error(tag1, tag2)("msg").
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   108
class LogTag : public AllStatic {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   109
 public:
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   110
  // The maximum number of tags that a single log message can have.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   111
  // E.g. there might be hundreds of different tags available,
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   112
  // but a specific log message can only be tagged with up to MaxTags of those.
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   113
  static const size_t MaxTags = 5;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   114
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   115
  enum type {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   116
    __NO_TAG,
34656
501b8f1784c4 8144146: Unified Logging tags cannot be reserved keywords
mlarsson
parents: 34629
diff changeset
   117
#define LOG_TAG(name) _##name,
33097
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   118
    LOG_TAG_LIST
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   119
#undef LOG_TAG
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   120
    Count
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   121
  };
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   122
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   123
  static const char* name(LogTag::type tag) {
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   124
    return _name[tag];
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   125
  }
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   126
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   127
  static LogTag::type from_string(const char *str);
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   128
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   129
 private:
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   130
  static const char* _name[];
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   131
};
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   132
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   133
typedef LogTag::type LogTagType;
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   134
96e348cb0442 8046148: JEP 158: Unified JVM Logging
mlarsson
parents:
diff changeset
   135
#endif // SHARE_VM_LOGGING_LOGTAG_HPP