src/os_cpu/linux_sparc/vm/thread_linux_sparc.cpp

changeset 568
435e64505015
child 631
d1605aabd0a1
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/os_cpu/linux_sparc/vm/thread_linux_sparc.cpp	Thu Apr 24 15:07:57 2008 -0400
     1.3 @@ -0,0 +1,107 @@
     1.4 +/*
     1.5 + * Copyright 2003-2004 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "incls/_precompiled.incl"
    1.29 +#include "incls/_thread_linux_sparc.cpp.incl"
    1.30 +
    1.31 +// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
    1.32 +// currently interrupted by SIGPROF
    1.33 +bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
    1.34 +                                                     void* ucontext,
    1.35 +                                                     bool isInJava) {
    1.36 +  assert(Thread::current() == this, "caller must be current thread");
    1.37 +  assert(this->is_Java_thread(), "must be JavaThread");
    1.38 +
    1.39 +  JavaThread* jt = (JavaThread *)this;
    1.40 +
    1.41 +  if (!isInJava) {
    1.42 +    // make_walkable flushes register windows and grabs last_Java_pc
    1.43 +    // which can not be done if the ucontext sp matches last_Java_sp
    1.44 +    // stack walking utilities assume last_Java_pc set if marked flushed
    1.45 +    jt->frame_anchor()->make_walkable(jt);
    1.46 +  }
    1.47 +
    1.48 +  // If we have a walkable last_Java_frame, then we should use it
    1.49 +  // even if isInJava == true. It should be more reliable than
    1.50 +  // ucontext info.
    1.51 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
    1.52 +    *fr_addr = jt->pd_last_frame();
    1.53 +    return true;
    1.54 +  }
    1.55 +
    1.56 +  ucontext_t* uc = (ucontext_t*) ucontext;
    1.57 +
    1.58 +  // At this point, we don't have a walkable last_Java_frame, so
    1.59 +  // we try to glean some information out of the ucontext.
    1.60 +  intptr_t* ret_sp;
    1.61 +  ExtendedPC addr =
    1.62 +    os::fetch_frame_from_context(uc, &ret_sp,
    1.63 +                                 NULL /* ret_fp only used on X86 */);
    1.64 +  if (addr.pc() == NULL || ret_sp == NULL) {
    1.65 +    // ucontext wasn't useful
    1.66 +    return false;
    1.67 +  }
    1.68 +
    1.69 +  // we were running Java code when SIGPROF came in
    1.70 +  if (isInJava) {
    1.71 +    // If we have a last_Java_sp, then the SIGPROF signal caught us
    1.72 +    // right when we were transitioning from _thread_in_Java to a new
    1.73 +    // JavaThreadState. We use last_Java_sp instead of the sp from
    1.74 +    // the ucontext since it should be more reliable.
    1.75 +    if (jt->has_last_Java_frame()) {
    1.76 +      ret_sp = jt->last_Java_sp();
    1.77 +    }
    1.78 +    // Implied else: we don't have a last_Java_sp so we use what we
    1.79 +    // got from the ucontext.
    1.80 +
    1.81 +    frame ret_frame(ret_sp, frame::unpatchable, addr.pc());
    1.82 +    if (!ret_frame.safe_for_sender(jt)) {
    1.83 +      // nothing else to try if the frame isn't good
    1.84 +      return false;
    1.85 +    }
    1.86 +    *fr_addr = ret_frame;
    1.87 +    return true;
    1.88 +  }
    1.89 +
    1.90 +  // At this point, we know we weren't running Java code. We might
    1.91 +  // have a last_Java_sp, but we don't have a walkable frame.
    1.92 +  // However, we might still be able to construct something useful
    1.93 +  // if the thread was running native code.
    1.94 +  if (jt->has_last_Java_frame()) {
    1.95 +    assert(!jt->frame_anchor()->walkable(), "case covered above");
    1.96 +
    1.97 +    if (jt->thread_state() == _thread_in_native) {
    1.98 +      frame ret_frame(jt->last_Java_sp(), frame::unpatchable, addr.pc());
    1.99 +      if (!ret_frame.safe_for_sender(jt)) {
   1.100 +        // nothing else to try if the frame isn't good
   1.101 +        return false;
   1.102 +      }
   1.103 +      *fr_addr = ret_frame;
   1.104 +      return true;
   1.105 +    }
   1.106 +  }
   1.107 +
   1.108 +  // nothing else to try
   1.109 +  return false;
   1.110 +}

mercurial