< prev index next >

src/hotspot/share/utilities/ostream.cpp

Print this page
rev 58036 : [mq]: asynclog


   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 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "compiler/compileLog.hpp"

  28 #include "memory/allocation.inline.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/arguments.hpp"
  31 #include "runtime/os.inline.hpp"
  32 #include "runtime/vm_version.hpp"
  33 #include "utilities/defaultStream.hpp"
  34 #include "utilities/macros.hpp"
  35 #include "utilities/ostream.hpp"
  36 #include "utilities/vmError.hpp"
  37 #include "utilities/xmlstream.hpp"
  38 
  39 // Declarations of jvm methods
  40 extern "C" void jio_print(const char* s, size_t len);
  41 extern "C" int jio_printf(const char *fmt, ...);
  42 
  43 outputStream::outputStream(int width) {
  44   _width       = width;
  45   _position    = 0;
  46   _newlines    = 0;
  47   _precount    = 0;


 708           // keys/values.
 709           text->print_raw(p->key());
 710           text->put('=');
 711           assert(p->value() != NULL, "p->value() is NULL");
 712           text->print_raw_cr(p->value());
 713         }
 714       }
 715       xs->tail("properties");
 716     }
 717     xs->tail("vm_arguments");
 718     // tty output per se is grouped under the <tty>...</tty> element.
 719     xs->head("tty");
 720     // All further non-markup text gets copied to the tty:
 721     xs->_text = this;  // requires friend declaration!
 722 }
 723 
 724 // finish_log() is called during normal VM shutdown. finish_log_on_error() is
 725 // called by ostream_abort() after a fatal error.
 726 //
 727 void defaultStream::finish_log() {


 728   xmlStream* xs = _outer_xmlStream;
 729   xs->done("tty");
 730 
 731   // Other log forks are appended here, at the End of Time:
 732   CompileLog::finish_log(xs->out());  // write compile logging, if any, now
 733 
 734   xs->done("hotspot_log");
 735   xs->flush();
 736 
 737   fileStream* file = _log_file;
 738   _log_file = NULL;
 739 
 740   delete _outer_xmlStream;
 741   _outer_xmlStream = NULL;
 742 
 743   file->flush();
 744   delete file;
 745 }
 746 
 747 void defaultStream::finish_log_on_error(char *buf, int buflen) {


 922   if (ostream_exit_called)  return;
 923   ostream_exit_called = true;
 924 #if INCLUDE_CDS
 925   if (classlist_file != NULL) {
 926     delete classlist_file;
 927   }
 928 #endif
 929   if (tty != defaultStream::instance) {
 930     delete tty;
 931   }
 932   if (defaultStream::instance != NULL) {
 933     delete defaultStream::instance;
 934   }
 935   tty = NULL;
 936   xtty = NULL;
 937   defaultStream::instance = NULL;
 938 }
 939 
 940 // ostream_abort() is called by os::abort() when VM is about to die.
 941 void ostream_abort() {


 942   // Here we can't delete tty, just flush its output
 943   if (tty) tty->flush();
 944 
 945   if (defaultStream::instance != NULL) {
 946     static char buf[4096];
 947     defaultStream::instance->finish_log_on_error(buf, sizeof(buf));
 948   }
 949 }
 950 
 951 bufferedStream::bufferedStream(size_t initial_size, size_t bufmax) : outputStream() {
 952   buffer_length = initial_size;
 953   buffer        = NEW_C_HEAP_ARRAY(char, buffer_length, mtInternal);
 954   buffer_pos    = 0;
 955   buffer_fixed  = false;
 956   buffer_max    = bufmax;
 957   truncated     = false;
 958 }
 959 
 960 bufferedStream::bufferedStream(char* fixed_buffer, size_t fixed_buffer_size, size_t bufmax) : outputStream() {
 961   buffer_length = fixed_buffer_size;




   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 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "compiler/compileLog.hpp"
  28 #include "logging/logAsyncFlusher.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/arguments.hpp"
  32 #include "runtime/os.inline.hpp"
  33 #include "runtime/vm_version.hpp"
  34 #include "utilities/defaultStream.hpp"
  35 #include "utilities/macros.hpp"
  36 #include "utilities/ostream.hpp"
  37 #include "utilities/vmError.hpp"
  38 #include "utilities/xmlstream.hpp"
  39 
  40 // Declarations of jvm methods
  41 extern "C" void jio_print(const char* s, size_t len);
  42 extern "C" int jio_printf(const char *fmt, ...);
  43 
  44 outputStream::outputStream(int width) {
  45   _width       = width;
  46   _position    = 0;
  47   _newlines    = 0;
  48   _precount    = 0;


 709           // keys/values.
 710           text->print_raw(p->key());
 711           text->put('=');
 712           assert(p->value() != NULL, "p->value() is NULL");
 713           text->print_raw_cr(p->value());
 714         }
 715       }
 716       xs->tail("properties");
 717     }
 718     xs->tail("vm_arguments");
 719     // tty output per se is grouped under the <tty>...</tty> element.
 720     xs->head("tty");
 721     // All further non-markup text gets copied to the tty:
 722     xs->_text = this;  // requires friend declaration!
 723 }
 724 
 725 // finish_log() is called during normal VM shutdown. finish_log_on_error() is
 726 // called by ostream_abort() after a fatal error.
 727 //
 728 void defaultStream::finish_log() {
 729   LogAsyncFlusher::cleanup();
 730 
 731   xmlStream* xs = _outer_xmlStream;
 732   xs->done("tty");
 733 
 734   // Other log forks are appended here, at the End of Time:
 735   CompileLog::finish_log(xs->out());  // write compile logging, if any, now
 736 
 737   xs->done("hotspot_log");
 738   xs->flush();
 739 
 740   fileStream* file = _log_file;
 741   _log_file = NULL;
 742 
 743   delete _outer_xmlStream;
 744   _outer_xmlStream = NULL;
 745 
 746   file->flush();
 747   delete file;
 748 }
 749 
 750 void defaultStream::finish_log_on_error(char *buf, int buflen) {


 925   if (ostream_exit_called)  return;
 926   ostream_exit_called = true;
 927 #if INCLUDE_CDS
 928   if (classlist_file != NULL) {
 929     delete classlist_file;
 930   }
 931 #endif
 932   if (tty != defaultStream::instance) {
 933     delete tty;
 934   }
 935   if (defaultStream::instance != NULL) {
 936     delete defaultStream::instance;
 937   }
 938   tty = NULL;
 939   xtty = NULL;
 940   defaultStream::instance = NULL;
 941 }
 942 
 943 // ostream_abort() is called by os::abort() when VM is about to die.
 944 void ostream_abort() {
 945   LogAsyncFlusher::cleanup();
 946 
 947   // Here we can't delete tty, just flush its output
 948   if (tty) tty->flush();
 949 
 950   if (defaultStream::instance != NULL) {
 951     static char buf[4096];
 952     defaultStream::instance->finish_log_on_error(buf, sizeof(buf));
 953   }
 954 }
 955 
 956 bufferedStream::bufferedStream(size_t initial_size, size_t bufmax) : outputStream() {
 957   buffer_length = initial_size;
 958   buffer        = NEW_C_HEAP_ARRAY(char, buffer_length, mtInternal);
 959   buffer_pos    = 0;
 960   buffer_fixed  = false;
 961   buffer_max    = bufmax;
 962   truncated     = false;
 963 }
 964 
 965 bufferedStream::bufferedStream(char* fixed_buffer, size_t fixed_buffer_size, size_t bufmax) : outputStream() {
 966   buffer_length = fixed_buffer_size;


< prev index next >