src/share/vm/utilities/debug.cpp

Print this page
rev 7023 : 8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well


 648   tty->print_cr("basic");
 649   tty->print_cr("  pp(void* p)   - try to make sense of p");
 650   tty->print_cr("  pv(intptr_t p)- ((PrintableResourceObj*) p)->print()");
 651   tty->print_cr("  ps()          - print current thread stack");
 652   tty->print_cr("  pss()         - print all thread stacks");
 653   tty->print_cr("  pm(int pc)    - print Method* given compiled PC");
 654   tty->print_cr("  findm(intptr_t pc) - finds Method*");
 655   tty->print_cr("  find(intptr_t x)   - finds & prints nmethod/stub/bytecode/oop based on pointer into it");
 656 
 657   tty->print_cr("misc.");
 658   tty->print_cr("  flush()       - flushes the log file");
 659   tty->print_cr("  events()      - dump events from ring buffers");
 660 
 661 
 662   tty->print_cr("compiler debugging");
 663   tty->print_cr("  debug()       - to set things up for compiler debugging");
 664   tty->print_cr("  ndebug()      - undo debug");
 665 }
 666 
 667 #endif // !PRODUCT





















































 648   tty->print_cr("basic");
 649   tty->print_cr("  pp(void* p)   - try to make sense of p");
 650   tty->print_cr("  pv(intptr_t p)- ((PrintableResourceObj*) p)->print()");
 651   tty->print_cr("  ps()          - print current thread stack");
 652   tty->print_cr("  pss()         - print all thread stacks");
 653   tty->print_cr("  pm(int pc)    - print Method* given compiled PC");
 654   tty->print_cr("  findm(intptr_t pc) - finds Method*");
 655   tty->print_cr("  find(intptr_t x)   - finds & prints nmethod/stub/bytecode/oop based on pointer into it");
 656 
 657   tty->print_cr("misc.");
 658   tty->print_cr("  flush()       - flushes the log file");
 659   tty->print_cr("  events()      - dump events from ring buffers");
 660 
 661 
 662   tty->print_cr("compiler debugging");
 663   tty->print_cr("  debug()       - to set things up for compiler debugging");
 664   tty->print_cr("  ndebug()      - undo debug");
 665 }
 666 
 667 #endif // !PRODUCT
 668 
 669 void print_native_stack(outputStream* st, frame fr, Thread* t, char* buf, int buf_size) {
 670 
 671   // see if it's a valid frame
 672   if (fr.pc()) {
 673     st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");
 674 
 675     int count = 0;
 676     while (count++ < StackPrintLimit) {
 677       fr.print_on_error(st, buf, buf_size);
 678       st->cr();
 679       // Compiled code may use EBP register on x86 so it looks like
 680       // non-walkable C frame. Use frame.sender() for java frames.
 681       if (t && t->is_Java_thread()) {
 682         // Catch very first native frame by using stack address.
 683         // For JavaThread stack_base and stack_size should be set.
 684         if (!t->on_local_stack((address)(fr.sender_sp() + 1))) {
 685           break;
 686         }
 687         if (fr.is_java_frame()) {
 688           RegisterMap map((JavaThread*)t, false); // No update
 689           fr = fr.sender(&map);
 690         } else {
 691           fr = os::get_sender_for_C_frame(&fr);
 692         }
 693       } else {
 694         // is_first_C_frame() does only simple checks for frame pointer,
 695         // it will pass if java compiled code has a pointer in EBP.
 696         if (os::is_first_C_frame(&fr)) break;
 697         fr = os::get_sender_for_C_frame(&fr);
 698       }
 699     }
 700 
 701     if (count > StackPrintLimit) {
 702       st->print_cr("...<more frames>...");
 703     }
 704 
 705     st->cr();
 706   }
 707 }
 708 
 709 #ifndef PRODUCT
 710 
 711 extern "C" void pns(frame fr) { // print native stack
 712   Command c("pns");
 713   static char buf[O_BUFLEN];
 714   Thread* t = ThreadLocalStorage::get_thread_slow();
 715   print_native_stack(tty, fr, t, buf, sizeof(buf));
 716 }
 717 
 718 #endif // !PRODUCT