logTag.hpp revision 13029:7e2df450df6c
1/*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24#ifndef SHARE_VM_LOGGING_LOGTAG_HPP
25#define SHARE_VM_LOGGING_LOGTAG_HPP
26
27#include "logging/logTag_ext.hpp"
28#include "memory/allocation.hpp"
29#include "utilities/globalDefinitions.hpp"
30
31// List of available logging tags. New tags should be added here.
32// (The tags 'all', 'disable' and 'help' are special tags that can
33// not be used in log calls, and should not be listed below.)
34#define LOG_TAG_LIST \
35  LOG_TAG(add) \
36  LOG_TAG(age) \
37  LOG_TAG(alloc) \
38  LOG_TAG(aot) \
39  LOG_TAG(annotation) \
40  LOG_TAG(arguments) \
41  LOG_TAG(attach) \
42  LOG_TAG(barrier) \
43  LOG_TAG(biasedlocking) \
44  LOG_TAG(blocks) \
45  LOG_TAG(bot) \
46  LOG_TAG(breakpoint) \
47  LOG_TAG(census) \
48  LOG_TAG(class) \
49  LOG_TAG(classhisto) \
50  LOG_TAG(cleanup) \
51  LOG_TAG(codecache) \
52  LOG_TAG(compaction) \
53  LOG_TAG(compilation) \
54  LOG_TAG(constraints) \
55  LOG_TAG(constantpool) \
56  LOG_TAG(coops) \
57  LOG_TAG(cpu) \
58  LOG_TAG(cset) \
59  LOG_TAG(data) \
60  LOG_TAG(datacreation) \
61  LOG_TAG(defaultmethods) \
62  LOG_TAG(dump) \
63  LOG_TAG(ergo) \
64  LOG_TAG(exceptions) \
65  LOG_TAG(exit) \
66  LOG_TAG(fingerprint) \
67  LOG_TAG(freelist) \
68  LOG_TAG(gc) \
69  LOG_TAG(hashtables) \
70  LOG_TAG(heap) \
71  LOG_TAG(humongous) \
72  LOG_TAG(ihop) \
73  LOG_TAG(iklass) \
74  LOG_TAG(init) \
75  LOG_TAG(inlining) \
76  LOG_TAG(itables) \
77  LOG_TAG(jit) \
78  LOG_TAG(jni) \
79  LOG_TAG(jvmti) \
80  LOG_TAG(liveness) \
81  LOG_TAG(load) /* Trace all classes loaded */ \
82  LOG_TAG(loader) \
83  LOG_TAG(logging) \
84  LOG_TAG(mark) \
85  LOG_TAG(marking) \
86  LOG_TAG(memops) \
87  LOG_TAG(methodcomparator) \
88  LOG_TAG(metadata) \
89  LOG_TAG(metaspace) \
90  LOG_TAG(mmu) \
91  LOG_TAG(modules) \
92  LOG_TAG(monitorinflation) \
93  LOG_TAG(monitormismatch) \
94  LOG_TAG(nmethod) \
95  LOG_TAG(normalize) \
96  LOG_TAG(objecttagging) \
97  LOG_TAG(obsolete) \
98  LOG_TAG(oopmap) \
99  LOG_TAG(os) \
100  LOG_TAG(pagesize) \
101  LOG_TAG(patch) \
102  LOG_TAG(path) \
103  LOG_TAG(perf) \
104  LOG_TAG(phases) \
105  LOG_TAG(plab) \
106  LOG_TAG(promotion) \
107  LOG_TAG(preorder) /* Trace all classes loaded in order referenced (not loaded) */ \
108  LOG_TAG(protectiondomain) /* "Trace protection domain verification" */ \
109  LOG_TAG(ref) \
110  LOG_TAG(redefine) \
111  LOG_TAG(refine) \
112  LOG_TAG(region) \
113  LOG_TAG(remset) \
114  LOG_TAG(purge) \
115  LOG_TAG(resolve) \
116  LOG_TAG(safepoint) \
117  LOG_TAG(scavenge) \
118  LOG_TAG(scrub) \
119  LOG_TAG(stacktrace) \
120  LOG_TAG(stackwalk) \
121  LOG_TAG(start) \
122  LOG_TAG(startuptime) \
123  LOG_TAG(state) \
124  LOG_TAG(stats) \
125  LOG_TAG(stringdedup) \
126  LOG_TAG(stringtable) \
127  LOG_TAG(stackmap) \
128  LOG_TAG(subclass) \
129  LOG_TAG(survivor) \
130  LOG_TAG(sweep) \
131  LOG_TAG(task) \
132  DEBUG_ONLY(LOG_TAG(test)) \
133  LOG_TAG(thread) \
134  LOG_TAG(tlab) \
135  LOG_TAG(time) \
136  LOG_TAG(timer) \
137  LOG_TAG(update) \
138  LOG_TAG(unload) /* Trace unloading of classes */ \
139  LOG_TAG(verification) \
140  LOG_TAG(verify) \
141  LOG_TAG(vmoperation) \
142  LOG_TAG(vtables) \
143  LOG_TAG(workgang) \
144  LOG_TAG_LIST_EXT
145
146#define PREFIX_LOG_TAG(T) (LogTag::_##T)
147
148// Expand a set of log tags to their prefixed names.
149// For error detection purposes, the macro passes one more tag than what is supported.
150// If too many tags are given, a static assert in the log class will fail.
151#define LOG_TAGS_EXPANDED(T0, T1, T2, T3, T4, T5, ...)  PREFIX_LOG_TAG(T0), PREFIX_LOG_TAG(T1), PREFIX_LOG_TAG(T2), \
152                                                        PREFIX_LOG_TAG(T3), PREFIX_LOG_TAG(T4), PREFIX_LOG_TAG(T5)
153// The EXPAND_VARARGS macro is required for MSVC, or it will resolve the LOG_TAGS_EXPANDED macro incorrectly.
154#define EXPAND_VARARGS(x) x
155#define LOG_TAGS(...) EXPAND_VARARGS(LOG_TAGS_EXPANDED(__VA_ARGS__, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG))
156
157// Log tags are used to classify log messages.
158// Each log message can be assigned between 1 to LogTag::MaxTags number of tags.
159// Specifying multiple tags for a log message means that only outputs configured
160// for those exact tags, or a subset of the tags with a wildcard, will see the logging.
161// Multiple tags should be comma separated, e.g. log_error(tag1, tag2)("msg").
162class LogTag : public AllStatic {
163 public:
164  // The maximum number of tags that a single log message can have.
165  // E.g. there might be hundreds of different tags available,
166  // but a specific log message can only be tagged with up to MaxTags of those.
167  static const size_t MaxTags = 5;
168
169  enum type {
170    __NO_TAG,
171#define LOG_TAG(name) _##name,
172    LOG_TAG_LIST
173#undef LOG_TAG
174    Count
175  };
176
177  static const char* name(LogTag::type tag) {
178    return _name[tag];
179  }
180
181  static LogTag::type from_string(const char *str);
182
183 private:
184  static const char* _name[];
185};
186
187typedef LogTag::type LogTagType;
188
189#endif // SHARE_VM_LOGGING_LOGTAG_HPP
190