/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "jvmtifiles/jvmtiEnv.hpp"
#include "memory/gcLocker.hpp"
#include "memory/resourceArea.hpp"
#include "prims/jvmtiEventController.inline.hpp"
#include "prims/jvmtiImpl.hpp"
#include "prims/jvmtiThreadState.inline.hpp"
#include "runtime/vframe.hpp"
// marker for when the stack depth has been reset and is now unknown.
// any negative number would work but small ones might obscure an
// underrun error.
///////////////////////////////////////////////////////////////
//
// class JvmtiThreadState
//
// Instances of JvmtiThreadState hang off of each thread.
// Thread local storage for JVMTI.
//
: _thread_event_enable() {
_exception_detected = false;
_exception_caught = false;
_debuggable = true;
_hide_single_stepping = false;
_hide_level = 0;
_pending_step_for_popframe = false;
// JVMTI ForceEarlyReturn support
_pending_step_for_earlyret = false;
_earlyret_value.j = 0L;
// add all the JvmtiEnvThreadState to the new JvmtiThreadState
{
}
}
}
// link us into the list
{
// The thread state list manipulation code must not have safepoints.
// See periodic_clean_up().
}
_head = this;
}
// set this as the state for the thread
thread->set_jvmti_thread_state(this);
}
// clear this as the state for the thread
// zap our env thread states
{
JvmtiEnvThreadStateIterator it(this);
delete zap;
}
}
// remove us from the list
{
// The thread state list manipulation code must not have safepoints.
// See periodic_clean_up().
} else {
}
}
}
}
void
// This iteration is initialized with "_head" instead of "JvmtiThreadState::first()"
// because the latter requires the JvmtiThreadState_lock.
// This iteration is safe at a safepoint as well, see the No_Safepoint_Verifier
// asserts at all list manipulation sites.
// For each environment thread state corresponding to an invalid environment
// unlink it from the list and deallocate it.
previous_ets = ets;
} else {
// This one isn't valid, remove it from the list and deallocate it
if (previous_ets == NULL) {
} else {
}
delete defunct_ets;
}
}
}
}
// add this environment thread state to the end of the list (order is important)
{
// list deallocation (which occurs at a safepoint) cannot occur simultaneously
JvmtiEnvThreadStateIterator it(this);
previous_ets = ets;
}
if (previous_ets == NULL) {
} else {
}
}
}
}
}
// Helper routine used in several places
#ifdef ASSERT
#endif
"at safepoint or must be suspended");
int n = 0;
// tty->print_cr("CSD: counting frames on %s ...",
// JvmtiTrace::safe_get_thread_name(get_thread()));
// tty->print_cr("CSD: frame - method %s.%s - loc %d",
// method->klass_name()->as_C_string(),
// method->name()->as_C_string(),
// jvf->bci() );
n++;
}
// tty->print_cr("CSD: frame count: %d", n);
return n;
}
// The caller can be the VMThread at a safepoint, the current thread
// or the target thread must be suspended.
"sanity check");
}
if (!is_interp_only_mode()) {
}
if (_cur_stack_depth != UNKNOWN_STACK_DEPTH) {
}
}
if (!is_interp_only_mode()) {
}
if (_cur_stack_depth != UNKNOWN_STACK_DEPTH) {
}
}
"must be current thread or suspended");
} else {
// heavy weight assert
"cur_stack_depth out of sync");
}
return _cur_stack_depth;
}
}
// We are single stepping as the last part of the PopFrame() dance
// so we have some house keeping to do.
// If the popframe_condition field is not popframe_inactive, then
// we missed all of the popframe_field cleanup points:
//
// - unpack_frames() was not called (nothing to deopt)
// - remove_activation_preserving_args_entry() was not called
// (did not get suspended in a call_vm() family call and did
// not complete a call_vm() family call on the way here)
}
// clearing the flag indicates we are done with the PopFrame() dance
// If exception was thrown in this frame, need to reset jvmti thread state.
// Single stepping may not get enabled correctly by the agent since
// exception state is passed in MethodExit event which may be sent at some
// time in the future. JDWP agent ignores MethodExit events if caused by
// an exception.
//
if (is_exception_detected()) {
}
// If step is pending for popframe then it may not be
// a repeat step. The new_bci and method_id is same as current_bci
// and current method_id after pop and step for recursive calls.
// Force the step by clearing the last location.
JvmtiEnvThreadStateIterator it(this);
}
}
// Class: JvmtiThreadState
// Function: update_for_pop_top_frame
// Description:
// This function removes any frame pop notification request for
// the top frame and invalidates both the current stack depth and
// all cached frameIDs.
//
// Called by: PopFrame
//
if (is_interp_only_mode()) {
// remove any frame pop notification request for the top frame
// in any environment
{
JvmtiEnvThreadStateIterator it(this);
}
}
}
// force stack depth to be recalculated
} else {
}
}
// We are single stepping as the last part of the ForceEarlyReturn
// dance so we have some house keeping to do.
if (is_earlyret_pending()) {
// If the earlyret_state field is not earlyret_inactive, then
// we missed all of the earlyret_field cleanup points:
//
// - remove_activation() was not called
// (did not get suspended in a call_vm() family call and did
// not complete a call_vm() family call on the way here)
//
// One legitimate way for us to miss all the cleanup points is
// if we got here right after handling a compiled return. If that
// is the case, then we consider our return from compiled code to
// complete the ForceEarlyReturn request and we clear the condition.
}
// clearing the flag indicates we are done with
// the ForceEarlyReturn() dance
// If exception was thrown in this frame, need to reset jvmti thread state.
// Single stepping may not get enabled correctly by the agent since
// exception state is passed in MethodExit event which may be sent at some
// time in the future. JDWP agent ignores MethodExit events if caused by
// an exception.
//
if (is_exception_detected()) {
}
// If step is pending for earlyret then it may not be a repeat step.
// The new_bci and method_id is same as current_bci and current
// method_id after earlyret and step for recursive calls.
// Force the step by clearing the last location.
JvmtiEnvThreadStateIterator it(this);
}
}
}