< prev index next >

src/share/vm/utilities/debug.cpp

Print this page
rev 13109 : imported patch move_pns


 566 // pv: print vm-printable object
 567 extern "C" void pa(intptr_t p)   { ((AllocatedObj*) p)->print(); }
 568 extern "C" void findpc(intptr_t x);
 569 
 570 #endif // !PRODUCT
 571 
 572 extern "C" void ps() { // print stack
 573   if (Thread::current_or_null() == NULL) return;
 574   Command c("ps");
 575 
 576 
 577   // Prints the stack of the current Java thread
 578   JavaThread* p = JavaThread::active();
 579   tty->print(" for thread: ");
 580   p->print();
 581   tty->cr();
 582 
 583   if (p->has_last_Java_frame()) {
 584     // If the last_Java_fp is set we are in C land and
 585     // can call the standard stack_trace function.
 586 #ifdef PRODUCT
 587     p->print_stack();
 588   } else {

 589     tty->print_cr("Cannot find the last Java frame, printing stack disabled.");
 590 #else // !PRODUCT
 591     p->trace_stack();
 592   } else {
 593     frame f = os::current_frame();
 594     RegisterMap reg_map(p);
 595     f = f.sender(&reg_map);
 596     tty->print("(guessing starting frame id=" PTR_FORMAT " based on current fp)\n", p2i(f.id()));
 597     p->trace_stack_from(vframe::new_vframe(&f, &reg_map, p));
 598   pd_ps(f);
 599 #endif // PRODUCT
 600   }
 601 
 602 }
 603 
 604 extern "C" void pfl() {
 605   // print frame layout
 606   Command c("pfl");
 607   JavaThread* p = JavaThread::active();
 608   tty->print(" for thread: ");
 609   p->print();
 610   tty->cr();
 611   if (p->has_last_Java_frame()) {
 612     p->print_frame_layout();


 742   tty->print_cr("  findm(intptr_t pc) - finds Method*");
 743   tty->print_cr("  find(intptr_t x)   - finds & prints nmethod/stub/bytecode/oop based on pointer into it");
 744   tty->print_cr("  pns(void* sp, void* fp, void* pc)  - print native (i.e. mixed) stack trace. E.g.");
 745   tty->print_cr("                   pns($sp, $rbp, $pc) on Linux/amd64 and Solaris/amd64 or");
 746   tty->print_cr("                   pns($sp, $ebp, $pc) on Linux/x86 or");
 747   tty->print_cr("                   pns($sp, 0, $pc)    on Linux/ppc64 or");
 748   tty->print_cr("                   pns($sp + 0x7ff, 0, $pc) on Solaris/SPARC");
 749   tty->print_cr("                 - in gdb do 'set overload-resolution off' before calling pns()");
 750   tty->print_cr("                 - in dbx do 'frame 1' before calling pns()");
 751 
 752   tty->print_cr("misc.");
 753   tty->print_cr("  flush()       - flushes the log file");
 754   tty->print_cr("  events()      - dump events from ring buffers");
 755 
 756 
 757   tty->print_cr("compiler debugging");
 758   tty->print_cr("  debug()       - to set things up for compiler debugging");
 759   tty->print_cr("  ndebug()      - undo debug");
 760 }
 761 
 762 #endif // !PRODUCT
 763 
 764 void print_native_stack(outputStream* st, frame fr, Thread* t, char* buf, int buf_size) {
 765 
 766   // see if it's a valid frame
 767   if (fr.pc()) {
 768     st->print_cr("Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)");
 769 
 770     int count = 0;
 771     while (count++ < StackPrintLimit) {
 772       fr.print_on_error(st, buf, buf_size);
 773       st->cr();
 774       // Compiled code may use EBP register on x86 so it looks like
 775       // non-walkable C frame. Use frame.sender() for java frames.
 776       if (t && t->is_Java_thread()) {
 777         // Catch very first native frame by using stack address.
 778         // For JavaThread stack_base and stack_size should be set.
 779         if (!t->on_local_stack((address)(fr.real_fp() + 1))) {
 780           break;
 781         }
 782         if (fr.is_java_frame() || fr.is_native_frame() || fr.is_runtime_frame()) {
 783           RegisterMap map((JavaThread*)t, false); // No update
 784           fr = fr.sender(&map);
 785         } else {
 786           fr = os::get_sender_for_C_frame(&fr);
 787         }
 788       } else {
 789         // is_first_C_frame() does only simple checks for frame pointer,
 790         // it will pass if java compiled code has a pointer in EBP.
 791         if (os::is_first_C_frame(&fr)) break;
 792         fr = os::get_sender_for_C_frame(&fr);
 793       }
 794     }
 795 
 796     if (count > StackPrintLimit) {
 797       st->print_cr("...<more frames>...");
 798     }
 799 
 800     st->cr();
 801   }
 802 }
 803 
 804 #ifndef PRODUCT
 805 
 806 extern "C" void pns(void* sp, void* fp, void* pc) { // print native stack
 807   Command c("pns");
 808   static char buf[O_BUFLEN];
 809   Thread* t = Thread::current_or_null();
 810   // Call generic frame constructor (certain arguments may be ignored)
 811   frame fr(sp, fp, pc);
 812   print_native_stack(tty, fr, t, buf, sizeof(buf));
 813 }
 814 
 815 #endif // !PRODUCT
 816 
 817 //////////////////////////////////////////////////////////////////////////////
 818 // Test multiple STATIC_ASSERT forms in various scopes.
 819 
 820 #ifndef PRODUCT
 821 
 822 // namespace scope
 823 STATIC_ASSERT(true);
 824 STATIC_ASSERT(true);
 825 STATIC_ASSERT(1 == 1);
 826 STATIC_ASSERT(0 == 0);
 827 
 828 void test_multiple_static_assert_forms_in_function_scope() {
 829   STATIC_ASSERT(true);
 830   STATIC_ASSERT(true);
 831   STATIC_ASSERT(0 == 0);
 832   STATIC_ASSERT(1 == 1);


 566 // pv: print vm-printable object
 567 extern "C" void pa(intptr_t p)   { ((AllocatedObj*) p)->print(); }
 568 extern "C" void findpc(intptr_t x);
 569 
 570 #endif // !PRODUCT
 571 
 572 extern "C" void ps() { // print stack
 573   if (Thread::current_or_null() == NULL) return;
 574   Command c("ps");
 575 
 576 
 577   // Prints the stack of the current Java thread
 578   JavaThread* p = JavaThread::active();
 579   tty->print(" for thread: ");
 580   p->print();
 581   tty->cr();
 582 
 583   if (p->has_last_Java_frame()) {
 584     // If the last_Java_fp is set we are in C land and
 585     // can call the standard stack_trace function.

 586     p->print_stack();
 587   } else {
 588 #ifdef PRODUCT
 589     tty->print_cr("Cannot find the last Java frame, printing stack disabled.");
 590 #else // !PRODUCT


 591     frame f = os::current_frame();
 592     RegisterMap reg_map(p);
 593     f = f.sender(&reg_map);
 594     tty->print("(guessing starting frame id=" PTR_FORMAT " based on current fp)\n", p2i(f.id()));
 595     p->trace_stack_from(vframe::new_vframe(&f, &reg_map, p));
 596     pd_ps(f);
 597 #endif // PRODUCT
 598   }
 599 
 600 }
 601 
 602 extern "C" void pfl() {
 603   // print frame layout
 604   Command c("pfl");
 605   JavaThread* p = JavaThread::active();
 606   tty->print(" for thread: ");
 607   p->print();
 608   tty->cr();
 609   if (p->has_last_Java_frame()) {
 610     p->print_frame_layout();


 740   tty->print_cr("  findm(intptr_t pc) - finds Method*");
 741   tty->print_cr("  find(intptr_t x)   - finds & prints nmethod/stub/bytecode/oop based on pointer into it");
 742   tty->print_cr("  pns(void* sp, void* fp, void* pc)  - print native (i.e. mixed) stack trace. E.g.");
 743   tty->print_cr("                   pns($sp, $rbp, $pc) on Linux/amd64 and Solaris/amd64 or");
 744   tty->print_cr("                   pns($sp, $ebp, $pc) on Linux/x86 or");
 745   tty->print_cr("                   pns($sp, 0, $pc)    on Linux/ppc64 or");
 746   tty->print_cr("                   pns($sp + 0x7ff, 0, $pc) on Solaris/SPARC");
 747   tty->print_cr("                 - in gdb do 'set overload-resolution off' before calling pns()");
 748   tty->print_cr("                 - in dbx do 'frame 1' before calling pns()");
 749 
 750   tty->print_cr("misc.");
 751   tty->print_cr("  flush()       - flushes the log file");
 752   tty->print_cr("  events()      - dump events from ring buffers");
 753 
 754 
 755   tty->print_cr("compiler debugging");
 756   tty->print_cr("  debug()       - to set things up for compiler debugging");
 757   tty->print_cr("  ndebug()      - undo debug");
 758 }
 759 












































 760 extern "C" void pns(void* sp, void* fp, void* pc) { // print native stack
 761   Command c("pns");
 762   static char buf[O_BUFLEN];
 763   Thread* t = Thread::current_or_null();
 764   // Call generic frame constructor (certain arguments may be ignored)
 765   frame fr(sp, fp, pc);
 766   VMError::print_native_stack(tty, fr, t, buf, sizeof(buf));
 767 }
 768 
 769 #endif // !PRODUCT
 770 
 771 //////////////////////////////////////////////////////////////////////////////
 772 // Test multiple STATIC_ASSERT forms in various scopes.
 773 
 774 #ifndef PRODUCT
 775 
 776 // namespace scope
 777 STATIC_ASSERT(true);
 778 STATIC_ASSERT(true);
 779 STATIC_ASSERT(1 == 1);
 780 STATIC_ASSERT(0 == 0);
 781 
 782 void test_multiple_static_assert_forms_in_function_scope() {
 783   STATIC_ASSERT(true);
 784   STATIC_ASSERT(true);
 785   STATIC_ASSERT(0 == 0);
 786   STATIC_ASSERT(1 == 1);
< prev index next >