ostream.cpp revision 100
0N/A * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A#
include "incls/_precompiled.incl" 0N/Aextern "C" void jio_print(
const char* s);
// Declarationtion of jvm method 0N/A// Execute a vsprintf, using the given buffer if necessary. 0N/A// Return a pointer to the formatted string. 0N/A // constant format string 0N/A // trivial copy-through format string 0N/A // outputStream::stamp() may get called by ostream_abort(), use snprintf 0N/A // to avoid allocating large stack buffer in print(). 0N/A // N.B. Same as INT64_FORMAT 0N/A // N.B. Same as UINT64_FORMAT 0N/A// useful for output to fixed chunks of memory, such as performance counters 0N/A // if buffer cannot resize, silently truncate 0N/A // For small overruns, double the buffer. For larger ones, 0N/A // increase to the requested size. 0N/A // invariant: buffer is always null-terminated 0N/A // Note that the following does not depend on write_len. 0N/A // This means that position and count get updated 0N/A // even when overflow occurs. 0N/A // lazily create log file (at startup, LogVMOutput is false even 0N/A // if +LogVMOutput is used, because the flags haven't been parsed yet) 0N/A // For safer printing during fatal error handling, do not init logfile 0N/A // if a VM error has been reported. 0N/A // convert foo*bar.log to foo123bar.log 0N/A // %%% Need a MutexLocker? 0N/A // Try again to open the file. 0N/A // Note: This feature is for maintainer use only. No need for L10N. 0N/A // Write XML header. 0N/A // (For now, don't bother to issue a DTD for this private format.) 0N/A // %%% Should be: jlong time_ms = os::start_time_milliseconds(), if 0N/A // we ever get round to introduce that method on the os class 0N/A // Write VM version header immediately. 0N/A // Record information about the command-line invocation. 0N/A xs->
head(
"vm_arguments");
// Cf. Arguments::print_on() 0N/A // Print it as a java-style property list. 0N/A // System properties don't generally contain newlines, so don't bother with unparsing. 0N/A // tty output per se is grouped under the <tty>...</tty> element. 0N/A // All further non-markup text gets copied to the tty: 0N/A // and leave xtty as NULL 0N/A// finish_log() is called during normal VM shutdown. finish_log_on_error() is 0N/A// called by ostream_abort() after a fatal error. 0N/A // Other log forks are appended here, at the End of Time: 0N/A // Other log forks are appended here, at the End of Time: 0N/A // Can't delete or close the file because delete and fclose aren't 0N/A // async-safe. We are about to die, so leave it to the kernel. 0N/A if (
// impossible, but who knows? 0N/A // bootstrap problem 0N/A // can't grab a lock or call Thread::current() if TLS isn't initialized 0N/A // VM already unhealthy 0N/A // safepoint == global lock (for VM only) 0N/A // do not attempt to lock unless we know the thread and the VM is healthy 0N/A // already held, no need to re-grab the lock 0N/A // output a hint where this output is coming from: 0N/A // nothing to release: either a recursive lock, or we scribbled (too bad) 0N/A return;
// already unlocked, perhaps via break_tty_lock_for_safepoint 0N/A// Yuck: jio_print does not accept char*/len. 0N/A // print to output stream. It can be redirected by a vfprintf hook 0N/A // print to log file 0N/A // flush the log file too, if there were any newlines 0N/A // (else there was no lock to break) 0N/A // We want to ensure that time stamps in GC logs consider time 0 0N/A // the time when the JVM is initialized, not the first time we ask 0N/A // for a time stamp. So, here, we explicitly update the time stamp 0N/A // Note : this must be called AFTER ostream_init() 0N/A // now we update the time stamp of the GC log to be synced up 0N/A // If we haven't lazily initialized the logfile yet, do it now, 0N/A // to avoid the possibility of lazy initialization during a VM 0N/A // crash, which can affect the stability of the fatal error handler. 0N/A// ostream_exit() is called during normal VM exit to finish log files, flush 0N/A// output and free resource. 0N/A // we temporaly disable PrintMallocFree here 0N/A // as otherwise it'll lead to using of almost deleted 0N/A // tty or defaultStream::instance in logging facility 0N/A // of HeapFree(), see 6391258 0N/A// ostream_abort() is called by os::abort() when VM is about to die. 0N/A // Here we can't delete gclog_or_tty and tty, just flush their output 0N/A // if buffer cannot resize, silently truncate 0N/A // For small overruns, double the buffer. For larger ones, 0N/A // increase to the requested size. 0N/A assert(
false,
"Socket could not be created!");