579N/A/*
961N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
579N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
579N/A *
579N/A * This code is free software; you can redistribute it and/or modify it
579N/A * under the terms of the GNU General Public License version 2 only, as
579N/A * published by the Free Software Foundation.
579N/A *
579N/A * This code is distributed in the hope that it will be useful, but WITHOUT
579N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
579N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
579N/A * version 2 for more details (a copy is included in the LICENSE file that
579N/A * accompanied this code).
579N/A *
579N/A * You should have received a copy of the GNU General Public License version
579N/A * 2 along with this work; if not, write to the Free Software Foundation,
579N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
579N/A *
580N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
580N/A * or visit www.oracle.com if you need additional information or have any
580N/A * questions.
579N/A *
579N/A */
579N/A
579N/A#include "precompiled.hpp"
794N/A#include "code/codeCache.hpp"
579N/A#include "code/nmethod.hpp"
579N/A#include "runtime/frame.hpp"
579N/A#include "runtime/init.hpp"
579N/A#include "runtime/os.hpp"
579N/A#include "utilities/debug.hpp"
891N/A#include "utilities/top.hpp"
579N/A
579N/A#ifndef PRODUCT
579N/A
579N/Aextern "C" void findpc(int x);
579N/A
579N/A
579N/Avoid pd_ps(frame f) {
579N/A intptr_t* sp = f.sp();
891N/A intptr_t* prev_sp = sp - 1;
579N/A intptr_t *pc = NULL;
579N/A intptr_t *next_pc = NULL;
579N/A int count = 0;
579N/A tty->print("register window backtrace from %#x:\n", sp);
579N/A while (sp != NULL && ((intptr_t)sp & 7) == 0 && sp > prev_sp && sp < prev_sp+1000) {
579N/A pc = next_pc;
579N/A next_pc = (intptr_t*) sp[I7->sp_offset_in_saved_window()];
579N/A tty->print("[%d] sp=%#x pc=", count, sp);
579N/A findpc((intptr_t)pc);
579N/A if (WizardMode && Verbose) {
579N/A // print register window contents also
794N/A tty->print_cr(" L0..L7: {%#x %#x %#x %#x %#x %#x %#x %#x}",
794N/A sp[0+0],sp[0+1],sp[0+2],sp[0+3],
579N/A sp[0+4],sp[0+5],sp[0+6],sp[0+7]);
794N/A tty->print_cr(" I0..I7: {%#x %#x %#x %#x %#x %#x %#x %#x}",
579N/A sp[8+0],sp[8+1],sp[8+2],sp[8+3],
794N/A sp[8+4],sp[8+5],sp[8+6],sp[8+7]);
794N/A // (and print stack frame contents too??)
579N/A
579N/A CodeBlob *b = CodeCache::find_blob((address) pc);
794N/A if (b != NULL) {
794N/A if (b->is_nmethod()) {
794N/A methodOop m = ((nmethod*)b)->method();
794N/A int nlocals = m->max_locals();
794N/A int nparams = m->size_of_parameters();
794N/A tty->print_cr("compiled java method (locals = %d, params = %d)", nlocals, nparams);
794N/A }
794N/A }
794N/A }
794N/A prev_sp = sp;
794N/A sp = (intptr_t *)sp[FP->sp_offset_in_saved_window()];
579N/A sp = (intptr_t *)((intptr_t)sp + STACK_BIAS);
794N/A count += 1;
794N/A }
794N/A if (sp != NULL)
794N/A tty->print("[%d] sp=%#x [bogus sp!]", count, sp);
794N/A}
579N/A
579N/A#endif // PRODUCT
579N/A