forte.cpp revision 1472
0N/A/*
3909N/A * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
1008N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1008N/A *
1008N/A * This code is free software; you can redistribute it and/or modify it
1008N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation.
1008N/A *
2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1008N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1008N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1008N/A * version 2 for more details (a copy is included in the LICENSE file that
1008N/A * accompanied this code).
1008N/A *
1008N/A * You should have received a copy of the GNU General Public License version
1008N/A * 2 along with this work; if not, write to the Free Software Foundation,
1008N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1008N/A *
1008N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1008N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2362N/A *
2362N/A */
1008N/A
1008N/A# include "incls/_precompiled.incl"
1008N/A# include "incls/_forte.cpp.incl"
1008N/A
0N/A// These name match the names reported by the forte quality kit
0N/Aenum {
1821N/A ticks_no_Java_frame = 0,
1821N/A ticks_no_class_load = -1,
1821N/A ticks_GC_active = -2,
1821N/A ticks_unknown_not_Java = -3,
1821N/A ticks_not_walkable_not_Java = -4,
1821N/A ticks_unknown_Java = -5,
1821N/A ticks_not_walkable_Java = -6,
1821N/A ticks_unknown_state = -7,
1821N/A ticks_thread_exit = -8,
1821N/A ticks_deopt = -9,
2391N/A ticks_safepoint = -10
1821N/A};
1821N/A
2391N/A//-------------------------------------------------------
1821N/A
1821N/A// Native interfaces for use by Forte tools.
1821N/A
2391N/A
1821N/A#ifndef IA64
1821N/A
1821N/Aclass vframeStreamForte : public vframeStreamCommon {
1821N/A public:
1821N/A // constructor that starts with sender of frame fr (top_frame)
1821N/A vframeStreamForte(JavaThread *jt, frame fr, bool stop_at_java_call_stub);
1821N/A void forte_next();
1821N/A};
1821N/A
1821N/A
1821N/Astatic bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm);
1821N/Astatic bool is_decipherable_interpreted_frame(JavaThread* thread,
1008N/A frame* fr,
1008N/A methodOop* method_p,
1821N/A int* bci_p);
1008N/A
1008N/A
1008N/A
1008N/A
1008N/AvframeStreamForte::vframeStreamForte(JavaThread *jt,
1821N/A frame fr,
1821N/A bool stop_at_java_call_stub) : vframeStreamCommon(jt) {
1821N/A
1821N/A _stop_at_java_call_stub = stop_at_java_call_stub;
1821N/A _frame = fr;
1821N/A
1821N/A // We must always have a valid frame to start filling
1821N/A
2228N/A bool filled_in = fill_from_frame();
2228N/A
2228N/A assert(filled_in, "invariant");
2228N/A
1821N/A}
0N/A
4634N/A
4634N/A// Solaris SPARC Compiler1 needs an additional check on the grandparent
4634N/A// of the top_frame when the parent of the top_frame is interpreted and
4634N/A// the grandparent is compiled. However, in this method we do not know
4634N/A// the relationship of the current _frame relative to the top_frame so
4634N/A// we implement a more broad sanity check. When the previous callee is
4634N/A// interpreted and the current sender is compiled, we verify that the
4634N/A// current sender is also walkable. If it is not walkable, then we mark
4634N/A// the current vframeStream as at the end.
2402N/Avoid vframeStreamForte::forte_next() {
2402N/A // handle frames with inlining
2402N/A if (_mode == compiled_mode &&
2402N/A vframeStreamCommon::fill_in_compiled_inlined_sender()) {
2402N/A return;
2402N/A }
2402N/A
2402N/A // handle general case
2402N/A
2402N/A int loop_count = 0;
2402N/A int loop_max = MaxJavaStackTraceDepth * 2;
2402N/A
2402N/A
2402N/A do {
2402N/A
2402N/A loop_count++;
2402N/A
2402N/A // By the time we get here we should never see unsafe but better
2402N/A // safe then segv'd
0N/A
0N/A if (loop_count > loop_max || !_frame.safe_for_sender(_thread)) {
1008N/A _mode = at_end_mode;
1821N/A return;
1821N/A }
1821N/A
2228N/A _frame = _frame.sender(&_reg_map);
2228N/A
2228N/A } while (!fill_from_frame());
2228N/A}
2228N/A
2228N/A// Determine if 'fr' is a decipherable compiled frame. We are already
2228N/A// assured that fr is for a java nmethod.
2228N/A
2228N/Astatic bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm) {
2228N/A assert(nm->is_java_method(), "invariant");
2402N/A
2402N/A if (thread->has_last_Java_frame() && thread->last_Java_pc() == fr->pc()) {
2402N/A // We're stopped at a call into the JVM so look for a PcDesc with
2402N/A // the actual pc reported by the frame.
2402N/A PcDesc* pc_desc = nm->pc_desc_at(fr->pc());
4634N/A
2402N/A // Did we find a useful PcDesc?
2402N/A if (pc_desc != NULL &&
2402N/A pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) {
2402N/A return true;
2402N/A }
2402N/A }
2402N/A
2402N/A // We're at some random pc in the nmethod so search for the PcDesc
2402N/A // whose pc is greater than the current PC. It's done this way
2402N/A // because the extra PcDescs that are recorded for improved debug
2402N/A // info record the end of the region covered by the ScopeDesc
2402N/A // instead of the beginning.
2402N/A PcDesc* pc_desc = nm->pc_desc_near(fr->pc() + 1);
2402N/A
2402N/A // Now do we have a useful PcDesc?
2402N/A if (pc_desc == NULL ||
1821N/A pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) {
2228N/A // No debug information available for this pc
2228N/A // vframeStream would explode if we try and walk the frames.
2228N/A return false;
2228N/A }
2228N/A
2228N/A // This PcDesc is useful however we must adjust the frame's pc
2228N/A // so that the vframeStream lookups will use this same pc
2228N/A fr->set_pc(pc_desc->real_pc(nm));
2228N/A return true;
2228N/A}
2228N/A
1821N/A
1821N/A// Determine if 'fr' is a walkable interpreted frame. Returns false
1821N/A// if it is not. *method_p, and *bci_p are not set when false is
2228N/A// returned. *method_p is non-NULL if frame was executing a Java
2228N/A// method. *bci_p is != -1 if a valid BCI in the Java method could
2228N/A// be found.
2228N/A// Note: this method returns true when a valid Java method is found
2228N/A// even if a valid BCI cannot be found.
1821N/A
2228N/Astatic bool is_decipherable_interpreted_frame(JavaThread* thread,
1821N/A frame* fr,
2228N/A methodOop* method_p,
2228N/A int* bci_p) {
1821N/A assert(fr->is_interpreted_frame(), "just checking");
2228N/A
1821N/A // top frame is an interpreted frame
1821N/A // check if it is walkable (i.e. valid methodOop and valid bci)
1821N/A
1821N/A // Because we may be racing a gc thread the method and/or bci
1821N/A // of a valid interpreter frame may look bad causing us to
1821N/A // fail the is_interpreted_frame_valid test. If the thread
1821N/A // is in any of the following states we are assured that the
1821N/A // frame is in fact valid and we must have hit the race.
1821N/A
1821N/A JavaThreadState state = thread->thread_state();
2228N/A bool known_valid = (state == _thread_in_native ||
1821N/A state == _thread_in_vm ||
1821N/A state == _thread_blocked );
1821N/A
1821N/A if (known_valid || fr->is_interpreted_frame_valid(thread)) {
1821N/A
1821N/A // The frame code should completely validate the frame so that
1821N/A // references to methodOop and bci are completely safe to access
1821N/A // If they aren't the frame code should be fixed not this
0N/A // code. However since gc isn't locked out the values could be
1821N/A // stale. This is a race we can never completely win since we can't
1008N/A // lock out gc so do one last check after retrieving their values
0N/A // from the frame for additional safety
0N/A
2228N/A methodOop method = fr->interpreter_frame_method();
2228N/A
2228N/A // We've at least found a method.
2228N/A // NOTE: there is something to be said for the approach that
2228N/A // if we don't find a valid bci then the method is not likely
2228N/A // a valid method. Then again we may have caught an interpreter
0N/A // frame in the middle of construction and the bci field is
1821N/A // not yet valid.
0N/A
1008N/A *method_p = method;
1008N/A
1008N/A // See if gc may have invalidated method since we validated frame
1008N/A
2228N/A if (!Universe::heap()->is_valid_method(method)) return false;
1008N/A
2228N/A intptr_t bcx = fr->interpreter_frame_bcx();
2228N/A
0N/A int bci = method->validate_bci_from_bcx(bcx);
1008N/A
1008N/A // note: bci is set to -1 if not a valid bci
1008N/A *bci_p = bci;
2228N/A return true;
2228N/A }
2228N/A
2228N/A return false;
2228N/A}
2228N/A
2228N/A
1008N/A// Determine if 'fr' can be used to find an initial Java frame.
1008N/A// Return false if it can not find a fully decipherable Java frame
1008N/A// (in other words a frame that isn't safe to use in a vframe stream).
1008N/A// Obviously if it can't even find a Java frame false will also be returned.
1008N/A//
1008N/A// If we find a Java frame decipherable or not then by definition we have
1821N/A// identified a method and that will be returned to the caller via method_p.
1008N/A// If we can determine a bci that is returned also. (Hmm is it possible
1008N/A// to return a method and bci and still return false? )
0N/A//
0N/A// The initial Java frame we find (if any) is return via initial_frame_p.
1008N/A//
1008N/A
1008N/Astatic bool find_initial_Java_frame(JavaThread* thread,
1008N/A frame* fr,
1008N/A frame* initial_frame_p,
0N/A methodOop* method_p,
1821N/A int* bci_p) {
1821N/A
1821N/A // It is possible that for a frame containing an nmethod
1821N/A // we can capture the method but no bci. If we get no
1821N/A // bci the frame isn't walkable but the method is usable.
1821N/A // Therefore we init the returned methodOop to NULL so the
1821N/A // caller can make the distinction.
1821N/A
1821N/A *method_p = NULL;
1821N/A
1821N/A // On the initial call to this method the frame we get may not be
1821N/A // recognizable to us. This should only happen if we are in a JRT_LEAF
1821N/A // or something called by a JRT_LEAF method.
1821N/A
1821N/A
2402N/A
2402N/A frame candidate = *fr;
2402N/A
2391N/A // If the starting frame we were given has no codeBlob associated with
2391N/A // it see if we can find such a frame because only frames with codeBlobs
1008N/A // are possible Java frames.
1008N/A
1008N/A if (fr->cb() == NULL) {
1008N/A
1008N/A // See if we can find a useful frame
0N/A int loop_count;
1008N/A int loop_max = MaxJavaStackTraceDepth * 2;
1008N/A RegisterMap map(thread, false);
2391N/A
1008N/A for (loop_count = 0; loop_count < loop_max; loop_count++) {
3866N/A if (!candidate.safe_for_sender(thread)) return false;
1008N/A candidate = candidate.sender(&map);
1821N/A if (candidate.cb() != NULL) break;
1821N/A }
1821N/A if (candidate.cb() == NULL) return false;
1821N/A }
1821N/A
1821N/A // We have a frame known to be in the codeCache
1947N/A // We will hopefully be able to figure out something to do with it.
1947N/A int loop_count;
1947N/A int loop_max = MaxJavaStackTraceDepth * 2;
1947N/A RegisterMap map(thread, false);
1947N/A
1947N/A for (loop_count = 0; loop_count < loop_max; loop_count++) {
1947N/A
1947N/A if (candidate.is_first_frame()) {
1947N/A // If initial frame is frame from StubGenerator and there is no
2017N/A // previous anchor, there are no java frames associated with a method
1947N/A return false;
1821N/A }
1821N/A
1947N/A if (candidate.is_interpreted_frame()) {
1821N/A if (is_decipherable_interpreted_frame(thread, &candidate, method_p, bci_p)) {
1947N/A *initial_frame_p = candidate;
1947N/A return true;
1821N/A }
2017N/A
1821N/A // Hopefully we got some data
1821N/A return false;
1821N/A }
1821N/A
1821N/A if (candidate.cb()->is_nmethod()) {
1821N/A
1821N/A nmethod* nm = (nmethod*) candidate.cb();
1821N/A *method_p = nm->method();
1947N/A
1821N/A // If the frame isn't fully decipherable then the default
1821N/A // value for the bci is a signal that we don't have a bci.
1821N/A // If we have a decipherable frame this bci value will
1947N/A // not be used.
1947N/A
1947N/A *bci_p = -1;
1821N/A
1821N/A *initial_frame_p = candidate;
1821N/A
1821N/A // Native wrapper code is trivial to decode by vframeStream
1821N/A
2500N/A if (nm->is_native_method()) return true;
1821N/A
1821N/A // If it isn't decipherable then we have found a pc that doesn't
1821N/A // have a PCDesc that can get us a bci however we did find
1821N/A // a method
3866N/A
3866N/A if (!is_decipherable_compiled_frame(thread, &candidate, nm)) {
3866N/A return false;
2203N/A }
1947N/A
1821N/A // is_decipherable_compiled_frame may modify candidate's pc
1008N/A *initial_frame_p = candidate;
1008N/A
0N/A assert(nm->pc_desc_at(candidate.pc()) != NULL, "if it's decipherable then pc must be valid");
1008N/A
1008N/A return true;
1008N/A }
0N/A
1008N/A // Must be some stub frame that we don't care about
1008N/A
1008N/A if (!candidate.safe_for_sender(thread)) return false;
2500N/A candidate = candidate.sender(&map);
0N/A
0N/A // If it isn't in the code cache something is wrong
0N/A // since once we find a frame in the code cache they
1008N/A // all should be there.
1008N/A
1008N/A if (candidate.cb() == NULL) return false;
1008N/A
1008N/A }
1008N/A
1008N/A return false;
1008N/A
1934N/A}
1934N/A
1934N/A
1934N/A// call frame copied from old .h file and renamed
1934N/Atypedef struct {
1008N/A jint lineno; // line number in the source file
1008N/A jmethodID method_id; // method executed in this frame
1008N/A} ASGCT_CallFrame;
1008N/A
1821N/A// call trace copied from old .h file and renamed
1821N/Atypedef struct {
1821N/A JNIEnv *env_id; // Env where trace was recorded
1821N/A jint num_frames; // number of frames in this trace
1821N/A ASGCT_CallFrame *frames; // frames
1821N/A} ASGCT_CallTrace;
1821N/A
1821N/Astatic void forte_fill_call_trace_given_top(JavaThread* thd,
1821N/A ASGCT_CallTrace* trace,
2020N/A int depth,
2020N/A frame top_frame) {
1821N/A NoHandleMark nhm;
1821N/A
1821N/A frame initial_Java_frame;
1821N/A methodOop method;
1821N/A int bci;
1821N/A int count;
1821N/A
1934N/A count = 0;
1821N/A assert(trace->frames != NULL, "trace->frames must be non-NULL");
1821N/A
1821N/A bool fully_decipherable = find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci);
1821N/A
3866N/A // The frame might not be walkable but still recovered a method
1821N/A // (e.g. an nmethod with no scope info for the pc
1821N/A
3866N/A if (method == NULL) return;
1821N/A
1934N/A CollectedHeap* ch = Universe::heap();
2500N/A
2228N/A // The method is not stored GC safe so see if GC became active
1934N/A // after we entered AsyncGetCallTrace() and before we try to
1934N/A // use the methodOop.
2228N/A // Yes, there is still a window after this check and before
1934N/A // we use methodOop below, but we can't lock out GC so that
1934N/A // has to be an acceptable risk.
1821N/A if (!ch->is_valid_method(method)) {
1821N/A trace->num_frames = ticks_GC_active; // -2
3866N/A return;
1821N/A }
1821N/A
1821N/A // We got a Java frame however it isn't fully decipherable
1821N/A // so it won't necessarily be safe to use it for the
1821N/A // initial frame in the vframe stream.
1008N/A
1008N/A if (!fully_decipherable) {
1934N/A // Take whatever method the top-frame decoder managed to scrape up.
1934N/A // We look further at the top frame only if non-safepoint
1934N/A // debugging information is available.
1934N/A count++;
1821N/A trace->num_frames = count;
1821N/A trace->frames[0].method_id = method->find_jmethod_id_or_null();
3740N/A if (!method->is_native()) {
3866N/A trace->frames[0].lineno = bci;
1821N/A } else {
1821N/A trace->frames[0].lineno = -3;
3740N/A }
3866N/A
1821N/A if (!initial_Java_frame.safe_for_sender(thd)) return;
1821N/A
2017N/A RegisterMap map(thd, false);
1821N/A initial_Java_frame = initial_Java_frame.sender(&map);
2017N/A }
1821N/A
1821N/A vframeStreamForte st(thd, initial_Java_frame, false);
1821N/A
1821N/A for (; !st.at_end() && count < depth; st.forte_next(), count++) {
1821N/A bci = st.bci();
1821N/A method = st.method();
1821N/A
1821N/A // The method is not stored GC safe so see if GC became active
1821N/A // after we entered AsyncGetCallTrace() and before we try to
1821N/A // use the methodOop.
3740N/A // Yes, there is still a window after this check and before
1821N/A // we use methodOop below, but we can't lock out GC so that
1821N/A // has to be an acceptable risk.
1821N/A if (!ch->is_valid_method(method)) {
1821N/A // we throw away everything we've gathered in this sample since
3740N/A // none of it is safe
3740N/A trace->num_frames = ticks_GC_active; // -2
1821N/A return;
3740N/A }
1821N/A
1821N/A trace->frames[count].method_id = method->find_jmethod_id_or_null();
1821N/A if (!method->is_native()) {
1821N/A trace->frames[count].lineno = bci;
1821N/A } else {
3740N/A trace->frames[count].lineno = -3;
3740N/A }
3740N/A }
1821N/A trace->num_frames = count;
2017N/A return;
2017N/A}
2017N/A
1821N/A
3740N/A// Forte Analyzer AsyncGetCallTrace() entry point. Currently supported
1821N/A// on Linux X86, Solaris SPARC and Solaris X86.
1821N/A//
2017N/A// Async-safe version of GetCallTrace being called from a signal handler
1934N/A// when a LWP gets interrupted by SIGPROF but the stack traces are filled
1934N/A// with different content (see below).
1934N/A//
1821N/A// This function must only be called when JVM/TI
1821N/A// CLASS_LOAD events have been enabled since agent startup. The enabled
3740N/A// event will cause the jmethodIDs to be allocated at class load time.
1821N/A// The jmethodIDs cannot be allocated in a signal handler because locks
1821N/A// cannot be grabbed in a signal handler safely.
1821N/A//
1821N/A// void (*AsyncGetCallTrace)(ASGCT_CallTrace *trace, jint depth, void* ucontext)
3740N/A//
1821N/A// Called by the profiler to obtain the current method call stack trace for
1821N/A// a given thread. The thread is identified by the env_id field in the
1821N/A// ASGCT_CallTrace structure. The profiler agent should allocate a ASGCT_CallTrace
1821N/A// structure with enough memory for the requested stack depth. The VM fills in
1821N/A// the frames buffer and the num_frames field.
3740N/A//
1821N/A// Arguments:
1821N/A//
1821N/A// trace - trace data structure to be filled by the VM.
1821N/A// depth - depth of the call stack trace.
1821N/A// ucontext - ucontext_t of the LWP
3740N/A//
1821N/A// ASGCT_CallTrace:
1821N/A// typedef struct {
2017N/A// JNIEnv *env_id;
1934N/A// jint num_frames;
1934N/A// ASGCT_CallFrame *frames;
1934N/A// } ASGCT_CallTrace;
1821N/A//
1821N/A// Fields:
3740N/A// env_id - ID of thread which executed this trace.
1821N/A// num_frames - number of frames in the trace.
1821N/A// (< 0 indicates the frame is not walkable).
1821N/A// frames - the ASGCT_CallFrames that make up this trace. Callee followed by callers.
1821N/A//
3740N/A// ASGCT_CallFrame:
3740N/A// typedef struct {
1821N/A// jint lineno;
3740N/A// jmethodID method_id;
1821N/A// } ASGCT_CallFrame;
1821N/A//
1821N/A// Fields:
1821N/A// 1) For Java frame (interpreted and compiled),
3740N/A// lineno - bci of the method being executed or -1 if bci is not available
1821N/A// method_id - jmethodID of the method being executed
1821N/A// 2) For native method
1821N/A// lineno - (-3)
1821N/A// method_id - jmethodID of the method being executed
3740N/A
1821N/Aextern "C" {
1821N/Avoid AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
2546N/A
1821N/A// This is if'd out because we no longer use thread suspension.
3740N/A// However if someone wanted to backport this to a 5.0 jvm then this
3887N/A// code would be important.
2402N/A#if 0
2546N/A if (SafepointSynchronize::is_synchronizing()) {
2017N/A // The safepoint mechanism is trying to synchronize all the threads.
2546N/A // Since this can involve thread suspension, it is not safe for us
1821N/A // to be here. We can reduce the deadlock risk window by quickly
4499N/A // returning to the SIGPROF handler. However, it is still possible
2546N/A // for VMThread to catch us here or in the SIGPROF handler. If we
1821N/A // are suspended while holding a resource and another thread blocks
2017N/A // on that resource in the SIGPROF handler, then we will have a
1934N/A // three-thread deadlock (VMThread, this thread, the other thread).
1934N/A trace->num_frames = ticks_safepoint; // -10
1934N/A return;
4499N/A }
4499N/A#endif
4499N/A
4499N/A JavaThread* thread;
1821N/A
1821N/A if (trace->env_id == NULL ||
1821N/A (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
3740N/A thread->is_exiting()) {
1821N/A
1821N/A // bad env_id, thread has exited or thread is exiting
1821N/A trace->num_frames = ticks_thread_exit; // -8
1821N/A return;
3740N/A }
1821N/A
1821N/A if (thread->in_deopt_handler()) {
1821N/A // thread is in the deoptimization handler so return no frames
1821N/A trace->num_frames = ticks_deopt; // -9
1821N/A return;
3740N/A }
1821N/A
2017N/A assert(JavaThread::current() == thread,
2017N/A "AsyncGetCallTrace must be called by the current interrupted thread");
2017N/A
1821N/A if (!JvmtiExport::should_post_class_load()) {
3740N/A trace->num_frames = ticks_no_class_load; // -1
3740N/A return;
2402N/A }
1821N/A
1821N/A if (Universe::heap()->is_gc_active()) {
2017N/A trace->num_frames = ticks_GC_active; // -2
1934N/A return;
1934N/A }
1934N/A
1821N/A switch (thread->thread_state()) {
1821N/A case _thread_new:
1821N/A case _thread_uninitialized:
3740N/A case _thread_new_trans:
1821N/A // We found the thread on the threads list above, but it is too
1821N/A // young to be useful so return that there are no Java frames.
1821N/A trace->num_frames = 0;
1821N/A break;
3740N/A case _thread_in_native:
1821N/A case _thread_in_native_trans:
1821N/A case _thread_blocked:
2017N/A case _thread_blocked_trans:
1821N/A case _thread_in_vm:
3740N/A case _thread_in_vm_trans:
1940N/A {
2017N/A frame fr;
2017N/A
2017N/A // param isInJava == false - indicate we aren't in Java code
1821N/A if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, false)) {
3740N/A trace->num_frames = ticks_unknown_not_Java; // -3 unknown frame
3740N/A } else {
3740N/A if (!thread->has_last_Java_frame()) {
2402N/A trace->num_frames = 0; // No Java frames
2500N/A } else {
1821N/A trace->num_frames = ticks_not_walkable_not_Java; // -4 non walkable frame by default
2017N/A forte_fill_call_trace_given_top(thread, trace, depth, fr);
1934N/A
1934N/A // This assert would seem to be valid but it is not.
1934N/A // It would be valid if we weren't possibly racing a gc
1821N/A // thread. A gc thread can make a valid interpreted frame
1821N/A // look invalid. It's a small window but it does happen.
3740N/A // The assert is left here commented out as a reminder.
1821N/A // assert(trace->num_frames != ticks_not_walkable_not_Java, "should always be walkable");
1821N/A
1821N/A }
1821N/A }
1821N/A }
2017N/A break;
2017N/A case _thread_in_Java:
2017N/A case _thread_in_Java_trans:
1821N/A {
1821N/A frame fr;
1821N/A
1821N/A // param isInJava == true - indicate we are in Java code
1821N/A if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, true)) {
1821N/A trace->num_frames = ticks_unknown_Java; // -5 unknown frame
1821N/A } else {
1008N/A trace->num_frames = ticks_not_walkable_Java; // -6, non walkable frame by default
1008N/A forte_fill_call_trace_given_top(thread, trace, depth, fr);
1821N/A }
1821N/A }
1821N/A break;
1821N/A default:
2020N/A // Unknown thread state
2020N/A trace->num_frames = ticks_unknown_state; // -7
2020N/A break;
1821N/A }
1821N/A}
1821N/A
1821N/A
1821N/A#ifndef _WINDOWS
2020N/A// Support for the Forte(TM) Peformance Tools collector.
2020N/A//
2017N/A// The method prototype is derived from libcollector.h. For more
2020N/A// information, please see the libcollect man page.
2020N/A
1821N/A// Method to let libcollector know about a dynamically loaded function.
2020N/A// Because it is weakly bound, the calls become NOP's when the library
2020N/A// isn't present.
1008N/Avoid collector_func_load(char* name,
1821N/A void* null_argument_1,
1821N/A void* null_argument_2,
1821N/A void *vaddr,
1821N/A int size,
1821N/A int zero_argument,
1821N/A void* null_argument_3);
1821N/A#pragma weak collector_func_load
1821N/A#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
1821N/A ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 )
1821N/A#endif // !_WINDOWS
1821N/A
1821N/A} // end extern "C"
1821N/A#endif // !IA64
1821N/A
1821N/Avoid Forte::register_stub(const char* name, address start, address end) {
1821N/A#if !defined(_WINDOWS) && !defined(IA64)
1821N/A assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
1821N/A "Code size exceeds maximum range");
1821N/A
1821N/A collector_func_load((char*)name, NULL, NULL, start,
1947N/A pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
1008N/A#endif // !_WINDOWS && !IA64
2402N/A}
2402N/A