src/share/vm/utilities/debug.cpp

changeset 7553
f43fad8786fc
parent 7300
03e6d34be1f5
child 7994
04ff2f6cd0eb
child 8209
8641949eb21f
equal deleted inserted replaced
7552:0ef505d06e12 7553:f43fad8786fc
664 tty->print_cr(" ps() - print current thread stack"); 664 tty->print_cr(" ps() - print current thread stack");
665 tty->print_cr(" pss() - print all thread stacks"); 665 tty->print_cr(" pss() - print all thread stacks");
666 tty->print_cr(" pm(int pc) - print Method* given compiled PC"); 666 tty->print_cr(" pm(int pc) - print Method* given compiled PC");
667 tty->print_cr(" findm(intptr_t pc) - finds Method*"); 667 tty->print_cr(" findm(intptr_t pc) - finds Method*");
668 tty->print_cr(" find(intptr_t x) - finds & prints nmethod/stub/bytecode/oop based on pointer into it"); 668 tty->print_cr(" find(intptr_t x) - finds & prints nmethod/stub/bytecode/oop based on pointer into it");
669 tty->print_cr(" pns(void* sp, void* fp, void* pc) - print native (i.e. mixed) stack trace. E.g.");
670 tty->print_cr(" pns($sp, $rbp, $pc) on Linux/amd64 and Solaris/amd64 or");
671 tty->print_cr(" pns($sp, $ebp, $pc) on Linux/x86 or");
672 tty->print_cr(" pns($sp, 0, $pc) on Linux/ppc64 or");
673 tty->print_cr(" pns($sp + 0x7ff, 0, $pc) on Solaris/SPARC");
674 tty->print_cr(" - in gdb do 'set overload-resolution off' before calling pns()");
675 tty->print_cr(" - in dbx do 'frame 1' before calling pns()");
669 676
670 tty->print_cr("misc."); 677 tty->print_cr("misc.");
671 tty->print_cr(" flush() - flushes the log file"); 678 tty->print_cr(" flush() - flushes the log file");
672 tty->print_cr(" events() - dump events from ring buffers"); 679 tty->print_cr(" events() - dump events from ring buffers");
673 680
676 tty->print_cr(" debug() - to set things up for compiler debugging"); 683 tty->print_cr(" debug() - to set things up for compiler debugging");
677 tty->print_cr(" ndebug() - undo debug"); 684 tty->print_cr(" ndebug() - undo debug");
678 } 685 }
679 686
680 #endif // !PRODUCT 687 #endif // !PRODUCT
688
689 void print_native_stack(outputStream* st, frame fr, Thread* t, char* buf, int buf_size) {
690
691 // see if it's a valid frame
692 if (fr.pc()) {
693 st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");
694
695 int count = 0;
696 while (count++ < StackPrintLimit) {
697 fr.print_on_error(st, buf, buf_size);
698 st->cr();
699 // Compiled code may use EBP register on x86 so it looks like
700 // non-walkable C frame. Use frame.sender() for java frames.
701 if (t && t->is_Java_thread()) {
702 // Catch very first native frame by using stack address.
703 // For JavaThread stack_base and stack_size should be set.
704 if (!t->on_local_stack((address)(fr.real_fp() + 1))) {
705 break;
706 }
707 if (fr.is_java_frame() || fr.is_native_frame() || fr.is_runtime_frame()) {
708 RegisterMap map((JavaThread*)t, false); // No update
709 fr = fr.sender(&map);
710 } else {
711 fr = os::get_sender_for_C_frame(&fr);
712 }
713 } else {
714 // is_first_C_frame() does only simple checks for frame pointer,
715 // it will pass if java compiled code has a pointer in EBP.
716 if (os::is_first_C_frame(&fr)) break;
717 fr = os::get_sender_for_C_frame(&fr);
718 }
719 }
720
721 if (count > StackPrintLimit) {
722 st->print_cr("...<more frames>...");
723 }
724
725 st->cr();
726 }
727 }
728
729 #ifndef PRODUCT
730
731 extern "C" void pns(void* sp, void* fp, void* pc) { // print native stack
732 Command c("pns");
733 static char buf[O_BUFLEN];
734 Thread* t = ThreadLocalStorage::get_thread_slow();
735 // Call generic frame constructor (certain arguments may be ignored)
736 frame fr(sp, fp, pc);
737 print_native_stack(tty, fr, t, buf, sizeof(buf));
738 }
739
740 #endif // !PRODUCT

mercurial