--- old/src/share/vm/compiler/compileBroker.cpp 2017-06-16 19:50:44.810699715 -0400 +++ new/src/share/vm/compiler/compileBroker.cpp 2017-06-16 19:50:44.682693321 -0400 @@ -52,8 +52,10 @@ #include "runtime/sweeper.hpp" #include "runtime/timerTrace.hpp" #include "trace/tracing.hpp" +#include "utilities/debug.hpp" #include "utilities/dtrace.hpp" #include "utilities/events.hpp" +#include "utilities/formatBuffer.hpp" #ifdef COMPILER1 #include "c1/c1_Compiler.hpp" #endif --- old/src/share/vm/gc/g1/heapRegionRemSet.cpp 2017-06-16 19:50:45.382728316 -0400 +++ new/src/share/vm/gc/g1/heapRegionRemSet.cpp 2017-06-16 19:50:45.254721909 -0400 @@ -35,6 +35,8 @@ #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" #include "utilities/bitMap.inline.hpp" +#include "utilities/debug.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" --- old/src/share/vm/gc/parallel/psParallelCompact.cpp 2017-06-16 19:50:45.934755903 -0400 +++ new/src/share/vm/gc/parallel/psParallelCompact.cpp 2017-06-16 19:50:45.806749500 -0400 @@ -66,7 +66,9 @@ #include "services/management.hpp" #include "services/memTracker.hpp" #include "services/memoryService.hpp" +#include "utilities/debug.hpp" #include "utilities/events.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/stack.inline.hpp" #include --- old/src/share/vm/gc/shared/collectedHeap.hpp 2017-06-16 19:50:46.510784705 -0400 +++ new/src/share/vm/gc/shared/collectedHeap.hpp 2017-06-16 19:50:46.382778300 -0400 @@ -31,7 +31,9 @@ #include "runtime/handles.hpp" #include "runtime/perfData.hpp" #include "runtime/safepoint.hpp" +#include "utilities/debug.hpp" #include "utilities/events.hpp" +#include "utilities/formatBuffer.hpp" // A "CollectedHeap" is an implementation of a java heap for HotSpot. This // is an abstract class: there may be many different kinds of heaps. This --- old/src/share/vm/gc/shared/genCollectedHeap.cpp 2017-06-16 19:50:47.062812297 -0400 +++ new/src/share/vm/gc/shared/genCollectedHeap.cpp 2017-06-16 19:50:46.930805698 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,6 +53,8 @@ #include "runtime/vmThread.hpp" #include "services/management.hpp" #include "services/memoryService.hpp" +#include "utilities/debug.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/macros.hpp" #include "utilities/stack.inline.hpp" #include "utilities/vmError.hpp" --- old/src/share/vm/memory/universe.cpp 2017-06-16 19:50:47.630840691 -0400 +++ new/src/share/vm/memory/universe.cpp 2017-06-16 19:50:47.494833899 -0400 @@ -73,7 +73,9 @@ #include "runtime/vm_operations.hpp" #include "services/memoryService.hpp" #include "utilities/copy.hpp" +#include "utilities/debug.hpp" #include "utilities/events.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/hashtable.inline.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" --- old/src/share/vm/runtime/frame.cpp 2017-06-16 19:50:48.202869284 -0400 +++ new/src/share/vm/runtime/frame.cpp 2017-06-16 19:50:48.070862686 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,9 @@ #include "runtime/stubCodeGenerator.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/thread.inline.hpp" +#include "utilities/debug.hpp" #include "utilities/decoder.hpp" +#include "utilities/formatBuffer.hpp" RegisterMap::RegisterMap(JavaThread *thread, bool update_map) { _thread = thread; --- old/src/share/vm/services/attachListener.cpp 2017-06-16 19:50:48.762897274 -0400 +++ new/src/share/vm/services/attachListener.cpp 2017-06-16 19:50:48.630890684 -0400 @@ -38,6 +38,8 @@ #include "services/diagnosticCommand.hpp" #include "services/heapDumper.hpp" #include "services/writeableFlags.hpp" +#include "utilities/debug.hpp" +#include "utilities/formatBuffer.hpp" volatile bool AttachListener::_initialized; --- old/src/share/vm/services/diagnosticCommand.cpp 2017-06-16 19:50:49.310924678 -0400 +++ new/src/share/vm/services/diagnosticCommand.cpp 2017-06-16 19:50:49.178918073 -0400 @@ -40,6 +40,8 @@ #include "services/heapDumper.hpp" #include "services/management.hpp" #include "services/writeableFlags.hpp" +#include "utilities/debug.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/macros.hpp" #include "oops/objArrayOop.inline.hpp" --- old/src/share/vm/services/management.cpp 2017-06-16 19:50:49.870952672 -0400 +++ new/src/share/vm/services/management.cpp 2017-06-16 19:50:49.738946070 -0400 @@ -56,6 +56,8 @@ #include "services/memoryService.hpp" #include "services/runtimeService.hpp" #include "services/threadService.hpp" +#include "utilities/debug.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/macros.hpp" PerfVariable* Management::_begin_vm_creation_time = NULL; --- old/src/share/vm/services/writeableFlags.hpp 2017-06-16 19:50:50.426980467 -0400 +++ new/src/share/vm/services/writeableFlags.hpp 2017-06-16 19:50:50.298974068 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ #ifndef SHARE_VM_SERVICES_WRITEABLEFLAG_HPP #define SHARE_VM_SERVICES_WRITEABLEFLAG_HPP +#include "runtime/globals.hpp" +#include "utilities/formatBuffer.hpp" + class WriteableFlags : AllStatic { private: // a writeable flag setter accepting either 'jvalue' or 'char *' values --- old/src/share/vm/utilities/debug.cpp 2017-06-16 19:50:51.031010669 -0400 +++ new/src/share/vm/utilities/debug.cpp 2017-06-16 19:50:50.899004060 -0400 @@ -52,6 +52,7 @@ #include "services/heapDumper.hpp" #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/macros.hpp" #include "utilities/vmError.hpp" @@ -81,14 +82,6 @@ # endif #endif // PRODUCT -FormatBufferResource::FormatBufferResource(const char * format, ...) - : FormatBufferBase((char*)resource_allocate_bytes(FormatBufferBase::BufferSize)) { - va_list argp; - va_start(argp, format); - jio_vsnprintf(_buf, FormatBufferBase::BufferSize, format, argp); - va_end(argp); -} - ATTRIBUTE_PRINTF(1, 2) void warning(const char* format, ...) { if (PrintWarnings) { --- old/src/share/vm/utilities/debug.hpp 2017-06-16 19:50:51.639041069 -0400 +++ new/src/share/vm/utilities/debug.hpp 2017-06-16 19:50:51.511034658 -0400 @@ -26,96 +26,6 @@ #define SHARE_VM_UTILITIES_DEBUG_HPP #include "utilities/globalDefinitions.hpp" -#include "prims/jvm.h" - -#include - -// Simple class to format the ctor arguments into a fixed-sized buffer. -class FormatBufferBase { - protected: - char* _buf; - inline FormatBufferBase(char* buf) : _buf(buf) {} - public: - static const int BufferSize = 256; - operator const char *() const { return _buf; } -}; - -// Use resource area for buffer -class FormatBufferResource : public FormatBufferBase { - public: - FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); -}; - -class FormatBufferDummy {}; - -// Use stack for buffer -template -class FormatBuffer : public FormatBufferBase { - public: - inline FormatBuffer(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - // since va_list is unspecified type (can be char*), we use FormatBufferDummy to disambiguate these constructors - inline FormatBuffer(FormatBufferDummy dummy, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0); - inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - inline void printv(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - - char* buffer() { return _buf; } - int size() { return bufsz; } - - private: - FormatBuffer(const FormatBuffer &); // prevent copies - char _buffer[bufsz]; - - protected: - inline FormatBuffer(); -}; - -template -FormatBuffer::FormatBuffer(const char * format, ...) : FormatBufferBase(_buffer) { - va_list argp; - va_start(argp, format); - jio_vsnprintf(_buf, bufsz, format, argp); - va_end(argp); -} - -template -FormatBuffer::FormatBuffer(FormatBufferDummy dummy, const char * format, va_list ap) : FormatBufferBase(_buffer) { - jio_vsnprintf(_buf, bufsz, format, ap); -} - -template -FormatBuffer::FormatBuffer() : FormatBufferBase(_buffer) { - _buf[0] = '\0'; -} - -template -void FormatBuffer::print(const char * format, ...) { - va_list argp; - va_start(argp, format); - jio_vsnprintf(_buf, bufsz, format, argp); - va_end(argp); -} - -template -void FormatBuffer::printv(const char * format, va_list argp) { - jio_vsnprintf(_buf, bufsz, format, argp); -} - -template -void FormatBuffer::append(const char* format, ...) { - // Given that the constructor does a vsnprintf we can assume that - // _buf is already initialized. - size_t len = strlen(_buf); - char* buf_end = _buf + len; - - va_list argp; - va_start(argp, format); - jio_vsnprintf(buf_end, bufsz - len, format, argp); - va_end(argp); -} - -// Used to format messages. -typedef FormatBuffer<> err_msg; // assertions #ifndef ASSERT --- old/src/share/vm/utilities/events.hpp 2017-06-16 19:50:52.183068248 -0400 +++ new/src/share/vm/utilities/events.hpp 2017-06-16 19:50:52.055061855 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ #include "memory/allocation.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/thread.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/vmError.hpp" // Events and EventMark provide interfaces to log events taking place in the vm. --- /dev/null 2017-05-19 14:48:27.437288209 -0400 +++ new/src/share/vm/utilities/formatBuffer.cpp 2017-06-16 19:50:52.599089055 -0400 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "prims/jvm.h" +#include "utilities/formatBuffer.hpp" + +#include + +FormatBufferResource::FormatBufferResource(const char * format, ...) + : FormatBufferBase((char*)resource_allocate_bytes(FormatBufferBase::BufferSize)) { + va_list argp; + va_start(argp, format); + jio_vsnprintf(_buf, FormatBufferBase::BufferSize, format, argp); + va_end(argp); +} + --- /dev/null 2017-05-19 14:48:27.437288209 -0400 +++ new/src/share/vm/utilities/formatBuffer.hpp 2017-06-16 19:50:53.099114044 -0400 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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_UTILITIES_FORMATBUFFER_HPP +#define SHARE_VM_UTILITIES_FORMATBUFFER_HPP + +#include "utilities/globalDefinitions.hpp" +#include "prims/jvm.h" +#include + +// Simple class to format the ctor arguments into a fixed-sized buffer. +class FormatBufferBase { + protected: + char* _buf; + inline FormatBufferBase(char* buf) : _buf(buf) {} + public: + static const int BufferSize = 256; + operator const char *() const { return _buf; } +}; + +// Use resource area for buffer +class FormatBufferResource : public FormatBufferBase { + public: + FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); +}; + +class FormatBufferDummy {}; + +// Use stack for buffer +template +class FormatBuffer : public FormatBufferBase { + public: + inline FormatBuffer(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + // since va_list is unspecified type (can be char*), we use FormatBufferDummy to disambiguate these constructors + inline FormatBuffer(FormatBufferDummy dummy, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0); + inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + inline void printv(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); + + char* buffer() { return _buf; } + int size() { return bufsz; } + + private: + FormatBuffer(const FormatBuffer &); // prevent copies + char _buffer[bufsz]; + + protected: + inline FormatBuffer(); +}; + +template +FormatBuffer::FormatBuffer(const char * format, ...) : FormatBufferBase(_buffer) { + va_list argp; + va_start(argp, format); + jio_vsnprintf(_buf, bufsz, format, argp); + va_end(argp); +} + +template +FormatBuffer::FormatBuffer(FormatBufferDummy dummy, const char * format, va_list ap) : FormatBufferBase(_buffer) { + jio_vsnprintf(_buf, bufsz, format, ap); +} + +template +FormatBuffer::FormatBuffer() : FormatBufferBase(_buffer) { + _buf[0] = '\0'; +} + +template +void FormatBuffer::print(const char * format, ...) { + va_list argp; + va_start(argp, format); + jio_vsnprintf(_buf, bufsz, format, argp); + va_end(argp); +} + +template +void FormatBuffer::printv(const char * format, va_list argp) { + jio_vsnprintf(_buf, bufsz, format, argp); +} + +template +void FormatBuffer::append(const char* format, ...) { + // Given that the constructor does a vsnprintf we can assume that + // _buf is already initialized. + size_t len = strlen(_buf); + char* buf_end = _buf + len; + + va_list argp; + va_start(argp, format); + jio_vsnprintf(buf_end, bufsz - len, format, argp); + va_end(argp); +} + +// Used to format messages. +typedef FormatBuffer<> err_msg; + +#endif // SHARE_VM_UTILITIES_FORMATBUFFER_HPP