annotate src/os_cpu/linux_sparc/vm/thread_linux_sparc.cpp @ 122:435e64505015

6693457: Open-source hotspot linux-sparc support Summary: Move os_cpu/linux_sparc from closed to open Reviewed-by: kamg
author phh
date Thu, 24 Apr 2008 15:07:57 -0400
parents
children d1605aabd0a1
rev   line source
phh@122 1 /*
phh@122 2 * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
phh@122 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
phh@122 4 *
phh@122 5 * This code is free software; you can redistribute it and/or modify it
phh@122 6 * under the terms of the GNU General Public License version 2 only, as
phh@122 7 * published by the Free Software Foundation.
phh@122 8 *
phh@122 9 * This code is distributed in the hope that it will be useful, but WITHOUT
phh@122 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
phh@122 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
phh@122 12 * version 2 for more details (a copy is included in the LICENSE file that
phh@122 13 * accompanied this code).
phh@122 14 *
phh@122 15 * You should have received a copy of the GNU General Public License version
phh@122 16 * 2 along with this work; if not, write to the Free Software Foundation,
phh@122 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
phh@122 18 *
phh@122 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
phh@122 20 * CA 95054 USA or visit www.sun.com if you need additional information or
phh@122 21 * have any questions.
phh@122 22 *
phh@122 23 */
phh@122 24
phh@122 25 #include "incls/_precompiled.incl"
phh@122 26 #include "incls/_thread_linux_sparc.cpp.incl"
phh@122 27
phh@122 28 // For Forte Analyzer AsyncGetCallTrace profiling support - thread is
phh@122 29 // currently interrupted by SIGPROF
phh@122 30 bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
phh@122 31 void* ucontext,
phh@122 32 bool isInJava) {
phh@122 33 assert(Thread::current() == this, "caller must be current thread");
phh@122 34 assert(this->is_Java_thread(), "must be JavaThread");
phh@122 35
phh@122 36 JavaThread* jt = (JavaThread *)this;
phh@122 37
phh@122 38 if (!isInJava) {
phh@122 39 // make_walkable flushes register windows and grabs last_Java_pc
phh@122 40 // which can not be done if the ucontext sp matches last_Java_sp
phh@122 41 // stack walking utilities assume last_Java_pc set if marked flushed
phh@122 42 jt->frame_anchor()->make_walkable(jt);
phh@122 43 }
phh@122 44
phh@122 45 // If we have a walkable last_Java_frame, then we should use it
phh@122 46 // even if isInJava == true. It should be more reliable than
phh@122 47 // ucontext info.
phh@122 48 if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
phh@122 49 *fr_addr = jt->pd_last_frame();
phh@122 50 return true;
phh@122 51 }
phh@122 52
phh@122 53 ucontext_t* uc = (ucontext_t*) ucontext;
phh@122 54
phh@122 55 // At this point, we don't have a walkable last_Java_frame, so
phh@122 56 // we try to glean some information out of the ucontext.
phh@122 57 intptr_t* ret_sp;
phh@122 58 ExtendedPC addr =
phh@122 59 os::fetch_frame_from_context(uc, &ret_sp,
phh@122 60 NULL /* ret_fp only used on X86 */);
phh@122 61 if (addr.pc() == NULL || ret_sp == NULL) {
phh@122 62 // ucontext wasn't useful
phh@122 63 return false;
phh@122 64 }
phh@122 65
phh@122 66 // we were running Java code when SIGPROF came in
phh@122 67 if (isInJava) {
phh@122 68 // If we have a last_Java_sp, then the SIGPROF signal caught us
phh@122 69 // right when we were transitioning from _thread_in_Java to a new
phh@122 70 // JavaThreadState. We use last_Java_sp instead of the sp from
phh@122 71 // the ucontext since it should be more reliable.
phh@122 72 if (jt->has_last_Java_frame()) {
phh@122 73 ret_sp = jt->last_Java_sp();
phh@122 74 }
phh@122 75 // Implied else: we don't have a last_Java_sp so we use what we
phh@122 76 // got from the ucontext.
phh@122 77
phh@122 78 frame ret_frame(ret_sp, frame::unpatchable, addr.pc());
phh@122 79 if (!ret_frame.safe_for_sender(jt)) {
phh@122 80 // nothing else to try if the frame isn't good
phh@122 81 return false;
phh@122 82 }
phh@122 83 *fr_addr = ret_frame;
phh@122 84 return true;
phh@122 85 }
phh@122 86
phh@122 87 // At this point, we know we weren't running Java code. We might
phh@122 88 // have a last_Java_sp, but we don't have a walkable frame.
phh@122 89 // However, we might still be able to construct something useful
phh@122 90 // if the thread was running native code.
phh@122 91 if (jt->has_last_Java_frame()) {
phh@122 92 assert(!jt->frame_anchor()->walkable(), "case covered above");
phh@122 93
phh@122 94 if (jt->thread_state() == _thread_in_native) {
phh@122 95 frame ret_frame(jt->last_Java_sp(), frame::unpatchable, addr.pc());
phh@122 96 if (!ret_frame.safe_for_sender(jt)) {
phh@122 97 // nothing else to try if the frame isn't good
phh@122 98 return false;
phh@122 99 }
phh@122 100 *fr_addr = ret_frame;
phh@122 101 return true;
phh@122 102 }
phh@122 103 }
phh@122 104
phh@122 105 // nothing else to try
phh@122 106 return false;
phh@122 107 }