Path: blob/master/src/hotspot/os_cpu/bsd_x86/thread_bsd_x86.cpp
40930 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "runtime/frame.inline.hpp"26#include "runtime/thread.inline.hpp"2728frame JavaThread::pd_last_frame() {29assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");30vmassert(_anchor.last_Java_pc() != NULL, "not walkable");31return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());32}3334// For Forte Analyzer AsyncGetCallTrace profiling support - thread is35// currently interrupted by SIGPROF36bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,37void* ucontext, bool isInJava) {38assert(Thread::current() == this, "caller must be current thread");39return pd_get_top_frame(fr_addr, ucontext, isInJava);40}4142bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) {43return pd_get_top_frame(fr_addr, ucontext, isInJava);44}4546bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) {47// If we have a last_Java_frame, then we should use it even if48// isInJava == true. It should be more reliable than ucontext info.49if (has_last_Java_frame() && frame_anchor()->walkable()) {50*fr_addr = pd_last_frame();51return true;52}5354// At this point, we don't have a last_Java_frame, so55// we try to glean some information out of the ucontext56// if we were running Java code when SIGPROF came in.57if (isInJava) {58ucontext_t* uc = (ucontext_t*) ucontext;5960intptr_t* ret_fp;61intptr_t* ret_sp;62address addr = os::fetch_frame_from_context(uc, &ret_sp, &ret_fp);63if (addr == NULL || ret_sp == NULL ) {64// ucontext wasn't useful65return false;66}6768frame ret_frame(ret_sp, ret_fp, addr);69if (!ret_frame.safe_for_sender(this)) {70#if COMPILER2_OR_JVMCI71// C2 and JVMCI use ebp as a general register see if NULL fp helps72frame ret_frame2(ret_sp, NULL, addr);73if (!ret_frame2.safe_for_sender(this)) {74// nothing else to try if the frame isn't good75return false;76}77ret_frame = ret_frame2;78#else79// nothing else to try if the frame isn't good80return false;81#endif // COMPILER2_OR_JVMCI82}83*fr_addr = ret_frame;84return true;85}8687// nothing else to try88return false;89}9091void JavaThread::cache_global_variables() { }929394