2015-09-24 12:36:04 +02:00
|
|
|
/*
|
2018-03-26 16:51:43 +02:00
|
|
|
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
2015-09-24 12:36:04 +02:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef SHARE_VM_LOGGING_LOGPREFIX_HPP
|
|
|
|
#define SHARE_VM_LOGGING_LOGPREFIX_HPP
|
|
|
|
|
|
|
|
#include "gc/shared/gcId.hpp"
|
|
|
|
#include "logging/logTag.hpp"
|
|
|
|
|
2015-11-13 09:49:28 +01:00
|
|
|
// Prefixes prepend each log message for a specified tagset with a given prefix.
|
|
|
|
// These prefixes are written before the log message but after the log decorations.
|
|
|
|
//
|
|
|
|
// A prefix is defined as a function that takes a buffer (with some size) as argument.
|
|
|
|
// This function will be called for each log message, and should write the prefix
|
|
|
|
// to the given buffer. The function should return how many characters it wrote,
|
|
|
|
// which should never exceed the given size.
|
2015-09-24 12:36:04 +02:00
|
|
|
//
|
|
|
|
// List of prefixes for specific tags and/or tagsets.
|
2015-11-13 09:49:28 +01:00
|
|
|
// Syntax: LOG_PREFIX(<name of prefixer function>, LOG_TAGS(<chosen log tags>))
|
|
|
|
// Where the prefixer function matches the following signature: size_t (*)(char*, size_t)
|
2016-03-29 09:43:05 +02:00
|
|
|
|
|
|
|
// Prefix function for internal vm test
|
|
|
|
DEBUG_ONLY(size_t Test_log_prefix_prefixer(char* buf, size_t len);)
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
#define LOG_PREFIX_LIST \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, age)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, alloc)) \
|
2016-03-22 13:41:52 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, alloc, region)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, barrier)) \
|
2016-02-05 08:59:36 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, classhisto)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, compaction)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, cpu)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo, cset)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo, heap)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo, ihop)) \
|
2016-04-18 14:52:31 -04:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo, refine)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, heap)) \
|
2016-03-14 09:11:21 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, heap, region)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, freelist)) \
|
2016-04-01 11:58:45 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, humongous)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ihop)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, liveness)) \
|
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 17:40:28 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, load)) \
|
2016-03-16 12:23:13 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, marking)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, metaspace)) \
|
2016-04-29 08:39:22 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, mmu)) \
|
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 17:40:28 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, nmethod)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases)) \
|
2017-08-10 18:09:19 -07:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, ref)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, start)) \
|
2016-02-29 13:06:03 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, task)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, plab)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, region)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, remset)) \
|
2018-03-26 16:51:43 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, remset, tracking)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ref)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ref, start)) \
|
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 17:40:28 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, reloc)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, start)) \
|
2016-06-21 14:00:18 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, stringtable)) \
|
2018-08-14 18:42:14 -05:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, symboltable)) \
|
2015-12-10 14:57:55 +01:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, sweep)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task, start)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task, stats)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task, time)) \
|
2016-03-29 09:43:05 +02:00
|
|
|
DEBUG_ONLY(LOG_PREFIX(Test_log_prefix_prefixer, LOG_TAGS(logging, test))) \
|
2016-04-01 07:08:40 +02:00
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, tlab)) \
|
|
|
|
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, workgang))
|
2015-12-10 14:57:55 +01:00
|
|
|
|
2015-09-24 12:36:04 +02:00
|
|
|
|
|
|
|
// The empty prefix, used when there's no prefix defined.
|
|
|
|
template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag = LogTag::__NO_TAG>
|
|
|
|
struct LogPrefix : public AllStatic {
|
|
|
|
STATIC_ASSERT(GuardTag == LogTag::__NO_TAG);
|
|
|
|
static size_t prefix(char* buf, size_t len) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-11-13 09:49:28 +01:00
|
|
|
#define LOG_PREFIX(fn, ...) \
|
2015-09-24 12:36:04 +02:00
|
|
|
template <> struct LogPrefix<__VA_ARGS__> { \
|
|
|
|
static size_t prefix(char* buf, size_t len) { \
|
2015-11-13 09:49:28 +01:00
|
|
|
size_t ret = fn(buf, len); \
|
2016-05-09 15:46:12 +02:00
|
|
|
/* Either prefix did fit (strlen(buf) == ret && ret < len) */ \
|
|
|
|
/* or the prefix didn't fit in buffer (ret > len && strlen(buf) < len) */ \
|
|
|
|
assert(ret == 0 || strlen(buf) < len, \
|
|
|
|
"Buffer overrun by prefix function."); \
|
|
|
|
assert(ret == 0 || strlen(buf) == ret || ret >= len, \
|
|
|
|
"Prefix function should return length of prefix written," \
|
|
|
|
" or the intended length of prefix if the buffer was too small."); \
|
2015-09-24 12:36:04 +02:00
|
|
|
return ret; \
|
|
|
|
} \
|
|
|
|
};
|
|
|
|
LOG_PREFIX_LIST
|
|
|
|
#undef LOG_PREFIX
|
|
|
|
|
|
|
|
#endif // SHARE_VM_LOGGING_LOGPREFIX_HPP
|