comparison src/share/vm/interpreter/bytecodeTracer.cpp @ 17937:78bbf4d43a14

8037816: Fix for 8036122 breaks build with Xcode5/clang 8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas 8043164: Format warning in traceStream.hpp Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings Reviewed-by: kvn, coleenp, iveresov, twisti
author drchase
date Thu, 22 May 2014 15:52:41 -0400
parents b8413a9cbb84
children 52b4284cb496
comparison
equal deleted inserted replaced
17935:7384f6a12fc1 17937:78bbf4d43a14
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.
213 st->print_cr(" %s...[%d]", buf, len); 213 st->print_cr(" %s...[%d]", buf, len);
214 } else { 214 } else {
215 st->print_cr(" %s", buf); 215 st->print_cr(" %s", buf);
216 } 216 }
217 } else { 217 } else {
218 st->print_cr(" " PTR_FORMAT, (void *)value); 218 st->print_cr(" " PTR_FORMAT, p2i((void *)value));
219 } 219 }
220 } 220 }
221 221
222 bool BytecodePrinter::check_index(int i, int& cp_index, outputStream* st) { 222 bool BytecodePrinter::check_index(int i, int& cp_index, outputStream* st) {
223 ConstantPool* constants = method()->constants(); 223 ConstantPool* constants = method()->constants();
282 } 282 }
283 #endif //ASSERT 283 #endif //ASSERT
284 if (i >= 0 && i < climit) { 284 if (i >= 0 && i < climit) {
285 cp_index = cache->entry_at(i)->constant_pool_index(); 285 cp_index = cache->entry_at(i)->constant_pool_index();
286 } else { 286 } else {
287 st->print_cr(" not in CP[*]?", i); 287 st->print_cr("%d not in CP[*]?", i);
288 return false; 288 return false;
289 } 289 }
290 return true; 290 return true;
291 } 291 }
292 292
297 297
298 if (i >= 0 && i < constants->resolved_references()->length()) { 298 if (i >= 0 && i < constants->resolved_references()->length()) {
299 cp_index = constants->object_to_cp_index(i); 299 cp_index = constants->object_to_cp_index(i);
300 return true; 300 return true;
301 } else { 301 } else {
302 st->print_cr(" not in OBJ[*]?", i); 302 st->print_cr("%d not in OBJ[*]?", i);
303 return false; 303 return false;
304 } 304 }
305 } 305 }
306 306
307 307
321 constantTag tag = constants->tag_at(i); 321 constantTag tag = constants->tag_at(i);
322 322
323 if (tag.is_int()) { 323 if (tag.is_int()) {
324 st->print_cr(" " INT32_FORMAT, constants->int_at(i)); 324 st->print_cr(" " INT32_FORMAT, constants->int_at(i));
325 } else if (tag.is_long()) { 325 } else if (tag.is_long()) {
326 st->print_cr(" " INT64_FORMAT, constants->long_at(i)); 326 st->print_cr(" " INT64_FORMAT, (int64_t)(constants->long_at(i)));
327 } else if (tag.is_float()) { 327 } else if (tag.is_float()) {
328 st->print_cr(" %f", constants->float_at(i)); 328 st->print_cr(" %f", constants->float_at(i));
329 } else if (tag.is_double()) { 329 } else if (tag.is_double()) {
330 st->print_cr(" %f", constants->double_at(i)); 330 st->print_cr(" %f", constants->double_at(i));
331 } else if (tag.is_string()) { 331 } else if (tag.is_string()) {
340 st->print(" <MethodType> %d", i2); 340 st->print(" <MethodType> %d", i2);
341 print_symbol(constants->symbol_at(i2), st); 341 print_symbol(constants->symbol_at(i2), st);
342 } else if (tag.is_method_handle()) { 342 } else if (tag.is_method_handle()) {
343 int kind = constants->method_handle_ref_kind_at(i); 343 int kind = constants->method_handle_ref_kind_at(i);
344 int i2 = constants->method_handle_index_at(i); 344 int i2 = constants->method_handle_index_at(i);
345 st->print(" <MethodHandle of kind %d>", kind, i2); 345 st->print(" <MethodHandle of kind %d index at %d>", kind, i2);
346 print_field_or_method(-i, i2, st); 346 print_field_or_method(-i, i2, st);
347 } else { 347 } else {
348 st->print_cr(" bad tag=%d at %d", tag.value(), i); 348 st->print_cr(" bad tag=%d at %d", tag.value(), i);
349 } 349 }
350 } 350 }
389 st->print_cr(" %d <%s%s%s>", i, name->as_C_string(), sep, signature->as_C_string()); 389 st->print_cr(" %d <%s%s%s>", i, name->as_C_string(), sep, signature->as_C_string());
390 } 390 }
391 } 391 }
392 392
393 393
394 PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL
394 void BytecodePrinter::print_attributes(int bci, outputStream* st) { 395 void BytecodePrinter::print_attributes(int bci, outputStream* st) {
395 // Show attributes of pre-rewritten codes 396 // Show attributes of pre-rewritten codes
396 Bytecodes::Code code = Bytecodes::java_code(raw_code()); 397 Bytecodes::Code code = Bytecodes::java_code(raw_code());
397 // If the code doesn't have any fields there's nothing to print. 398 // If the code doesn't have any fields there's nothing to print.
398 // note this is ==1 because the tableswitch and lookupswitch are 399 // note this is ==1 because the tableswitch and lookupswitch are
515 int first = true; 516 int first = true;
516 for (int ll = lo; ll <= hi; ll++, first = false) { 517 for (int ll = lo; ll <= hi; ll++, first = false) {
517 int idx = ll - lo; 518 int idx = ll - lo;
518 const char *format = first ? " %d:" INT32_FORMAT " (delta: %d)" : 519 const char *format = first ? " %d:" INT32_FORMAT " (delta: %d)" :
519 ", %d:" INT32_FORMAT " (delta: %d)"; 520 ", %d:" INT32_FORMAT " (delta: %d)";
521 PRAGMA_DIAG_PUSH
522 PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
520 st->print(format, ll, dest[idx], dest[idx]-bci); 523 st->print(format, ll, dest[idx], dest[idx]-bci);
524 PRAGMA_DIAG_POP
521 } 525 }
522 st->cr(); 526 st->cr();
523 } 527 }
524 break; 528 break;
525 case Bytecodes::_lookupswitch: 529 case Bytecodes::_lookupswitch:
535 st->print(" %d %d ", default_dest, len); 539 st->print(" %d %d ", default_dest, len);
536 bool first = true; 540 bool first = true;
537 for (int ll = 0; ll < len; ll++, first = false) { 541 for (int ll = 0; ll < len; ll++, first = false) {
538 const char *format = first ? " " INT32_FORMAT ":" INT32_FORMAT : 542 const char *format = first ? " " INT32_FORMAT ":" INT32_FORMAT :
539 ", " INT32_FORMAT ":" INT32_FORMAT ; 543 ", " INT32_FORMAT ":" INT32_FORMAT ;
544 PRAGMA_DIAG_PUSH
545 PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
540 st->print(format, key[ll], dest[ll]); 546 st->print(format, key[ll], dest[ll]);
547 PRAGMA_DIAG_POP
541 } 548 }
542 st->cr(); 549 st->cr();
543 } 550 }
544 break; 551 break;
545 552