< prev index next >

src/share/vm/utilities/debug.cpp

Print this page




 198 
 199 #undef is_token_break
 200 
 201 #else
 202 
 203 // Place-holder for non-existent suppression check:
 204 #define error_is_suppressed(file_name, line_no) (false)
 205 
 206 #endif // !PRODUCT
 207 
 208 void report_vm_error(const char* file, int line, const char* error_msg)
 209 {
 210   report_vm_error(file, line, error_msg, "%s", "");
 211 }
 212 
 213 void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...)
 214 {
 215   if (Debugging || error_is_suppressed(file, line)) return;
 216   va_list detail_args;
 217   va_start(detail_args, detail_fmt);
 218   VMError::report_and_die(ThreadLocalStorage::get_thread_slow(), file, line, error_msg, detail_fmt, detail_args);
 219   va_end(detail_args);
 220 }
 221 
 222 void report_fatal(const char* file, int line, const char* detail_fmt, ...)
 223 {
 224   if (Debugging || error_is_suppressed(file, line)) return;
 225   va_list detail_args;
 226   va_start(detail_args, detail_fmt);
 227   VMError::report_and_die(ThreadLocalStorage::get_thread_slow(), file, line, "fatal error", detail_fmt, detail_args);
 228   va_end(detail_args);
 229 }
 230 
 231 void report_vm_out_of_memory(const char* file, int line, size_t size,
 232                              VMErrorType vm_err_type, const char* detail_fmt, ...) {
 233   if (Debugging) return;
 234   va_list detail_args;
 235   va_start(detail_args, detail_fmt);
 236   VMError::report_and_die(ThreadLocalStorage::get_thread_slow(), file, line, size, vm_err_type, detail_fmt, detail_args);
 237   va_end(detail_args);
 238 
 239   // The UseOSErrorReporting option in report_and_die() may allow a return
 240   // to here. If so then we'll have to figure out how to handle it.
 241   guarantee(false, "report_and_die() should not return here");
 242 }
 243 
 244 void report_should_not_call(const char* file, int line) {
 245   report_vm_error(file, line, "ShouldNotCall()");
 246 }
 247 
 248 void report_should_not_reach_here(const char* file, int line) {
 249   report_vm_error(file, line, "ShouldNotReachHere()");
 250 }
 251 
 252 void report_unimplemented(const char* file, int line) {
 253   report_vm_error(file, line, "Unimplemented()");
 254 }
 255 
 256 void report_untested(const char* file, int line, const char* message) {


 519 extern "C" void pp(void* p) {
 520   Command c("pp");
 521   FlagSetting fl(PrintVMMessages, true);
 522   FlagSetting f2(DisplayVMOutput, true);
 523   if (Universe::heap()->is_in(p)) {
 524     oop obj = oop(p);
 525     obj->print();
 526   } else {
 527     tty->print(PTR_FORMAT, p2i(p));
 528   }
 529 }
 530 
 531 
 532 // pv: print vm-printable object
 533 extern "C" void pa(intptr_t p)   { ((AllocatedObj*) p)->print(); }
 534 extern "C" void findpc(intptr_t x);
 535 
 536 #endif // !PRODUCT
 537 
 538 extern "C" void ps() { // print stack
 539   if (Thread::current() == NULL) return;
 540   Command c("ps");
 541 
 542 
 543   // Prints the stack of the current Java thread
 544   JavaThread* p = JavaThread::active();
 545   tty->print(" for thread: ");
 546   p->print();
 547   tty->cr();
 548 
 549   if (p->has_last_Java_frame()) {
 550     // If the last_Java_fp is set we are in C land and
 551     // can call the standard stack_trace function.
 552 #ifdef PRODUCT
 553     p->print_stack();
 554   } else {
 555     tty->print_cr("Cannot find the last Java frame, printing stack disabled.");
 556 #else // !PRODUCT
 557     p->trace_stack();
 558   } else {
 559     frame f = os::current_frame();


 598 extern "C" void threads() {
 599   Command c("threads");
 600   Threads::print(false, true);
 601 }
 602 
 603 
 604 extern "C" void psd() {
 605   Command c("psd");
 606   SystemDictionary::print();
 607 }
 608 
 609 
 610 extern "C" void safepoints() {
 611   Command c("safepoints");
 612   SafepointSynchronize::print_state();
 613 }
 614 
 615 #endif // !PRODUCT
 616 
 617 extern "C" void pss() { // print all stacks
 618   if (Thread::current() == NULL) return;
 619   Command c("pss");
 620   Threads::print(true, PRODUCT_ONLY(false) NOT_PRODUCT(true));
 621 }
 622 
 623 #ifndef PRODUCT
 624 
 625 extern "C" void debug() {               // to set things up for compiler debugging
 626   Command c("debug");
 627   WizardMode = true;
 628   PrintVMMessages = PrintCompilation = true;
 629   PrintInlining = PrintAssembly = true;
 630   tty->flush();
 631 }
 632 
 633 
 634 extern "C" void ndebug() {              // undo debug()
 635   Command c("ndebug");
 636   PrintCompilation = false;
 637   PrintInlining = PrintAssembly = false;
 638   tty->flush();


 755         // is_first_C_frame() does only simple checks for frame pointer,
 756         // it will pass if java compiled code has a pointer in EBP.
 757         if (os::is_first_C_frame(&fr)) break;
 758         fr = os::get_sender_for_C_frame(&fr);
 759       }
 760     }
 761 
 762     if (count > StackPrintLimit) {
 763       st->print_cr("...<more frames>...");
 764     }
 765 
 766     st->cr();
 767   }
 768 }
 769 
 770 #ifndef PRODUCT
 771 
 772 extern "C" void pns(void* sp, void* fp, void* pc) { // print native stack
 773   Command c("pns");
 774   static char buf[O_BUFLEN];
 775   Thread* t = ThreadLocalStorage::get_thread_slow();
 776   // Call generic frame constructor (certain arguments may be ignored)
 777   frame fr(sp, fp, pc);
 778   print_native_stack(tty, fr, t, buf, sizeof(buf));
 779 }
 780 
 781 #endif // !PRODUCT
 782 
 783 //////////////////////////////////////////////////////////////////////////////
 784 // Test multiple STATIC_ASSERT forms in various scopes.
 785 
 786 #ifndef PRODUCT
 787 
 788 // namespace scope
 789 STATIC_ASSERT(true);
 790 STATIC_ASSERT(true);
 791 STATIC_ASSERT(1 == 1);
 792 STATIC_ASSERT(0 == 0);
 793 
 794 void test_multiple_static_assert_forms_in_function_scope() {
 795   STATIC_ASSERT(true);


 198 
 199 #undef is_token_break
 200 
 201 #else
 202 
 203 // Place-holder for non-existent suppression check:
 204 #define error_is_suppressed(file_name, line_no) (false)
 205 
 206 #endif // !PRODUCT
 207 
 208 void report_vm_error(const char* file, int line, const char* error_msg)
 209 {
 210   report_vm_error(file, line, error_msg, "%s", "");
 211 }
 212 
 213 void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...)
 214 {
 215   if (Debugging || error_is_suppressed(file, line)) return;
 216   va_list detail_args;
 217   va_start(detail_args, detail_fmt);
 218   VMError::report_and_die(Thread::current_or_null(), file, line, error_msg, detail_fmt, detail_args);
 219   va_end(detail_args);
 220 }
 221 
 222 void report_fatal(const char* file, int line, const char* detail_fmt, ...)
 223 {
 224   if (Debugging || error_is_suppressed(file, line)) return;
 225   va_list detail_args;
 226   va_start(detail_args, detail_fmt);
 227   VMError::report_and_die(Thread::current_or_null(), file, line, "fatal error", detail_fmt, detail_args);
 228   va_end(detail_args);
 229 }
 230 
 231 void report_vm_out_of_memory(const char* file, int line, size_t size,
 232                              VMErrorType vm_err_type, const char* detail_fmt, ...) {
 233   if (Debugging) return;
 234   va_list detail_args;
 235   va_start(detail_args, detail_fmt);
 236   VMError::report_and_die(Thread::current_or_null(), file, line, size, vm_err_type, detail_fmt, detail_args);
 237   va_end(detail_args);
 238 
 239   // The UseOSErrorReporting option in report_and_die() may allow a return
 240   // to here. If so then we'll have to figure out how to handle it.
 241   guarantee(false, "report_and_die() should not return here");
 242 }
 243 
 244 void report_should_not_call(const char* file, int line) {
 245   report_vm_error(file, line, "ShouldNotCall()");
 246 }
 247 
 248 void report_should_not_reach_here(const char* file, int line) {
 249   report_vm_error(file, line, "ShouldNotReachHere()");
 250 }
 251 
 252 void report_unimplemented(const char* file, int line) {
 253   report_vm_error(file, line, "Unimplemented()");
 254 }
 255 
 256 void report_untested(const char* file, int line, const char* message) {


 519 extern "C" void pp(void* p) {
 520   Command c("pp");
 521   FlagSetting fl(PrintVMMessages, true);
 522   FlagSetting f2(DisplayVMOutput, true);
 523   if (Universe::heap()->is_in(p)) {
 524     oop obj = oop(p);
 525     obj->print();
 526   } else {
 527     tty->print(PTR_FORMAT, p2i(p));
 528   }
 529 }
 530 
 531 
 532 // pv: print vm-printable object
 533 extern "C" void pa(intptr_t p)   { ((AllocatedObj*) p)->print(); }
 534 extern "C" void findpc(intptr_t x);
 535 
 536 #endif // !PRODUCT
 537 
 538 extern "C" void ps() { // print stack
 539   if (Thread::current_or_null() == NULL) return;
 540   Command c("ps");
 541 
 542 
 543   // Prints the stack of the current Java thread
 544   JavaThread* p = JavaThread::active();
 545   tty->print(" for thread: ");
 546   p->print();
 547   tty->cr();
 548 
 549   if (p->has_last_Java_frame()) {
 550     // If the last_Java_fp is set we are in C land and
 551     // can call the standard stack_trace function.
 552 #ifdef PRODUCT
 553     p->print_stack();
 554   } else {
 555     tty->print_cr("Cannot find the last Java frame, printing stack disabled.");
 556 #else // !PRODUCT
 557     p->trace_stack();
 558   } else {
 559     frame f = os::current_frame();


 598 extern "C" void threads() {
 599   Command c("threads");
 600   Threads::print(false, true);
 601 }
 602 
 603 
 604 extern "C" void psd() {
 605   Command c("psd");
 606   SystemDictionary::print();
 607 }
 608 
 609 
 610 extern "C" void safepoints() {
 611   Command c("safepoints");
 612   SafepointSynchronize::print_state();
 613 }
 614 
 615 #endif // !PRODUCT
 616 
 617 extern "C" void pss() { // print all stacks
 618   if (Thread::current_or_null() == NULL) return;
 619   Command c("pss");
 620   Threads::print(true, PRODUCT_ONLY(false) NOT_PRODUCT(true));
 621 }
 622 
 623 #ifndef PRODUCT
 624 
 625 extern "C" void debug() {               // to set things up for compiler debugging
 626   Command c("debug");
 627   WizardMode = true;
 628   PrintVMMessages = PrintCompilation = true;
 629   PrintInlining = PrintAssembly = true;
 630   tty->flush();
 631 }
 632 
 633 
 634 extern "C" void ndebug() {              // undo debug()
 635   Command c("ndebug");
 636   PrintCompilation = false;
 637   PrintInlining = PrintAssembly = false;
 638   tty->flush();


 755         // is_first_C_frame() does only simple checks for frame pointer,
 756         // it will pass if java compiled code has a pointer in EBP.
 757         if (os::is_first_C_frame(&fr)) break;
 758         fr = os::get_sender_for_C_frame(&fr);
 759       }
 760     }
 761 
 762     if (count > StackPrintLimit) {
 763       st->print_cr("...<more frames>...");
 764     }
 765 
 766     st->cr();
 767   }
 768 }
 769 
 770 #ifndef PRODUCT
 771 
 772 extern "C" void pns(void* sp, void* fp, void* pc) { // print native stack
 773   Command c("pns");
 774   static char buf[O_BUFLEN];
 775   Thread* t = Thread::current_or_null();
 776   // Call generic frame constructor (certain arguments may be ignored)
 777   frame fr(sp, fp, pc);
 778   print_native_stack(tty, fr, t, buf, sizeof(buf));
 779 }
 780 
 781 #endif // !PRODUCT
 782 
 783 //////////////////////////////////////////////////////////////////////////////
 784 // Test multiple STATIC_ASSERT forms in various scopes.
 785 
 786 #ifndef PRODUCT
 787 
 788 // namespace scope
 789 STATIC_ASSERT(true);
 790 STATIC_ASSERT(true);
 791 STATIC_ASSERT(1 == 1);
 792 STATIC_ASSERT(0 == 0);
 793 
 794 void test_multiple_static_assert_forms_in_function_scope() {
 795   STATIC_ASSERT(true);
< prev index next >