thread_linux_x86.cpp revision 1601
c533a883a71cff9ff32df1c53c31201e1cbf371fhx/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx *
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This code is free software; you can redistribute it and/or modify it
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * under the terms of the GNU General Public License version 2 only, as
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * published by the Free Software Foundation.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx *
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * This code is distributed in the hope that it will be useful, but WITHOUT
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * version 2 for more details (a copy is included in the LICENSE file that
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * accompanied this code).
c533a883a71cff9ff32df1c53c31201e1cbf371fhx *
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * You should have received a copy of the GNU General Public License version
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * 2 along with this work; if not, write to the Free Software Foundation,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx *
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * or visit www.oracle.com if you need additional information or have any
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * questions.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx *
c533a883a71cff9ff32df1c53c31201e1cbf371fhx */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#include "incls/_precompiled.incl"
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#include "incls/_thread_linux_x86.cpp.incl"
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
c533a883a71cff9ff32df1c53c31201e1cbf371fhx// currently interrupted by SIGPROF
c533a883a71cff9ff32df1c53c31201e1cbf371fhxbool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx void* ucontext, bool isInJava) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx assert(Thread::current() == this, "caller must be current thread");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx assert(this->is_Java_thread(), "must be JavaThread");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx JavaThread* jt = (JavaThread *)this;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // If we have a last_Java_frame, then we should use it even if
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // isInJava == true. It should be more reliable than ucontext info.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (jt->has_last_Java_frame()) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx *fr_addr = jt->pd_last_frame();
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx }
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // At this point, we don't have a last_Java_frame, so
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // we try to glean some information out of the ucontext
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // if we were running Java code when SIGPROF came in.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (isInJava) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx ucontext_t* uc = (ucontext_t*) ucontext;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng intptr_t* ret_fp;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx intptr_t* ret_sp;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx ExtendedPC addr = os::Linux::fetch_frame_from_ucontext(this, uc,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx &ret_sp, &ret_fp);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (addr.pc() == NULL || ret_sp == NULL ) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // ucontext wasn't useful
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx }
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China
c533a883a71cff9ff32df1c53c31201e1cbf371fhx frame ret_frame(ret_sp, ret_fp, addr.pc());
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!ret_frame.safe_for_sender(jt)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#ifdef COMPILER2
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // C2 uses ebp as a general register see if NULL fp helps
c533a883a71cff9ff32df1c53c31201e1cbf371fhx frame ret_frame2(ret_sp, NULL, addr.pc());
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!ret_frame2.safe_for_sender(jt)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // nothing else to try if the frame isn't good
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx }
c533a883a71cff9ff32df1c53c31201e1cbf371fhx ret_frame = ret_frame2;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#else
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // nothing else to try if the frame isn't good
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx#endif /* COMPILER2 */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx }
c533a883a71cff9ff32df1c53c31201e1cbf371fhx *fr_addr = ret_frame;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx }
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // nothing else to try
43439c96b8398c01c375889c79bed72d78fb4c39hx return false;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China}
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhxvoid JavaThread::cache_global_variables() { }
c533a883a71cff9ff32df1c53c31201e1cbf371fhx
c533a883a71cff9ff32df1c53c31201e1cbf371fhx