7a1bf87c6e
2007-02-15 Kyle Galloway <kgallowa@redhat.com> * interpret.cc (_Jv_InterpMethod::check_handler): New method. * interpret-run.cc: Change the catch section to report exception events and to use the new check_handler method. * include/java-interp.h (_Jv_InterpMethod): Add check_handler. * gnu/gcj/jvmti/ExceptionEvent.java: New file. * gnu/gcj/jvmti/ExceptionEvent.h: New file. * gnu/gcj/jvmti/natExceptionEvent.cc: New file. * libjava/classpath/lib/gnu/gcj/jvmti/ExceptionEvent.class: New file. * sources.am: Added ExceptionEvent.java. * Makefile.am: Added natExceptionEvent.cc * Makefile.in: Regenerated. * include/Makefile.in: Regenerated. * gcj/Makefile.in: Regenerated. From-SVN: r122019
60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
// natExceptionEvent.cc - C++ code for JVMTI Exception events
|
|
|
|
/* Copyright (C) 2007 Free Software Foundation
|
|
|
|
This file is part of libgcj.
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
details. */
|
|
|
|
#include <config.h>
|
|
#include <gcj/cni.h>
|
|
#include <gcj/method.h>
|
|
#include <java-interp.h>
|
|
#include <java-insns.h>
|
|
#include <java-assert.h>
|
|
#include <jvmti.h>
|
|
#include <jvmti-int.h>
|
|
|
|
#include <gnu/gcj/jvmti/ExceptionEvent.h>
|
|
|
|
void
|
|
gnu::gcj::jvmti::ExceptionEvent::sendEvent ()
|
|
{
|
|
// Check if the exception is caught somewhere in the interpreted call stack
|
|
if (_catchMeth == 0 || _catchLoc == 0)
|
|
checkCatch ();
|
|
|
|
JNIEnv *jni = _Jv_GetCurrentJNIEnv ();
|
|
|
|
_Jv_JVMTI_PostEvent (JVMTI_EVENT_EXCEPTION, _thread, jni,
|
|
reinterpret_cast<jmethodID> (_throwMeth),
|
|
static_cast<jlocation> (_throwLoc), _ex,
|
|
reinterpret_cast<jmethodID> (_catchMeth),
|
|
static_cast<jlocation> (_catchLoc));
|
|
}
|
|
|
|
// This method looks up the interpreted call stack to see if the exception will
|
|
// eventually be caught by some java method.
|
|
void
|
|
gnu::gcj::jvmti::ExceptionEvent::checkCatch ()
|
|
{
|
|
_Jv_InterpFrame *frame
|
|
= reinterpret_cast<_Jv_InterpFrame *> (_thread->interp_frame);
|
|
|
|
while ((frame = frame->next_interp))
|
|
{
|
|
_Jv_InterpMethod *meth
|
|
= reinterpret_cast<_Jv_InterpMethod *> (frame->self);
|
|
pc_t pc = frame->pc;
|
|
|
|
if (meth->check_handler (&pc, meth, _ex))
|
|
{
|
|
_catchMeth = reinterpret_cast<jlong> (meth->get_method ());
|
|
_catchLoc = meth->insn_index (pc);
|
|
break;
|
|
}
|
|
}
|
|
}
|