comparison src/share/vm/runtime/os.cpp @ 1681:126ea7725993

6953477: Increase portability and flexibility of building Hotspot Summary: A collection of portability improvements including shared code support for PPC, ARM platforms, software floating point, cross compilation support and improvements in error crash detail. Reviewed-by: phh, never, coleenp, dholmes
author bobv
date Tue, 03 Aug 2010 08:13:38 -0400
parents 0e7d2a08b605
children 1e9a9d2e6509
comparison
equal deleted inserted replaced
1680:a64438a2b7e8 1681:126ea7725993
733 // Linux. Must be a bug in glibc ? Workaround is to round "t" to int 733 // Linux. Must be a bug in glibc ? Workaround is to round "t" to int
734 // before printf. We lost some precision, but who cares? 734 // before printf. We lost some precision, but who cares?
735 st->print_cr("elapsed time: %d seconds", (int)t); 735 st->print_cr("elapsed time: %d seconds", (int)t);
736 } 736 }
737 737
738 // moved from debug.cpp (used to be find()) but still called from there
739 // The print_pc parameter is only set by the debug code in one case
740 void os::print_location(outputStream* st, intptr_t x, bool print_pc) {
741 address addr = (address)x;
742 CodeBlob* b = CodeCache::find_blob_unsafe(addr);
743 if (b != NULL) {
744 if (b->is_buffer_blob()) {
745 // the interpreter is generated into a buffer blob
746 InterpreterCodelet* i = Interpreter::codelet_containing(addr);
747 if (i != NULL) {
748 i->print_on(st);
749 return;
750 }
751 if (Interpreter::contains(addr)) {
752 st->print_cr(INTPTR_FORMAT " is pointing into interpreter code"
753 " (not bytecode specific)", addr);
754 return;
755 }
756 //
757 if (AdapterHandlerLibrary::contains(b)) {
758 st->print_cr("Printing AdapterHandler");
759 AdapterHandlerLibrary::print_handler_on(st, b);
760 }
761 // the stubroutines are generated into a buffer blob
762 StubCodeDesc* d = StubCodeDesc::desc_for(addr);
763 if (d != NULL) {
764 d->print_on(st);
765 if (print_pc) st->cr();
766 return;
767 }
768 if (StubRoutines::contains(addr)) {
769 st->print_cr(INTPTR_FORMAT " is pointing to an (unnamed) "
770 "stub routine", addr);
771 return;
772 }
773 // the InlineCacheBuffer is using stubs generated into a buffer blob
774 if (InlineCacheBuffer::contains(addr)) {
775 st->print_cr(INTPTR_FORMAT " is pointing into InlineCacheBuffer", addr);
776 return;
777 }
778 VtableStub* v = VtableStubs::stub_containing(addr);
779 if (v != NULL) {
780 v->print_on(st);
781 return;
782 }
783 }
784 if (print_pc && b->is_nmethod()) {
785 ResourceMark rm;
786 st->print("%#p: Compiled ", addr);
787 ((nmethod*)b)->method()->print_value_on(st);
788 st->print(" = (CodeBlob*)" INTPTR_FORMAT, b);
789 st->cr();
790 return;
791 }
792 if ( b->is_nmethod()) {
793 if (b->is_zombie()) {
794 st->print_cr(INTPTR_FORMAT " is zombie nmethod", b);
795 } else if (b->is_not_entrant()) {
796 st->print_cr(INTPTR_FORMAT " is non-entrant nmethod", b);
797 }
798 }
799 b->print_on(st);
800 return;
801 }
802
803 if (Universe::heap()->is_in(addr)) {
804 HeapWord* p = Universe::heap()->block_start(addr);
805 bool print = false;
806 // If we couldn't find it it just may mean that heap wasn't parseable
807 // See if we were just given an oop directly
808 if (p != NULL && Universe::heap()->block_is_obj(p)) {
809 print = true;
810 } else if (p == NULL && ((oopDesc*)addr)->is_oop()) {
811 p = (HeapWord*) addr;
812 print = true;
813 }
814 if (print) {
815 oop(p)->print_on(st);
816 if (p != (HeapWord*)x && oop(p)->is_constMethod() &&
817 constMethodOop(p)->contains(addr)) {
818 Thread *thread = Thread::current();
819 HandleMark hm(thread);
820 methodHandle mh (thread, constMethodOop(p)->method());
821 if (!mh->is_native()) {
822 st->print_cr("bci_from(%p) = %d; print_codes():",
823 addr, mh->bci_from(address(x)));
824 mh->print_codes_on(st);
825 }
826 }
827 return;
828 }
829 } else {
830 if (Universe::heap()->is_in_reserved(addr)) {
831 st->print_cr(INTPTR_FORMAT " is an unallocated location "
832 "in the heap", addr);
833 return;
834 }
835 }
836 if (JNIHandles::is_global_handle((jobject) addr)) {
837 st->print_cr(INTPTR_FORMAT " is a global jni handle", addr);
838 return;
839 }
840 if (JNIHandles::is_weak_global_handle((jobject) addr)) {
841 st->print_cr(INTPTR_FORMAT " is a weak global jni handle", addr);
842 return;
843 }
844 #ifndef PRODUCT
845 // we don't keep the block list in product mode
846 if (JNIHandleBlock::any_contains((jobject) addr)) {
847 st->print_cr(INTPTR_FORMAT " is a local jni handle", addr);
848 return;
849 }
850 #endif
851
852 for(JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
853 // Check for privilege stack
854 if (thread->privileged_stack_top() != NULL &&
855 thread->privileged_stack_top()->contains(addr)) {
856 st->print_cr(INTPTR_FORMAT " is pointing into the privilege stack "
857 "for thread: " INTPTR_FORMAT, addr, thread);
858 thread->print_on(st);
859 return;
860 }
861 // If the addr is a java thread print information about that.
862 if (addr == (address)thread) {
863 thread->print_on(st);
864 return;
865 }
866 // If the addr is in the stack region for this thread then report that
867 // and print thread info
868 if (thread->stack_base() >= addr &&
869 addr > (thread->stack_base() - thread->stack_size())) {
870 st->print_cr(INTPTR_FORMAT " is pointing into the stack for thread: "
871 INTPTR_FORMAT, addr, thread);
872 thread->print_on(st);
873 return;
874 }
875
876 }
877 // Try an OS specific find
878 if (os::find(addr, st)) {
879 return;
880 }
881
882 st->print_cr(INTPTR_FORMAT " is pointing to unknown location", addr);
883 }
738 884
739 // Looks like all platforms except IA64 can use the same function to check 885 // Looks like all platforms except IA64 can use the same function to check
740 // if C stack is walkable beyond current frame. The check for fp() is not 886 // if C stack is walkable beyond current frame. The check for fp() is not
741 // necessary on Sparc, but it's harmless. 887 // necessary on Sparc, but it's harmless.
742 bool os::is_first_C_frame(frame* fr) { 888 bool os::is_first_C_frame(frame* fr) {