Mercurial > hg > truffle
comparison src/share/vm/utilities/ostream.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4ca6dc0799b6 78bbf4d43a14 |
children | 7848fc12602b |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
36 #ifdef TARGET_OS_FAMILY_solaris | 36 #ifdef TARGET_OS_FAMILY_solaris |
37 # include "os_solaris.inline.hpp" | 37 # include "os_solaris.inline.hpp" |
38 #endif | 38 #endif |
39 #ifdef TARGET_OS_FAMILY_windows | 39 #ifdef TARGET_OS_FAMILY_windows |
40 # include "os_windows.inline.hpp" | 40 # include "os_windows.inline.hpp" |
41 #endif | |
42 #ifdef TARGET_OS_FAMILY_aix | |
43 # include "os_aix.inline.hpp" | |
41 #endif | 44 #endif |
42 #ifdef TARGET_OS_FAMILY_bsd | 45 #ifdef TARGET_OS_FAMILY_bsd |
43 # include "os_bsd.inline.hpp" | 46 # include "os_bsd.inline.hpp" |
44 #endif | 47 #endif |
45 | 48 |
263 */ | 266 */ |
264 void outputStream::print_data(void* data, size_t len, bool with_ascii) { | 267 void outputStream::print_data(void* data, size_t len, bool with_ascii) { |
265 size_t limit = (len + 16) / 16 * 16; | 268 size_t limit = (len + 16) / 16 * 16; |
266 for (size_t i = 0; i < limit; ++i) { | 269 for (size_t i = 0; i < limit; ++i) { |
267 if (i % 16 == 0) { | 270 if (i % 16 == 0) { |
268 indent().print("%07x:", i); | 271 indent().print(SIZE_FORMAT_HEX_W(07)":", i); |
269 } | 272 } |
270 if (i % 2 == 0) { | 273 if (i % 2 == 0) { |
271 print(" "); | 274 print(" "); |
272 } | 275 } |
273 if (i < len) { | 276 if (i < len) { |
284 char c = ((char*)data)[idx]; | 287 char c = ((char*)data)[idx]; |
285 print("%c", c >= 32 && c <= 126 ? c : '.'); | 288 print("%c", c >= 32 && c <= 126 ? c : '.'); |
286 } | 289 } |
287 } | 290 } |
288 } | 291 } |
289 print_cr(""); | 292 cr(); |
290 } | 293 } |
291 } | 294 } |
292 } | 295 } |
293 | 296 |
294 stringStream::stringStream(size_t initial_size) : outputStream() { | 297 stringStream::stringStream(size_t initial_size) : outputStream() { |
601 | 604 |
602 // dump vm version, os version, platform info, build id, | 605 // dump vm version, os version, platform info, build id, |
603 // memory usage and command line flags into header | 606 // memory usage and command line flags into header |
604 void gcLogFileStream::dump_loggc_header() { | 607 void gcLogFileStream::dump_loggc_header() { |
605 if (is_open()) { | 608 if (is_open()) { |
606 print_cr(Abstract_VM_Version::internal_vm_info_string()); | 609 print_cr("%s", Abstract_VM_Version::internal_vm_info_string()); |
607 os::print_memory_info(this); | 610 os::print_memory_info(this); |
608 print("CommandLine flags: "); | 611 print("CommandLine flags: "); |
609 CommandLineFlags::printSetFlags(this); | 612 CommandLineFlags::printSetFlags(this); |
610 } | 613 } |
611 } | 614 } |
657 // function directly. Currently, it is safe to rotate log at safepoint through VMThread. | 660 // function directly. Currently, it is safe to rotate log at safepoint through VMThread. |
658 // That is, no mutator threads and concurrent GC threads run parallel with VMThread to | 661 // That is, no mutator threads and concurrent GC threads run parallel with VMThread to |
659 // write to gc log file at safepoint. If in future, changes made for mutator threads or | 662 // write to gc log file at safepoint. If in future, changes made for mutator threads or |
660 // concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log | 663 // concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log |
661 // must be synchronized. | 664 // must be synchronized. |
662 void gcLogFileStream::rotate_log() { | 665 void gcLogFileStream::rotate_log(bool force, outputStream* out) { |
663 char time_msg[FILENAMEBUFLEN]; | 666 char time_msg[FILENAMEBUFLEN]; |
664 char time_str[EXTRACHARLEN]; | 667 char time_str[EXTRACHARLEN]; |
665 char current_file_name[FILENAMEBUFLEN]; | 668 char current_file_name[FILENAMEBUFLEN]; |
666 char renamed_file_name[FILENAMEBUFLEN]; | 669 char renamed_file_name[FILENAMEBUFLEN]; |
667 | 670 |
668 if (_bytes_written < (jlong)GCLogFileSize) { | 671 if (!should_rotate(force)) { |
669 return; | 672 return; |
670 } | 673 } |
671 | 674 |
672 #ifdef ASSERT | 675 #ifdef ASSERT |
673 Thread *thread = Thread::current(); | 676 Thread *thread = Thread::current(); |
680 rewind(); | 683 rewind(); |
681 _bytes_written = 0L; | 684 _bytes_written = 0L; |
682 jio_snprintf(time_msg, sizeof(time_msg), "File %s rotated at %s\n", | 685 jio_snprintf(time_msg, sizeof(time_msg), "File %s rotated at %s\n", |
683 _file_name, os::local_time_string((char *)time_str, sizeof(time_str))); | 686 _file_name, os::local_time_string((char *)time_str, sizeof(time_str))); |
684 write(time_msg, strlen(time_msg)); | 687 write(time_msg, strlen(time_msg)); |
688 | |
689 if (out != NULL) { | |
690 out->print("%s", time_msg); | |
691 } | |
692 | |
685 dump_loggc_header(); | 693 dump_loggc_header(); |
686 return; | 694 return; |
687 } | 695 } |
688 | 696 |
689 #if defined(_WINDOWS) | 697 #if defined(_WINDOWS) |
701 if (_file != NULL) { | 709 if (_file != NULL) { |
702 jio_snprintf(renamed_file_name, filename_len + EXTRACHARLEN, "%s.%d", | 710 jio_snprintf(renamed_file_name, filename_len + EXTRACHARLEN, "%s.%d", |
703 _file_name, _cur_file_num); | 711 _file_name, _cur_file_num); |
704 jio_snprintf(current_file_name, filename_len + EXTRACHARLEN, "%s.%d" CURRENTAPPX, | 712 jio_snprintf(current_file_name, filename_len + EXTRACHARLEN, "%s.%d" CURRENTAPPX, |
705 _file_name, _cur_file_num); | 713 _file_name, _cur_file_num); |
706 jio_snprintf(time_msg, sizeof(time_msg), "%s GC log file has reached the" | 714 |
707 " maximum size. Saved as %s\n", | 715 const char* msg = force ? "GC log rotation request has been received." |
708 os::local_time_string((char *)time_str, sizeof(time_str)), | 716 : "GC log file has reached the maximum size."; |
709 renamed_file_name); | 717 jio_snprintf(time_msg, sizeof(time_msg), "%s %s Saved as %s\n", |
718 os::local_time_string((char *)time_str, sizeof(time_str)), | |
719 msg, renamed_file_name); | |
710 write(time_msg, strlen(time_msg)); | 720 write(time_msg, strlen(time_msg)); |
721 | |
722 if (out != NULL) { | |
723 out->print("%s", time_msg); | |
724 } | |
711 | 725 |
712 fclose(_file); | 726 fclose(_file); |
713 _file = NULL; | 727 _file = NULL; |
714 | 728 |
715 bool can_rename = true; | 729 bool can_rename = true; |
747 "%s.%d", _file_name, _cur_file_num); | 761 "%s.%d", _file_name, _cur_file_num); |
748 jio_snprintf(time_msg, sizeof(time_msg), "%s GC log file created %s\n", | 762 jio_snprintf(time_msg, sizeof(time_msg), "%s GC log file created %s\n", |
749 os::local_time_string((char *)time_str, sizeof(time_str)), | 763 os::local_time_string((char *)time_str, sizeof(time_str)), |
750 current_file_name); | 764 current_file_name); |
751 write(time_msg, strlen(time_msg)); | 765 write(time_msg, strlen(time_msg)); |
766 | |
767 if (out != NULL) { | |
768 out->print("%s", time_msg); | |
769 } | |
770 | |
752 dump_loggc_header(); | 771 dump_loggc_header(); |
753 // remove the existing file | 772 // remove the existing file |
754 if (access(current_file_name, F_OK) == 0) { | 773 if (access(current_file_name, F_OK) == 0) { |
755 if (remove(current_file_name) != 0) { | 774 if (remove(current_file_name) != 0) { |
756 warning("Could not delete existing file %s\n", current_file_name); | 775 warning("Could not delete existing file %s\n", current_file_name); |
824 // %%% Should be: jlong time_ms = os::start_time_milliseconds(), if | 843 // %%% Should be: jlong time_ms = os::start_time_milliseconds(), if |
825 // we ever get round to introduce that method on the os class | 844 // we ever get round to introduce that method on the os class |
826 xs->head("hotspot_log version='%d %d'" | 845 xs->head("hotspot_log version='%d %d'" |
827 " process='%d' time_ms='"INT64_FORMAT"'", | 846 " process='%d' time_ms='"INT64_FORMAT"'", |
828 LOG_MAJOR_VERSION, LOG_MINOR_VERSION, | 847 LOG_MAJOR_VERSION, LOG_MINOR_VERSION, |
829 os::current_process_id(), time_ms); | 848 os::current_process_id(), (int64_t)time_ms); |
830 // Write VM version header immediately. | 849 // Write VM version header immediately. |
831 xs->head("vm_version"); | 850 xs->head("vm_version"); |
832 xs->head("name"); xs->text("%s", VM_Version::vm_name()); xs->cr(); | 851 xs->head("name"); xs->text("%s", VM_Version::vm_name()); xs->cr(); |
833 xs->tail("name"); | 852 xs->tail("name"); |
834 xs->head("release"); xs->text("%s", VM_Version::vm_release()); xs->cr(); | 853 xs->head("release"); xs->text("%s", VM_Version::vm_release()); xs->cr(); |
1236 } | 1255 } |
1237 } | 1256 } |
1238 | 1257 |
1239 #ifndef PRODUCT | 1258 #ifndef PRODUCT |
1240 | 1259 |
1241 #if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE) | 1260 #if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE) |
1242 #include <sys/types.h> | 1261 #include <sys/types.h> |
1243 #include <sys/socket.h> | 1262 #include <sys/socket.h> |
1244 #include <netinet/in.h> | 1263 #include <netinet/in.h> |
1245 #include <arpa/inet.h> | 1264 #include <arpa/inet.h> |
1246 #endif | 1265 #endif |