Mercurial > hg > truffle
comparison src/share/vm/utilities/ostream.hpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 89152779163c 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. |
51 | 51 |
52 void update_position(const char* s, size_t len); | 52 void update_position(const char* s, size_t len); |
53 static const char* do_vsnprintf(char* buffer, size_t buflen, | 53 static const char* do_vsnprintf(char* buffer, size_t buflen, |
54 const char* format, va_list ap, | 54 const char* format, va_list ap, |
55 bool add_cr, | 55 bool add_cr, |
56 size_t& result_len); | 56 size_t& result_len) ATTRIBUTE_PRINTF(3, 0); |
57 | 57 |
58 public: | 58 public: |
59 // creation | 59 // creation |
60 outputStream(int width = 80); | 60 outputStream(int width = 80); |
61 outputStream(int width, bool has_time_stamps); | 61 outputStream(int width, bool has_time_stamps); |
78 julong count() const { return _precount + _position; } | 78 julong count() const { return _precount + _position; } |
79 void set_count(julong count) { _precount = count - _position; } | 79 void set_count(julong count) { _precount = count - _position; } |
80 void set_position(int pos) { _position = pos; } | 80 void set_position(int pos) { _position = pos; } |
81 | 81 |
82 // printing | 82 // printing |
83 void print(const char* format, ...); | 83 void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
84 void print_cr(const char* format, ...); | 84 void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
85 void vprint(const char *format, va_list argptr); | 85 void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); |
86 void vprint_cr(const char* format, va_list argptr); | 86 void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); |
87 void print_raw(const char* str) { write(str, strlen(str)); } | 87 void print_raw(const char* str) { write(str, strlen(str)); } |
88 void print_raw(const char* str, int len) { write(str, len); } | 88 void print_raw(const char* str, int len) { write(str, len); } |
89 void print_raw_cr(const char* str) { write(str, strlen(str)); cr(); } | 89 void print_raw_cr(const char* str) { write(str, strlen(str)); cr(); } |
90 void print_raw_cr(const char* str, int len){ write(str, len); cr(); } | 90 void print_raw_cr(const char* str, int len){ write(str, len); cr(); } |
91 void print_data(void* data, size_t len, bool with_ascii); | 91 void print_data(void* data, size_t len, bool with_ascii); |
113 void print_julong(julong value); | 113 void print_julong(julong value); |
114 | 114 |
115 // flushing | 115 // flushing |
116 virtual void flush() {} | 116 virtual void flush() {} |
117 virtual void write(const char* str, size_t len) = 0; | 117 virtual void write(const char* str, size_t len) = 0; |
118 virtual void rotate_log() {} // GC log rotation | 118 virtual void rotate_log(bool force, outputStream* out = NULL) {} // GC log rotation |
119 virtual ~outputStream() {} // close properly on deletion | 119 virtual ~outputStream() {} // close properly on deletion |
120 | 120 |
121 void dec_cr() { dec(); cr(); } | 121 void dec_cr() { dec(); cr(); } |
122 void inc_cr() { inc(); cr(); } | 122 void inc_cr() { inc(); cr(); } |
123 }; | 123 }; |
238 uintx _cur_file_num; // current logfile rotation number, from 0 to NumberOfGCLogFiles-1 | 238 uintx _cur_file_num; // current logfile rotation number, from 0 to NumberOfGCLogFiles-1 |
239 public: | 239 public: |
240 gcLogFileStream(const char* file_name); | 240 gcLogFileStream(const char* file_name); |
241 ~gcLogFileStream(); | 241 ~gcLogFileStream(); |
242 virtual void write(const char* c, size_t len); | 242 virtual void write(const char* c, size_t len); |
243 virtual void rotate_log(); | 243 virtual void rotate_log(bool force, outputStream* out = NULL); |
244 void dump_loggc_header(); | 244 void dump_loggc_header(); |
245 | |
246 /* If "force" sets true, force log file rotation from outside JVM */ | |
247 bool should_rotate(bool force) { | |
248 return force || | |
249 ((GCLogFileSize != 0) && ((uintx)_bytes_written >= GCLogFileSize)); | |
250 } | |
251 | |
245 }; | 252 }; |
246 | 253 |
247 #ifndef PRODUCT | 254 #ifndef PRODUCT |
248 // unit test for checking -Xloggc:<filename> parsing result | 255 // unit test for checking -Xloggc:<filename> parsing result |
249 void test_loggc_filename(); | 256 void test_loggc_filename(); |
266 staticBufferStream(char* buffer, size_t buflen, | 273 staticBufferStream(char* buffer, size_t buflen, |
267 outputStream *outer_stream); | 274 outputStream *outer_stream); |
268 ~staticBufferStream() {}; | 275 ~staticBufferStream() {}; |
269 virtual void write(const char* c, size_t len); | 276 virtual void write(const char* c, size_t len); |
270 void flush(); | 277 void flush(); |
271 void print(const char* format, ...); | 278 void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
272 void print_cr(const char* format, ...); | 279 void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
273 void vprint(const char *format, va_list argptr); | 280 void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); |
274 void vprint_cr(const char* format, va_list argptr); | 281 void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); |
275 }; | 282 }; |
276 | 283 |
277 // In the non-fixed buffer case an underlying buffer will be created and | 284 // In the non-fixed buffer case an underlying buffer will be created and |
278 // managed in C heap. Not MT-safe. | 285 // managed in C heap. Not MT-safe. |
279 class bufferedStream : public outputStream { | 286 class bufferedStream : public outputStream { |