1 /* 2 * Copyright (c) 2015, 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 "memory/allocation.hpp" 28 #include "utilities/globalDefinitions.hpp" 29 30 // List of available logging tags. New tags should be added here. 31 // (The tags 'all', 'disable' and 'help' are special tags that can 32 // not be used in log calls, and should not be listed below.) 33 #define LOG_TAG_LIST \ 34 LOG_TAG(alloc) \ 35 LOG_TAG(age) \ 36 LOG_TAG(barrier) \ 37 LOG_TAG(bot) \ 38 LOG_TAG(census) \ 39 LOG_TAG(classhisto) \ 40 LOG_TAG(classresolve) \ 41 LOG_TAG(classinit) \ 42 LOG_TAG(classload) /* Trace all classes loaded */ \ 43 LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \ 44 LOG_TAG(classunload) /* Trace unloading of classes */ \ 45 LOG_TAG(classpath) \ 46 LOG_TAG(compaction) \ 47 LOG_TAG(cpu) \ 48 LOG_TAG(cset) \ 49 LOG_TAG(defaultmethods) \ 50 LOG_TAG(ergo) \ 51 LOG_TAG(exceptions) \ 52 LOG_TAG(exit) \ 53 LOG_TAG(freelist) \ 54 LOG_TAG(gc) \ 55 LOG_TAG(heap) \ 56 LOG_TAG(humongous) \ 57 LOG_TAG(ihop) \ 58 LOG_TAG(itables) \ 59 LOG_TAG(jni) \ 60 LOG_TAG(liveness) \ 61 LOG_TAG(logging) \ 62 LOG_TAG(marking) \ 63 LOG_TAG(metaspace) \ 64 LOG_TAG(monitorinflation) \ 65 LOG_TAG(os) \ 66 LOG_TAG(phases) \ 67 LOG_TAG(plab) \ 68 LOG_TAG(promotion) \ 69 LOG_TAG(ref) \ 70 LOG_TAG(refine) \ 71 LOG_TAG(region) \ 72 LOG_TAG(remset) \ 73 LOG_TAG(safepoint) \ 74 LOG_TAG(scavenge) \ 75 LOG_TAG(scrub) \ 76 LOG_TAG(start) \ 77 LOG_TAG(state) \ 78 LOG_TAG(stats) \ 79 LOG_TAG(stringdedup) \ 80 LOG_TAG(survivor) \ 81 LOG_TAG(sweep) \ 82 LOG_TAG(task) \ 83 LOG_TAG(tlab) \ 84 LOG_TAG(time) \ 85 LOG_TAG(verify) \ 86 LOG_TAG(vmoperation) \ 87 LOG_TAG(vtables) 88 89 #define PREFIX_LOG_TAG(T) (LogTag::_##T) 90 91 // Expand a set of log tags to their prefixed names. 92 // For error detection purposes, the macro passes one more tag than what is supported. 93 // If too many tags are given, a static assert in the log class will fail. 94 #define LOG_TAGS_EXPANDED(T0, T1, T2, T3, T4, T5, ...) PREFIX_LOG_TAG(T0), PREFIX_LOG_TAG(T1), PREFIX_LOG_TAG(T2), \ 95 PREFIX_LOG_TAG(T3), PREFIX_LOG_TAG(T4), PREFIX_LOG_TAG(T5) 96 // The EXPAND_VARARGS macro is required for MSVC, or it will resolve the LOG_TAGS_EXPANDED macro incorrectly. 97 #define EXPAND_VARARGS(x) x 98 #define LOG_TAGS(...) EXPAND_VARARGS(LOG_TAGS_EXPANDED(__VA_ARGS__, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG, _NO_TAG)) 99 100 // Log tags are used to classify log messages. 101 // Each log message can be assigned between 1 to LogTag::MaxTags number of tags. 102 // Specifying multiple tags for a log message means that only outputs configured 103 // for those exact tags, or a subset of the tags with a wildcard, will see the logging. 104 // Multiple tags should be comma separated, e.g. log_error(tag1, tag2)("msg"). 105 class LogTag : public AllStatic { 106 public: 107 // The maximum number of tags that a single log message can have. 108 // E.g. there might be hundreds of different tags available, 109 // but a specific log message can only be tagged with up to MaxTags of those. 110 static const size_t MaxTags = 5; 111 112 enum type { 113 __NO_TAG, 114 #define LOG_TAG(name) _##name, 115 LOG_TAG_LIST 116 #undef LOG_TAG 117 Count 118 }; 119 120 static const char* name(LogTag::type tag) { 121 return _name[tag]; 122 } 123 124 static LogTag::type from_string(const char *str); 125 126 private: 127 static const char* _name[]; 128 }; 129 130 typedef LogTag::type LogTagType; 131 132 #endif // SHARE_VM_LOGGING_LOGTAG_HPP