src/share/vm/runtime/os.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6970683 Sdiff src/share/vm/runtime

src/share/vm/runtime/os.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 719   st->print("total %d", os::processor_count());
 720   // It's not safe to query number of active processors after crash
 721   // st->print("(active %d)", os::active_processor_count());
 722   st->print(" %s", VM_Version::cpu_features());
 723   st->cr();
 724 }
 725 
 726 void os::print_date_and_time(outputStream *st) {
 727   time_t tloc;
 728   (void)time(&tloc);
 729   st->print("time: %s", ctime(&tloc));  // ctime adds newline.
 730 
 731   double t = os::elapsedTime();
 732   // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
 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?
 735   st->print_cr("elapsed time: %d seconds", (int)t);
 736 }
 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     }


 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 }
 884 
 885 // Looks like all platforms except IA64 can use the same function to check
 886 // if C stack is walkable beyond current frame. The check for fp() is not
 887 // necessary on Sparc, but it's harmless.
 888 bool os::is_first_C_frame(frame* fr) {
 889 #ifdef IA64
 890   // In order to walk native frames on Itanium, we need to access the unwind
 891   // table, which is inside ELF. We don't want to parse ELF after fatal error,
 892   // so return true for IA64. If we need to support C stack walking on IA64,
 893   // this function needs to be moved to CPU specific files, as fp() on IA64
 894   // is register stack, which grows towards higher memory address.
 895   return true;
 896 #endif
 897 
 898   // Load up sp, fp, sender sp and sender fp, check for reasonable values.
 899   // Check usp first, because if that's bad the other accessors may fault
 900   // on some architectures.  Ditto ufp second, etc.
 901   uintptr_t fp_align_mask = (uintptr_t)(sizeof(address)-1);
 902   // sp on amd can be 32 bit aligned.


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 719   st->print("total %d", os::processor_count());
 720   // It's not safe to query number of active processors after crash
 721   // st->print("(active %d)", os::active_processor_count());
 722   st->print(" %s", VM_Version::cpu_features());
 723   st->cr();
 724 }
 725 
 726 void os::print_date_and_time(outputStream *st) {
 727   time_t tloc;
 728   (void)time(&tloc);
 729   st->print("time: %s", ctime(&tloc));  // ctime adds newline.
 730 
 731   double t = os::elapsedTime();
 732   // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
 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?
 735   st->print_cr("elapsed time: %d seconds", (int)t);
 736 }
 737 
 738 // moved from debug.cpp (used to be find()) but still called from there
 739 // The verbose parameter is only set by the debug code in one case
 740 void os::print_location(outputStream* st, intptr_t x, bool verbose) {
 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         st->print_cr(INTPTR_FORMAT " is an Interpreter codelet", addr);
 749         i->print_on(st);
 750         return;
 751       }
 752       if (Interpreter::contains(addr)) {
 753         st->print_cr(INTPTR_FORMAT " is pointing into interpreter code"
 754                      " (not bytecode specific)", addr);
 755         return;
 756       }
 757       //
 758       if (AdapterHandlerLibrary::contains(b)) {
 759         st->print_cr(INTPTR_FORMAT " is an AdapterHandler", addr);
 760         AdapterHandlerLibrary::print_handler_on(st, b);
 761       }
 762       // the stubroutines are generated into a buffer blob
 763       StubCodeDesc* d = StubCodeDesc::desc_for(addr);
 764       if (d != NULL) {
 765         d->print_on(st);
 766         if (verbose) st->cr();
 767         return;
 768       }
 769       if (StubRoutines::contains(addr)) {
 770         st->print_cr(INTPTR_FORMAT " is pointing to an (unnamed) "
 771                      "stub routine", addr);
 772         return;
 773       }
 774       // the InlineCacheBuffer is using stubs generated into a buffer blob
 775       if (InlineCacheBuffer::contains(addr)) {
 776         st->print_cr(INTPTR_FORMAT " is pointing into InlineCacheBuffer", addr);
 777         return;
 778       }
 779       VtableStub* v = VtableStubs::stub_containing(addr);
 780       if (v != NULL) {
 781         v->print_on(st);
 782         return;
 783       }
 784     }
 785     if (verbose && b->is_nmethod()) {
 786       ResourceMark rm;
 787       st->print("%#p: Compiled ", addr);
 788       ((nmethod*)b)->method()->print_value_on(st);
 789       st->print("  = (CodeBlob*)" INTPTR_FORMAT, b);
 790       st->cr();
 791       return;
 792     }
 793     if ( b->is_nmethod()) {
 794       if (b->is_zombie()) {
 795         st->print_cr(INTPTR_FORMAT " is zombie nmethod", b);
 796       } else if (b->is_not_entrant()) {
 797         st->print_cr(INTPTR_FORMAT " is non-entrant nmethod", b);
 798       }
 799     }
 800     b->print_on(st);
 801     return;
 802   }
 803 
 804   if (Universe::heap()->is_in(addr)) {
 805     HeapWord* p = Universe::heap()->block_start(addr);
 806     bool print = false;
 807     // If we couldn't find it it just may mean that heap wasn't parseable
 808     // See if we were just given an oop directly
 809     if (p != NULL && Universe::heap()->block_is_obj(p)) {
 810       print = true;
 811     } else if (p == NULL && ((oopDesc*)addr)->is_oop()) {
 812       p = (HeapWord*) addr;
 813       print = true;
 814     }
 815     if (print) {
 816       st->print_cr(INTPTR_FORMAT " is an oop", addr);
 817       oop(p)->print_on(st);
 818       if (p != (HeapWord*)x && oop(p)->is_constMethod() &&
 819           constMethodOop(p)->contains(addr)) {
 820         Thread *thread = Thread::current();
 821         HandleMark hm(thread);
 822         methodHandle mh (thread, constMethodOop(p)->method());
 823         if (!mh->is_native()) {
 824           st->print_cr("bci_from(%p) = %d; print_codes():",
 825                         addr, mh->bci_from(address(x)));
 826           mh->print_codes_on(st);
 827         }
 828       }
 829       return;
 830     }
 831   } else {
 832     if (Universe::heap()->is_in_reserved(addr)) {
 833       st->print_cr(INTPTR_FORMAT " is an unallocated location "
 834                    "in the heap", addr);
 835       return;
 836     }


 840     return;
 841   }
 842   if (JNIHandles::is_weak_global_handle((jobject) addr)) {
 843     st->print_cr(INTPTR_FORMAT " is a weak global jni handle", addr);
 844     return;
 845   }
 846 #ifndef PRODUCT
 847   // we don't keep the block list in product mode
 848   if (JNIHandleBlock::any_contains((jobject) addr)) {
 849     st->print_cr(INTPTR_FORMAT " is a local jni handle", addr);
 850     return;
 851   }
 852 #endif
 853 
 854   for(JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
 855     // Check for privilege stack
 856     if (thread->privileged_stack_top() != NULL &&
 857         thread->privileged_stack_top()->contains(addr)) {
 858       st->print_cr(INTPTR_FORMAT " is pointing into the privilege stack "
 859                    "for thread: " INTPTR_FORMAT, addr, thread);
 860       if (verbose) thread->print_on(st);
 861       return;
 862     }
 863     // If the addr is a java thread print information about that.
 864     if (addr == (address)thread) {
 865       if (verbose) {
 866         thread->print_on(st);
 867       } else {
 868         st->print_cr(INTPTR_FORMAT " is a thread", addr);
 869       }
 870       return;
 871     }
 872     // If the addr is in the stack region for this thread then report that
 873     // and print thread info
 874     if (thread->stack_base() >= addr &&
 875         addr > (thread->stack_base() - thread->stack_size())) {
 876       st->print_cr(INTPTR_FORMAT " is pointing into the stack for thread: "
 877                    INTPTR_FORMAT, addr, thread);
 878       if (verbose) thread->print_on(st);
 879       return;
 880     }
 881 
 882   }
 883   // Try an OS specific find
 884   if (os::find(addr, st)) {
 885     return;
 886   }
 887 
 888   st->print_cr(INTPTR_FORMAT " is an unknown value", addr);
 889 }
 890 
 891 // Looks like all platforms except IA64 can use the same function to check
 892 // if C stack is walkable beyond current frame. The check for fp() is not
 893 // necessary on Sparc, but it's harmless.
 894 bool os::is_first_C_frame(frame* fr) {
 895 #ifdef IA64
 896   // In order to walk native frames on Itanium, we need to access the unwind
 897   // table, which is inside ELF. We don't want to parse ELF after fatal error,
 898   // so return true for IA64. If we need to support C stack walking on IA64,
 899   // this function needs to be moved to CPU specific files, as fp() on IA64
 900   // is register stack, which grows towards higher memory address.
 901   return true;
 902 #endif
 903 
 904   // Load up sp, fp, sender sp and sender fp, check for reasonable values.
 905   // Check usp first, because if that's bad the other accessors may fault
 906   // on some architectures.  Ditto ufp second, etc.
 907   uintptr_t fp_align_mask = (uintptr_t)(sizeof(address)-1);
 908   // sp on amd can be 32 bit aligned.


src/share/vm/runtime/os.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File