comparison src/share/vm/utilities/debug.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 c18cbe5936b8
children 30f67acf635d
comparison
equal deleted inserted replaced
1680:a64438a2b7e8 1681:126ea7725993
1 /* 1 /*
2 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. 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. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
550 } else { 550 } else {
551 return (address)(intptr_t(y) & page_bits); 551 return (address)(intptr_t(y) & page_bits);
552 } 552 }
553 } 553 }
554 554
555
556 static void find(intptr_t x, bool print_pc) {
557 address addr = (address)x;
558
559 CodeBlob* b = CodeCache::find_blob_unsafe(addr);
560 if (b != NULL) {
561 if (b->is_buffer_blob()) {
562 // the interpreter is generated into a buffer blob
563 InterpreterCodelet* i = Interpreter::codelet_containing(addr);
564 if (i != NULL) {
565 i->print();
566 return;
567 }
568 if (Interpreter::contains(addr)) {
569 tty->print_cr(INTPTR_FORMAT " is pointing into interpreter code (not bytecode specific)", addr);
570 return;
571 }
572 //
573 if (AdapterHandlerLibrary::contains(b)) {
574 AdapterHandlerLibrary::print_handler(b);
575 }
576 // the stubroutines are generated into a buffer blob
577 StubCodeDesc* d = StubCodeDesc::desc_for(addr);
578 if (d != NULL) {
579 d->print();
580 if (print_pc) tty->cr();
581 return;
582 }
583 if (StubRoutines::contains(addr)) {
584 tty->print_cr(INTPTR_FORMAT " is pointing to an (unnamed) stub routine", addr);
585 return;
586 }
587 // the InlineCacheBuffer is using stubs generated into a buffer blob
588 if (InlineCacheBuffer::contains(addr)) {
589 tty->print_cr(INTPTR_FORMAT " is pointing into InlineCacheBuffer", addr);
590 return;
591 }
592 VtableStub* v = VtableStubs::stub_containing(addr);
593 if (v != NULL) {
594 v->print();
595 return;
596 }
597 }
598 if (print_pc && b->is_nmethod()) {
599 ResourceMark rm;
600 tty->print("%#p: Compiled ", addr);
601 ((nmethod*)b)->method()->print_value_on(tty);
602 tty->print(" = (CodeBlob*)" INTPTR_FORMAT, b);
603 tty->cr();
604 return;
605 }
606 if ( b->is_nmethod()) {
607 if (b->is_zombie()) {
608 tty->print_cr(INTPTR_FORMAT " is zombie nmethod", b);
609 } else if (b->is_not_entrant()) {
610 tty->print_cr(INTPTR_FORMAT " is non-entrant nmethod", b);
611 }
612 }
613 b->print();
614 return;
615 }
616
617 if (Universe::heap()->is_in(addr)) {
618 HeapWord* p = Universe::heap()->block_start(addr);
619 bool print = false;
620 // If we couldn't find it it just may mean that heap wasn't parseable
621 // See if we were just given an oop directly
622 if (p != NULL && Universe::heap()->block_is_obj(p)) {
623 print = true;
624 } else if (p == NULL && ((oopDesc*)addr)->is_oop()) {
625 p = (HeapWord*) addr;
626 print = true;
627 }
628 if (print) {
629 oop(p)->print();
630 if (p != (HeapWord*)x && oop(p)->is_constMethod() &&
631 constMethodOop(p)->contains(addr)) {
632 Thread *thread = Thread::current();
633 HandleMark hm(thread);
634 methodHandle mh (thread, constMethodOop(p)->method());
635 if (!mh->is_native()) {
636 tty->print_cr("bci_from(%p) = %d; print_codes():",
637 addr, mh->bci_from(address(x)));
638 mh->print_codes();
639 }
640 }
641 return;
642 }
643 } else if (Universe::heap()->is_in_reserved(addr)) {
644 tty->print_cr(INTPTR_FORMAT " is an unallocated location in the heap", addr);
645 return;
646 }
647
648 if (JNIHandles::is_global_handle((jobject) addr)) {
649 tty->print_cr(INTPTR_FORMAT " is a global jni handle", addr);
650 return;
651 }
652 if (JNIHandles::is_weak_global_handle((jobject) addr)) {
653 tty->print_cr(INTPTR_FORMAT " is a weak global jni handle", addr);
654 return;
655 }
656 if (JNIHandleBlock::any_contains((jobject) addr)) {
657 tty->print_cr(INTPTR_FORMAT " is a local jni handle", addr);
658 return;
659 }
660
661 for(JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
662 // Check for privilege stack
663 if (thread->privileged_stack_top() != NULL && thread->privileged_stack_top()->contains(addr)) {
664 tty->print_cr(INTPTR_FORMAT " is pointing into the privilege stack for thread: " INTPTR_FORMAT, addr, thread);
665 return;
666 }
667 // If the addr is a java thread print information about that.
668 if (addr == (address)thread) {
669 thread->print();
670 return;
671 }
672 }
673
674 // Try an OS specific find
675 if (os::find(addr)) {
676 return;
677 }
678
679 if (print_pc) {
680 tty->print_cr(INTPTR_FORMAT ": probably in C++ code; check debugger", addr);
681 Disassembler::decode(same_page(addr-40,addr),same_page(addr+40,addr));
682 return;
683 }
684
685 tty->print_cr(INTPTR_FORMAT " is pointing to unknown location", addr);
686 }
687
688
689 class LookForRefInGenClosure : public OopsInGenClosure { 555 class LookForRefInGenClosure : public OopsInGenClosure {
690 public: 556 public:
691 oop target; 557 oop target;
692 void do_oop(oop* o) { 558 void do_oop(oop* o) {
693 if (o != NULL && *o == target) { 559 if (o != NULL && *o == target) {
765 631
766 // Another interface that isn't ambiguous in dbx. 632 // Another interface that isn't ambiguous in dbx.
767 // Can we someday rename the other find to hsfind? 633 // Can we someday rename the other find to hsfind?
768 extern "C" void hsfind(intptr_t x) { 634 extern "C" void hsfind(intptr_t x) {
769 Command c("hsfind"); 635 Command c("hsfind");
770 find(x, false); 636 os::print_location(tty, x, false);
771 } 637 }
772 638
773 639
774 extern "C" void hsfindref(intptr_t x) { 640 extern "C" void hsfindref(intptr_t x) {
775 Command c("hsfindref"); 641 Command c("hsfindref");
776 findref(x); 642 findref(x);
777 } 643 }
778 644
779 extern "C" void find(intptr_t x) { 645 extern "C" void find(intptr_t x) {
780 Command c("find"); 646 Command c("find");
781 find(x, false); 647 os::print_location(tty, x, false);
782 } 648 }
783 649
784 650
785 extern "C" void findpc(intptr_t x) { 651 extern "C" void findpc(intptr_t x) {
786 Command c("findpc"); 652 Command c("findpc");
787 find(x, true); 653 os::print_location(tty, x, true);
788 } 654 }
789 655
790 656
791 // int versions of all methods to avoid having to type type casts in the debugger 657 // int versions of all methods to avoid having to type type casts in the debugger
792 658