1 /* 2 * Copyright (c) 1999, 2012, 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 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "code/codeCache.hpp" 27 #include "code/nmethod.hpp" 28 #include "runtime/frame.hpp" 29 #include "runtime/init.hpp" 30 #include "runtime/os.hpp" 31 #include "utilities/debug.hpp" 32 #include "utilities/top.hpp" 33 34 #ifndef PRODUCT 35 36 extern "C" void findpc(int x); 37 38 39 void pd_ps(frame f) { 40 intptr_t* sp = f.sp(); 41 intptr_t* prev_sp = sp - 1; 42 intptr_t *pc = NULL; 43 intptr_t *next_pc = NULL; 44 int count = 0; 45 tty->print_cr("register window backtrace from " INTPTR_FORMAT ":", p2i(sp)); 46 while (sp != NULL && ((intptr_t)sp & 7) == 0 && sp > prev_sp && sp < prev_sp+1000) { 47 pc = next_pc; 48 next_pc = (intptr_t*) sp[I7->sp_offset_in_saved_window()]; 49 tty->print("[%d] sp=" INTPTR_FORMAT " pc=", count, p2i(sp)); 50 findpc((intptr_t)pc); 51 if (WizardMode && Verbose) { 52 // print register window contents also 53 tty->print_cr(" L0..L7: {" 54 INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " 55 INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " ", 56 sp[0+0], sp[0+1], sp[0+2], sp[0+3], 57 sp[0+4], sp[0+5], sp[0+6], sp[0+7]); 58 tty->print_cr(" I0..I7: {" 59 INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " 60 INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " ", 61 sp[8+0], sp[8+1], sp[8+2], sp[8+3], 62 sp[8+4], sp[8+5], sp[8+6], sp[8+7]); 63 // (and print stack frame contents too??) 64 65 CodeBlob *b = CodeCache::find_blob((address) pc); 66 if (b != NULL) { 67 if (b->is_nmethod()) { 68 Method* m = ((nmethod*)b)->method(); 69 int nlocals = m->max_locals(); 70 int nparams = m->size_of_parameters(); 71 tty->print_cr("compiled java method (locals = %d, params = %d)", nlocals, nparams); 72 } 73 } 74 } 75 prev_sp = sp; 76 sp = (intptr_t *)sp[FP->sp_offset_in_saved_window()]; 77 sp = (intptr_t *)((intptr_t)sp + STACK_BIAS); 78 count += 1; 79 } 80 if (sp != NULL) 81 tty->print("[%d] sp=" INTPTR_FORMAT " [bogus sp!]", count, p2i(sp)); 82 } 83 84 #endif // PRODUCT