1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp Sun Sep 25 16:03:29 2011 -0700 1.3 @@ -0,0 +1,84 @@ 1.4 +/* 1.5 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "runtime/frame.inline.hpp" 1.30 +#include "thread_bsd.inline.hpp" 1.31 + 1.32 +// For Forte Analyzer AsyncGetCallTrace profiling support - thread is 1.33 +// currently interrupted by SIGPROF 1.34 +bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, 1.35 + void* ucontext, bool isInJava) { 1.36 + 1.37 + assert(Thread::current() == this, "caller must be current thread"); 1.38 + assert(this->is_Java_thread(), "must be JavaThread"); 1.39 + 1.40 + JavaThread* jt = (JavaThread *)this; 1.41 + 1.42 + // If we have a last_Java_frame, then we should use it even if 1.43 + // isInJava == true. It should be more reliable than ucontext info. 1.44 + if (jt->has_last_Java_frame()) { 1.45 + *fr_addr = jt->pd_last_frame(); 1.46 + return true; 1.47 + } 1.48 + 1.49 + // At this point, we don't have a last_Java_frame, so 1.50 + // we try to glean some information out of the ucontext 1.51 + // if we were running Java code when SIGPROF came in. 1.52 + if (isInJava) { 1.53 + ucontext_t* uc = (ucontext_t*) ucontext; 1.54 + 1.55 + intptr_t* ret_fp; 1.56 + intptr_t* ret_sp; 1.57 + ExtendedPC addr = os::Bsd::fetch_frame_from_ucontext(this, uc, 1.58 + &ret_sp, &ret_fp); 1.59 + if (addr.pc() == NULL || ret_sp == NULL ) { 1.60 + // ucontext wasn't useful 1.61 + return false; 1.62 + } 1.63 + 1.64 + frame ret_frame(ret_sp, ret_fp, addr.pc()); 1.65 + if (!ret_frame.safe_for_sender(jt)) { 1.66 +#ifdef COMPILER2 1.67 + // C2 uses ebp as a general register see if NULL fp helps 1.68 + frame ret_frame2(ret_sp, NULL, addr.pc()); 1.69 + if (!ret_frame2.safe_for_sender(jt)) { 1.70 + // nothing else to try if the frame isn't good 1.71 + return false; 1.72 + } 1.73 + ret_frame = ret_frame2; 1.74 +#else 1.75 + // nothing else to try if the frame isn't good 1.76 + return false; 1.77 +#endif /* COMPILER2 */ 1.78 + } 1.79 + *fr_addr = ret_frame; 1.80 + return true; 1.81 + } 1.82 + 1.83 + // nothing else to try 1.84 + return false; 1.85 +} 1.86 + 1.87 +void JavaThread::cache_global_variables() { }