src/os_cpu/solaris_sparc/vm/thread_solaris_sparc.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 542
93b6525e3b82
permissions
-rw-r--r--

Initial load

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

mercurial