comparison src/share/vm/utilities/ostream.cpp @ 6605:4ee06e614636

7116786: RFE: Detailed information on VerifyErrors Summary: Provide additional detail in VerifyError messages Reviewed-by: sspitsyn, acorn
author kamg
date Mon, 06 Aug 2012 15:54:45 -0400
parents d2a62e0f25eb
children c38f13903fdf c3e799c37717
comparison
equal deleted inserted replaced
6604:c3c2141203e7 6605:4ee06e614636
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, 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.
235 } 235 }
236 print_raw(suffix); 236 print_raw(suffix);
237 return; 237 return;
238 } 238 }
239 239
240 void outputStream::indent() { 240 outputStream& outputStream::indent() {
241 while (_position < _indentation) sp(); 241 while (_position < _indentation) sp();
242 return *this;
242 } 243 }
243 244
244 void outputStream::print_jlong(jlong value) { 245 void outputStream::print_jlong(jlong value) {
245 // N.B. Same as INT64_FORMAT 246 // N.B. Same as INT64_FORMAT
246 print(os::jlong_format_specifier(), value); 247 print(os::jlong_format_specifier(), value);
247 } 248 }
248 249
249 void outputStream::print_julong(julong value) { 250 void outputStream::print_julong(julong value) {
250 // N.B. Same as UINT64_FORMAT 251 // N.B. Same as UINT64_FORMAT
251 print(os::julong_format_specifier(), value); 252 print(os::julong_format_specifier(), value);
253 }
254
255 /**
256 * This prints out hex data in a 'windbg' or 'xxd' form, where each line is:
257 * <hex-address>: 8 * <hex-halfword> <ascii translation (optional)>
258 * example:
259 * 0000000: 7f44 4f46 0102 0102 0000 0000 0000 0000 .DOF............
260 * 0000010: 0000 0000 0000 0040 0000 0020 0000 0005 .......@... ....
261 * 0000020: 0000 0000 0000 0040 0000 0000 0000 015d .......@.......]
262 * ...
263 *
264 * indent is applied to each line. Ends with a CR.
265 */
266 void outputStream::print_data(void* data, size_t len, bool with_ascii) {
267 size_t limit = (len + 16) / 16 * 16;
268 for (size_t i = 0; i < limit; ++i) {
269 if (i % 16 == 0) {
270 indent().print("%07x:", i);
271 }
272 if (i % 2 == 0) {
273 print(" ");
274 }
275 if (i < len) {
276 print("%02x", ((unsigned char*)data)[i]);
277 } else {
278 print(" ");
279 }
280 if ((i + 1) % 16 == 0) {
281 if (with_ascii) {
282 print(" ");
283 for (size_t j = 0; j < 16; ++j) {
284 size_t idx = i + j - 15;
285 if (idx < len) {
286 char c = ((char*)data)[idx];
287 print("%c", c >= 32 && c <= 126 ? c : '.');
288 }
289 }
290 }
291 print_cr("");
292 }
293 }
252 } 294 }
253 295
254 stringStream::stringStream(size_t initial_size) : outputStream() { 296 stringStream::stringStream(size_t initial_size) : outputStream() {
255 buffer_length = initial_size; 297 buffer_length = initial_size;
256 buffer = NEW_RESOURCE_ARRAY(char, buffer_length); 298 buffer = NEW_RESOURCE_ARRAY(char, buffer_length);