duke@435: /* sla@5237: * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "runtime/frame.inline.hpp" stefank@4299: #include "runtime/thread.inline.hpp" duke@435: duke@435: // For Forte Analyzer AsyncGetCallTrace profiling support - thread is duke@435: // currently interrupted by SIGPROF duke@435: bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, duke@435: void* ucontext, bool isInJava) { duke@435: duke@435: assert(Thread::current() == this, "caller must be current thread"); sla@5237: return pd_get_top_frame(fr_addr, ucontext, isInJava); sla@5237: } sla@5237: sla@5237: bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) { sla@5237: return pd_get_top_frame(fr_addr, ucontext, isInJava); sla@5237: } sla@5237: sla@5237: bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) { sla@5237: duke@435: assert(this->is_Java_thread(), "must be JavaThread"); duke@435: duke@435: JavaThread* jt = (JavaThread *)this; duke@435: duke@435: // If we have a last_Java_frame, then we should use it even if duke@435: // isInJava == true. It should be more reliable than CONTEXT info. kevinw@8877: if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) { duke@435: *fr_addr = jt->pd_last_frame(); duke@435: return true; duke@435: } duke@435: duke@435: // At this point, we don't have a last_Java_frame, so duke@435: // we try to glean some information out of the CONTEXT duke@435: // if we were running Java code when SIGPROF came in. duke@435: if (isInJava) { duke@435: CONTEXT* uc = (CONTEXT*)ucontext; duke@435: duke@435: #ifdef AMD64 duke@435: intptr_t* ret_fp = (intptr_t*) uc->Rbp; duke@435: intptr_t* ret_sp = (intptr_t*) uc->Rsp; duke@435: ExtendedPC addr = ExtendedPC((address)uc->Rip); duke@435: #else duke@435: intptr_t* ret_fp = (intptr_t*) uc->Ebp; duke@435: intptr_t* ret_sp = (intptr_t*) uc->Esp; duke@435: ExtendedPC addr = ExtendedPC((address)uc->Eip); duke@435: #endif // AMD64 duke@435: if (addr.pc() == NULL || ret_sp == NULL ) { duke@435: // CONTEXT wasn't useful duke@435: return false; duke@435: } duke@435: duke@435: frame ret_frame(ret_sp, ret_fp, addr.pc()); duke@435: if (!ret_frame.safe_for_sender(jt)) { duke@435: #ifdef COMPILER2 duke@435: // C2 uses ebp as a general register see if NULL fp helps duke@435: frame ret_frame2(ret_sp, NULL, addr.pc()); duke@435: if (!ret_frame2.safe_for_sender(jt)) { duke@435: // nothing else to try if the frame isn't good duke@435: return false; duke@435: } duke@435: ret_frame = ret_frame2; duke@435: #else duke@435: // nothing else to try if the frame isn't good duke@435: return false; duke@435: #endif /* COMPILER2 */ duke@435: } duke@435: *fr_addr = ret_frame; duke@435: return true; duke@435: } duke@435: duke@435: // nothing else to try duke@435: return false; duke@435: } bobv@2036: bobv@2036: void JavaThread::cache_global_variables() { }