thread_windows_x86.cpp revision 0:a61af66fc99e
1179404Sobrien/* 2179404Sobrien * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. 3218822Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4179404Sobrien * 5179404Sobrien * This code is free software; you can redistribute it and/or modify it 6179404Sobrien * under the terms of the GNU General Public License version 2 only, as 7179404Sobrien * published by the Free Software Foundation. 8179404Sobrien * 9179404Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT 10179404Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11179404Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12179404Sobrien * version 2 for more details (a copy is included in the LICENSE file that 13179404Sobrien * accompanied this code). 14179404Sobrien * 15179404Sobrien * You should have received a copy of the GNU General Public License version 16179404Sobrien * 2 along with this work; if not, write to the Free Software Foundation, 17179404Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18179404Sobrien * 19179404Sobrien * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20179404Sobrien * CA 95054 USA or visit www.sun.com if you need additional information or 21179404Sobrien * have any questions. 22179404Sobrien * 23179404Sobrien */ 24179404Sobrien 25179404Sobrien#include "incls/_precompiled.incl" 26208737Sjmallett#include "incls/_thread_windows_x86.cpp.incl" 27179404Sobrien 28179404Sobrien// For Forte Analyzer AsyncGetCallTrace profiling support - thread is 29179404Sobrien// currently interrupted by SIGPROF 30218822Sdimbool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, 31179404Sobrien void* ucontext, bool isInJava) { 32179404Sobrien 33179404Sobrien assert(Thread::current() == this, "caller must be current thread"); 34179404Sobrien assert(this->is_Java_thread(), "must be JavaThread"); 35179404Sobrien 36179404Sobrien JavaThread* jt = (JavaThread *)this; 37218822Sdim 38179404Sobrien // If we have a last_Java_frame, then we should use it even if 39179404Sobrien // isInJava == true. It should be more reliable than CONTEXT info. 40179404Sobrien if (jt->has_last_Java_frame()) { 41179404Sobrien *fr_addr = jt->pd_last_frame(); 42179404Sobrien return true; 43179404Sobrien } 44179404Sobrien 45179404Sobrien // At this point, we don't have a last_Java_frame, so 46179404Sobrien // we try to glean some information out of the CONTEXT 47218822Sdim // if we were running Java code when SIGPROF came in. 48218822Sdim if (isInJava) { 49218822Sdim CONTEXT* uc = (CONTEXT*)ucontext; 50218822Sdim 51218822Sdim#ifdef AMD64 52218822Sdim intptr_t* ret_fp = (intptr_t*) uc->Rbp; 53218822Sdim intptr_t* ret_sp = (intptr_t*) uc->Rsp; 54218822Sdim ExtendedPC addr = ExtendedPC((address)uc->Rip); 55218822Sdim#else 56218822Sdim intptr_t* ret_fp = (intptr_t*) uc->Ebp; 57218822Sdim intptr_t* ret_sp = (intptr_t*) uc->Esp; 58218822Sdim ExtendedPC addr = ExtendedPC((address)uc->Eip); 59218822Sdim#endif // AMD64 60218822Sdim if (addr.pc() == NULL || ret_sp == NULL ) { 61218822Sdim // CONTEXT wasn't useful 62218822Sdim return false; 63218822Sdim } 64218822Sdim 65218822Sdim frame ret_frame(ret_sp, ret_fp, addr.pc()); 66218822Sdim if (!ret_frame.safe_for_sender(jt)) { 67218822Sdim#ifdef COMPILER2 68218822Sdim // C2 uses ebp as a general register see if NULL fp helps 69218822Sdim frame ret_frame2(ret_sp, NULL, addr.pc()); 70218822Sdim if (!ret_frame2.safe_for_sender(jt)) { 71218822Sdim // nothing else to try if the frame isn't good 72218822Sdim return false; 73218822Sdim } 74218822Sdim ret_frame = ret_frame2; 75218822Sdim#else 76218822Sdim // nothing else to try if the frame isn't good 77218822Sdim return false; 78218822Sdim#endif /* COMPILER2 */ 79218822Sdim } 80179404Sobrien *fr_addr = ret_frame; 81179404Sobrien return true; 82179404Sobrien } 83179404Sobrien 84179404Sobrien // nothing else to try 85179404Sobrien return false; 86179404Sobrien} 87179404Sobrien