aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2007-01-27 16:34:32 +0000
committerKeith Seitz <kseitz@gcc.gnu.org>2007-01-27 16:34:32 +0000
commitea6244280b016b12843432c1381a2a9064f60d00 (patch)
tree2551b9d83c81be4bbd40c4ac824bff75b75668be
parent9eab67850ba2faf07c1bb3e4f12b4754003066cc (diff)
downloadgcc-ea6244280b016b12843432c1381a2a9064f60d00.zip
gcc-ea6244280b016b12843432c1381a2a9064f60d00.tar.gz
gcc-ea6244280b016b12843432c1381a2a9064f60d00.tar.bz2
* gnu/classpath/jdwp/natVMVirtualMachine.cc
(getAllClassMethods): Move error handling to ... (throw_jvmti_error): ... here. (jdwpClassPrepareCB): New function. (jdwpThreadEndCB): New function. (jdwpThreadStartCB): New function. (jdwpVMDeathCB): New function. (jdwpVMInitCB): Define and enable callbacks for ClassPrepare, ThreadEnd, ThreadStart, and VMDeath. From-SVN: r121233
-rw-r--r--libjava/ChangeLog12
-rw-r--r--libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc112
2 files changed, 110 insertions, 14 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 28602c2..4e6e238 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,15 @@
+2007-01-27 Keith Seitz <keiths@redhat.com>
+
+ * gnu/classpath/jdwp/natVMVirtualMachine.cc
+ (getAllClassMethods): Move error handling to ...
+ (throw_jvmti_error): ... here.
+ (jdwpClassPrepareCB): New function.
+ (jdwpThreadEndCB): New function.
+ (jdwpThreadStartCB): New function.
+ (jdwpVMDeathCB): New function.
+ (jdwpVMInitCB): Define and enable callbacks for
+ ClassPrepare, ThreadEnd, ThreadStart, and VMDeath.
+
2007-01-27 Jakub Jelinek <jakub@redhat.com>
* Makefile.am (generic_header_files): Add $(inner_nat_headers).
diff --git a/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc b/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc
index ef4fe28..1e080665 100644
--- a/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc
+++ b/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc
@@ -28,7 +28,11 @@ details. */
#include <gnu/classpath/jdwp/VMFrame.h>
#include <gnu/classpath/jdwp/VMMethod.h>
#include <gnu/classpath/jdwp/VMVirtualMachine.h>
+#include <gnu/classpath/jdwp/event/ClassPrepareEvent.h>
#include <gnu/classpath/jdwp/event/EventRequest.h>
+#include <gnu/classpath/jdwp/event/ThreadEndEvent.h>
+#include <gnu/classpath/jdwp/event/ThreadStartEvent.h>
+#include <gnu/classpath/jdwp/event/VmDeathEvent.h>
#include <gnu/classpath/jdwp/event/VmInitEvent.h>
#include <gnu/classpath/jdwp/exception/InvalidMethodException.h>
#include <gnu/classpath/jdwp/exception/JdwpInternalErrorException.h>
@@ -39,7 +43,12 @@ using namespace gnu::classpath::jdwp::event;
using namespace gnu::classpath::jdwp::util;
// Forward declarations
+static void JNICALL jdwpClassPrepareCB (jvmtiEnv *, JNIEnv *, jthread, jclass);
+static void JNICALL jdwpThreadEndCB (jvmtiEnv *, JNIEnv *, jthread);
+static void JNICALL jdwpThreadStartCB (jvmtiEnv *, JNIEnv *, jthread);
+static void JNICALL jdwpVMDeathCB (jvmtiEnv *, JNIEnv *);
static void JNICALL jdwpVMInitCB (jvmtiEnv *, JNIEnv *, jthread);
+static void throw_jvmti_error (jvmtiError);
#define DEFINE_CALLBACK(Cb,Event) Cb.Event = jdwp ## Event ## CB
#define ENABLE_EVENT(Event,Thread) \
@@ -313,20 +322,7 @@ getAllClassMethods (jclass klass)
jmethodID *methods;
jvmtiError err = _jdwp_jvmtiEnv->GetClassMethods (klass, &count, &methods);
if (err != JVMTI_ERROR_NONE)
- {
- char *error;
- jstring msg;
- if (_jdwp_jvmtiEnv->GetErrorName (err, &error) != JVMTI_ERROR_NONE)
- {
- msg = JvNewStringLatin1 (error);
- _jdwp_jvmtiEnv->Deallocate ((unsigned char *) error);
- }
- else
- msg = JvNewStringLatin1 ("out of memory");
-
- using namespace gnu::classpath::jdwp::exception;
- throw new JdwpInternalErrorException (msg);
- }
+ throw_jvmti_error (err);
JArray<VMMethod *> *result
= (JArray<VMMethod *> *) JvNewObjectArray (count,
@@ -407,10 +403,98 @@ getSourceFile (MAYBE_UNUSED jclass clazz)
return NULL;
}
+static void
+throw_jvmti_error (jvmtiError err)
+{
+ char *error;
+ jstring msg;
+ if (_jdwp_jvmtiEnv->GetErrorName (err, &error) == JVMTI_ERROR_NONE)
+ {
+ msg = JvNewStringLatin1 (error);
+ _jdwp_jvmtiEnv->Deallocate ((unsigned char *) error);
+ }
+ else
+ msg = JvNewStringLatin1 ("out of memory");
+
+ using namespace gnu::classpath::jdwp::exception;
+ throw new JdwpInternalErrorException (msg);
+}
+
+static void JNICALL
+jdwpClassPrepareCB (jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env,
+ jthread thread, jclass klass)
+{
+ using namespace gnu::classpath::jdwp;
+
+ Thread *t = reinterpret_cast<Thread *> (thread);
+ jint flags = 0;
+ jvmtiError err = env->GetClassStatus (klass, &flags);
+ if (err != JVMTI_ERROR_NONE)
+ throw_jvmti_error (err);
+
+ using namespace gnu::classpath::jdwp::event;
+ jint status = 0;
+ if (flags & JVMTI_CLASS_STATUS_VERIFIED)
+ status |= ClassPrepareEvent::STATUS_VERIFIED;
+ if (flags & JVMTI_CLASS_STATUS_PREPARED)
+ status |= ClassPrepareEvent::STATUS_PREPARED;
+ if (flags & JVMTI_CLASS_STATUS_ERROR)
+ status |= ClassPrepareEvent::STATUS_ERROR;
+ if (flags & JVMTI_CLASS_STATUS_INITIALIZED)
+ status |= ClassPrepareEvent::STATUS_INITIALIZED;
+
+ event::ClassPrepareEvent *event
+ = new event::ClassPrepareEvent (t, klass, status);
+ Jdwp::notify (event);
+}
+
+static void JNICALL
+jdwpThreadEndCB (MAYBE_UNUSED jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env,
+ jthread thread)
+{
+ using namespace gnu::classpath::jdwp::event;
+
+ Thread *t = reinterpret_cast<Thread *> (thread);
+ ThreadEndEvent *e = new ThreadEndEvent (t);
+ gnu::classpath::jdwp::Jdwp::notify (e);
+}
+
+static void JNICALL
+jdwpThreadStartCB (MAYBE_UNUSED jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env,
+ jthread thread)
+{
+ using namespace gnu::classpath::jdwp::event;
+
+ Thread *t = reinterpret_cast<Thread *> (thread);
+ ThreadStartEvent *e = new ThreadStartEvent (t);
+ gnu::classpath::jdwp::Jdwp::notify (e);
+}
+
+static void JNICALL
+jdwpVMDeathCB (MAYBE_UNUSED jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env)
+{
+ using namespace gnu::classpath::jdwp::event;
+ gnu::classpath::jdwp::Jdwp::notify (new VmDeathEvent ());
+}
+
static void JNICALL
jdwpVMInitCB (MAYBE_UNUSED jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env,
jthread thread)
{
+ // The VM is now initialized, add our callbacks
+ jvmtiEventCallbacks callbacks;
+ DEFINE_CALLBACK (callbacks, ClassPrepare);
+ DEFINE_CALLBACK (callbacks, ThreadEnd);
+ DEFINE_CALLBACK (callbacks, ThreadStart);
+ DEFINE_CALLBACK (callbacks, VMDeath);
+ _jdwp_jvmtiEnv->SetEventCallbacks (&callbacks, sizeof (callbacks));
+
+ // Enable callbacks
+ ENABLE_EVENT (CLASS_PREPARE, NULL);
+ ENABLE_EVENT (THREAD_END, NULL);
+ ENABLE_EVENT (THREAD_START, NULL);
+ ENABLE_EVENT (VM_DEATH, NULL);
+
// Send JDWP VMInit
using namespace gnu::classpath::jdwp::event;
Thread *init_thread = reinterpret_cast<Thread *> (thread);