src/native/vm/VMVirtualMachine.c (suspendThread): print error message with printjvmti...
authormotse <none@none>
Wed, 31 May 2006 13:53:16 +0000 (13:53 +0000)
committermotse <none@none>
Wed, 31 May 2006 13:53:16 +0000 (13:53 +0000)
(resumeThread): idem
(getAllLoadedClassCount): idem
(getAllLoadedClasses): idem
(getClassStatus): idem
(getAllClassMethods): idem
(getFrameCount): idem
(getThreadStatus): idem
(getSourceFile): idem
(registerEvent): idem

src/native/vm/VMMethod.c (printjvmtierror): new helper function for getting and print error messages
(getName): print error message with printjvmtierror, remove signature, generic signature
(getSignature): print error message with printjvmtierror, remove name, generic signature
(getModifiers): print error message with printjvmtierror
(getlinetable): idem
(fillVariableTable): new function for converting jvmtiLocalVariableEntry to arguments for gnu.classpath.jdwp.util.VariableTable constructor
(getVariableTable): new implementation. tries to get local variable table and return gnu.classpath.jdwp.util.VariableTable.

src/native/include/Makefile.am: add VariableTable

src/native/jvmti/VMjdwp.c (printjvmtierror) new function (duplicate) - this is a work around
(VMInit): print error message with printjvmtierror

src/native/jvmti/jvmti.c (InterruptThread): new implentation
(GetThreadInfo): switch form using javastring_tochar (uses malloc) to javastring_toutf/utf_sprint_convert_to_latin1
(GetOwnedMonitorInfo): fix error handling
(GetFrameLocation): idem
(DestroyRawMonitor): use heap_free
(GetClassSignature): fix error handling
(GetSourceFileName): use utf_bytes
(GetFieldName): fix error handling
(GetFieldDeclaringClass): add error handling
(GetFieldModifiers): idem
(GetMethodName): fix error handling
(GetClassLoaderClasses): idem
(GenerateEvents): add CHECK_CAPABILITY can_generate_compiled_method_load_events

src/native/jvmti/VMjdwp.h add printjvmtierror

src/native/include/Makefile.am
src/native/jvmti/Makefile.am
src/native/jvmti/VMjdwp.c
src/native/jvmti/VMjdwp.h
src/native/jvmti/jvmti.c
src/native/vm/VMFrame.c
src/native/vm/VMMethod.c
src/native/vm/VMVirtualMachine.c

index 209fbd56b03f4216e922ffb9e7bf9715dceb5bf1..7376c13d07e56d88f344f98c374cb3ea7dd2835f 100644 (file)
@@ -28,7 +28,7 @@
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4892 2006-05-06 18:29:55Z motse $
+## $Id: Makefile.am 4996 2006-05-31 13:53:16Z motse $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -77,7 +77,8 @@ GEN_JVMTI_HEADER_FILES = \
        gnu_classpath_jdwp_VMFrame.h \
        gnu_classpath_jdwp_VMMethod.h \
        gnu_classpath_jdwp_VMVirtualMachine.h \
-       gnu_classpath_jdwp_event_EventRequest.h
+       gnu_classpath_jdwp_event_EventRequest.h \
+       gnu_classpath_jdwp_util_VariableTable.h
 
 ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
        gnu_classpath_VMStackWalker.h \
index 04fd2eacbf17c70a6a34aa4aba911ec1a075635f..120ec55a30b19641d9a4f41a2146b0261fe433f2 100644 (file)
@@ -28,7 +28,7 @@
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4954 2006-05-25 21:59:49Z motse $
+## $Id: Makefile.am 4996 2006-05-31 13:53:16Z motse $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -58,8 +58,7 @@ lib_LTLIBRARIES = \
 
 libjdwp_la_SOURCES = \
        VMjdwp.c \
-       VMjdwp.h 
-
+       VMjdwp.h \
 
 ## Local variables:
 ## mode: Makefile
index 9bcde095be206dd49de351538008f7df017579bd..82281eb8a45f666fa1d4d3c8ce48e511e92a21d6 100644 (file)
@@ -29,7 +29,7 @@
    Changes:             
 
 
-   $Id: VMjdwp.c 4954 2006-05-25 21:59:49Z motse $
+   $Id: VMjdwp.c 4996 2006-05-31 13:53:16Z motse $
 
 */
 
 #include <stdlib.h>
 #include <string.h>
 
+void printjvmtierror(char *desc, jvmtiError err) {
+    char* errdesc;
+       
+       if (err == JVMTI_ERROR_NONE) return;
+       (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
+       fprintf(stderr,"%s: jvmti error %s\n",desc, errdesc);
+       fflush(stderr);
+       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+}
+
 
 
 static jmethodID notifymid = NULL;
@@ -174,6 +184,7 @@ static void VMInit (jvmtiEnv *jvmti_env,
        jclass cl;
        jmethodID m;
        jobject eventobj;
+       jvmtiError err; 
 
        fprintf(stderr,"JDWP VMInit\n");
 
@@ -209,9 +220,9 @@ static void VMInit (jvmtiEnv *jvmti_env,
        notify (jni_env,eventobj);
 
        if (suspend) {
-               fprintf(stderr,"suspend true -> do not continue debuggee\n");
-               if (JVMTI_ERROR_NONE!=(*jvmti_env)->SuspendThread(jvmti_env,thread))
-                       fprintf(stderr,"error suspending initial thread\n");
+               fprintf(stderr,"suspend initial thread\n");
+               err = (*jvmti_env)->SuspendThread(jvmti_env,thread);
+               printjvmtierror("error suspending initial thread",err);
        }
 }
 
@@ -292,19 +303,19 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
        
        /* set eventcallbacks */
        if (JVMTI_ERROR_NONE != 
-               (*jvmtienv)->SetEventCallbacks(jvmtienv,
+               (e = (*jvmtienv)->SetEventCallbacks(jvmtienv,
                                                                           &jvmti_jdwp_EventCallbacks,
-                                                                          sizeof(jvmtiEventCallbacks))){
-               fprintf(stderr,"jdwp: unable to setup event callbacks");
+                                                                          sizeof(jvmtiEventCallbacks)))){
+               printjvmtierror("jdwp: unable to setup event callbacks", e);
                return -1;
        }
 
        e = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &cap);
-       if (e == JVMTI_ERROR_NONE) {
+       printjvmtierror("jdwp: unable to get potential capabilities", e);
+       if (e == JVMTI_ERROR_NONE) 
                e = (*jvmtienv)->AddCapabilities(jvmtienv, &cap);
-       }
        if (e != JVMTI_ERROR_NONE) {
-               fprintf(stderr,"jdwp: error adding jvmti capabilities");
+               printjvmtierror("jdwp: error adding jvmti capabilities", e);
                return -1;
        }
        
@@ -319,7 +330,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
                                                                                                          NULL);
                        
                        if (JVMTI_ERROR_NONE != e) {
-                               fprintf(stderr,"jdwp: unable to setup event notification mode");
+                               printjvmtierror("jdwp: unable to setup event notification mode",e);
                                return -1;
                        }
                }
index 235ddf993ad6790c735fa13d7f25c95ebfe7901d..2c2f3d7d3b71a190e3f18f622e183d48f750b677 100644 (file)
@@ -43,4 +43,5 @@ extern jvmtiEventCallbacks jvmti_jdwp_EventCallbacks;
 char* jdwpoptions;
 bool suspend;               /* should the virtual machine suspend on startup?  */
 
+void printjvmtierror(char *desc, jvmtiError err);
 #endif
index a2b211c0ab8ac908b812c79b85a212b921739f60..fa88ca11607f52e1d28e1ed9ffae30cbac63a5af 100644 (file)
@@ -31,7 +31,7 @@
             Samuel Vinson
 
    
-   $Id: jvmti.c 4969 2006-05-29 09:41:02Z motse $
+   $Id: jvmti.c 4996 2006-05-31 13:53:16Z motse $
 
 */
 
@@ -65,7 +65,7 @@
 #include "native/include/java_lang_VMSystem.h"
 #include "native/include/java_lang_VMClass.h"
 #include "vm/suck.h"
-#include  "boehm-gc/include/gc.h"
+#include "boehm-gc/include/gc.h"
 
 #include <string.h>
 #include <linux/unistd.h>
@@ -662,16 +662,19 @@ InterruptThread (jvmtiEnv * env, jthread thread)
     CHECK_PHASE_END;
     CHECK_CAPABILITY(env,can_signal_thread)
 
-       log_text ("JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
-
-       return JVMTI_ERROR_NOT_AVAILABLE;
-
+#if defined(ENABLE_THREADS)
        if(!builtin_instanceof(thread,class_java_lang_Thread))
                return JVMTI_ERROR_INVALID_THREAD;
 
-       CHECK_THREAD_IS_ALIVE(thread);        
+       CHECK_THREAD_IS_ALIVE(thread);
+
+       threads_interrupt_thread(((java_lang_Thread*)thread)->vmThread);
+
 
     return JVMTI_ERROR_NONE;
+#else
+       return JVMTI_ERROR_NOT_AVAILABLE;
+#endif
 }
 
 /* GetThreadInfo ***************************************************************
@@ -684,16 +687,22 @@ InterruptThread (jvmtiEnv * env, jthread thread)
 static jvmtiError
 GetThreadInfo (jvmtiEnv * env, jthread t, jvmtiThreadInfo * info_ptr)
 {
+       utf *name;
        java_lang_Thread* th = (java_lang_Thread*)t;
 
+
     CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
+
        info_ptr->priority=(jint)th->priority;
        info_ptr->is_daemon=(jboolean)th->daemon;
        info_ptr->thread_group=(jthreadGroup)th->group;
        info_ptr->context_class_loader=(jobject)th->contextClassLoader;
-       info_ptr->name= javastring_tochar((java_objectheader *)th->name);
+
+       name = javastring_toutf(th->name,false);
+       info_ptr->name=(char*)heap_allocate(sizeof(char)*(utf_bytes(name)+1),true,NULL);
+       utf_sprint_convert_to_latin1(info_ptr->name, name);
 
     return JVMTI_ERROR_NONE;
 }
@@ -712,6 +721,7 @@ GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread,
        int i,j,size=20;
        java_objectheader **om;
        lock_record_pool_t* lrp;
+       threadobject* t;
 
        log_text("GetOwnedMonitorInfo called");
 
@@ -723,10 +733,15 @@ GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread,
        if ((owned_monitors_ptr==NULL)||(owned_monitor_count_ptr==NULL)) 
                return JVMTI_ERROR_NULL_POINTER;
 
-       if(!builtin_instanceof(thread,class_java_lang_Thread))
-               return JVMTI_ERROR_INVALID_THREAD;
-
-       CHECK_THREAD_IS_ALIVE(thread);
+       if (thread == NULL) {
+               t = jvmti_get_current_thread();
+       } else {
+               if(!builtin_instanceof(thread,class_java_lang_Thread))
+                       return JVMTI_ERROR_INVALID_THREAD;
+               
+               CHECK_THREAD_IS_ALIVE(thread);
+               t = (threadobject*) thread;
+       }
 
 #if defined(ENABLE_THREADS)
 
@@ -737,7 +752,7 @@ GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread,
 
        while (lrp != NULL) {
                for (j=0; j<lrp->header.size; j++) {
-/*                     if((lrp->lr[j].owner==(threadobject*)thread)&&
+/*                     if((lrp->lr[j].owner==t)&&
                           (!lrp->lr[j].waiting)) {
                                if (i>=size) {
                                        MREALLOC(om,java_objectheader*,size,size*2);
@@ -857,7 +872,7 @@ RunAgentThread (jvmtiEnv * env, jthread thread, jvmtiStartFunction proc,
                (priority > JVMTI_THREAD_MAX_PRIORITY)) 
                return JVMTI_ERROR_INVALID_PRIORITY;
 
-       /* XXX:  Threads started with with this function should not be visible to 
+       /* XXX:  Threads started with this function should not be visible to 
           Java programming language queries but are included in JVM TI queries */
 
        rap.sf = proc;
@@ -1018,14 +1033,16 @@ GetThreadGroupChildren (jvmtiEnv * env, jthreadGroup group,
 
        *thread_count_ptr = (jint)tgp->threads->elementCount;
 
-       *threads_ptr = heap_allocate(sizeof(jthread*)*(*thread_count_ptr),true,NULL);
+       *threads_ptr = 
+               heap_allocate(sizeof(jthread)*(*thread_count_ptr),true,NULL);
 
        memcpy(*threads_ptr, &tgp->threads->elementData, 
-                  (*thread_count_ptr)*sizeof(jthread*));
+                  (*thread_count_ptr)*sizeof(java_objectarray*));
 
        *group_count_ptr = (jint) tgp->groups->elementCount;
 
-       *groups_ptr     = heap_allocate(sizeof(jthreadGroup*)*(*group_count_ptr),true,NULL);    
+       *groups_ptr     = 
+               heap_allocate(sizeof(jthreadGroup)*(*group_count_ptr),true,NULL);       
 
        memcpy(*groups_ptr, &tgp->threads->elementData,
                   (*group_count_ptr)*sizeof(jthreadGroup*));
@@ -1049,7 +1066,7 @@ static jvmtiError getcacaostacktrace(stacktracebuffer** trace, jthread thread) {
                t = (threadobject*)((java_lang_Thread*)thread)->vmThread;
                if (t != jvmti_get_current_thread())
                        /* XXX: todo: take care that the requested thread is in a 
-                          safe state */
+                          safe state - this needs a working thread suspend */
                        return JVMTI_ERROR_INTERNAL;
        }
 
@@ -1129,7 +1146,7 @@ GetThreadState (jvmtiEnv * env, jthread thread, jint * thread_state_ptr)
                /* alive */
                *thread_state_ptr = JVMTI_THREAD_STATE_ALIVE;
                if (t->interrupted) *thread_state_ptr |= JVMTI_THREAD_STATE_INTERRUPTED;
-               /* todo */
+               /* XXX todo -  info not available */
                if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_SUSPENDED;
                if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_IN_NATIVE;
                if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_RUNNABLE;
@@ -1161,22 +1178,28 @@ GetFrameLocation (jvmtiEnv * env, jthread thread, jint depth,
 {
        stackframeinfo   *sfi;
        int i;
+       threadobject* th;
                
        CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
         
-       if(!builtin_instanceof(thread,class_java_lang_Thread))
-               return JVMTI_ERROR_INVALID_THREAD;
-
-       CHECK_THREAD_IS_ALIVE(thread);
+       if (thread == NULL) {
+               th = jvmti_get_current_thread();
+       } else {
+               if(!builtin_instanceof(thread,class_java_lang_Thread))
+                       return JVMTI_ERROR_INVALID_THREAD;
+               
+               CHECK_THREAD_IS_ALIVE(thread);
+               th = (threadobject*) ((java_lang_Thread*)thread)->vmThread;
+       }
 
        if (depth < 0) return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 
        if ((method_ptr == NULL)&&(location_ptr == NULL)) 
                return JVMTI_ERROR_NULL_POINTER;
        
-       sfi = ((threadobject*)thread)->_stackframeinfo;
+       sfi = th->_stackframeinfo;
        
        i = 0;
        while ((sfi != NULL) && (i<depth)) {
@@ -1461,7 +1484,7 @@ DestroyRawMonitor (jvmtiEnv * env, jrawMonitorID monitor)
        
        lock_monitor_exit((threadobject*)THREADOBJECT, (java_objectheader*)monitor->name);
 
-       /* GC will clean monitor up */
+       heap_free(monitor);
 #else
        log_text ("DestroyRawMonitor not supported");
 #endif
@@ -1767,16 +1790,21 @@ GetClassSignature (jvmtiEnv * env, jclass klass, char **signature_ptr,
     CHECK_PHASE(JVMTI_PHASE_START)
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
-       
-    if ((generic_ptr== NULL)||(signature_ptr == NULL)) 
-        return JVMTI_ERROR_NULL_POINTER;
+    
+       if (klass == NULL) return JVMTI_ERROR_INVALID_CLASS;
+       if (!builtin_instanceof(klass,class_java_lang_Class))
+               return JVMTI_ERROR_INVALID_CLASS;
 
-    *signature_ptr = (char*)
-               heap_allocate(sizeof(char) * 
-                                         ((classinfo*)klass)->name->blength,true,NULL);
+       if (signature_ptr != NULL) {
+               *signature_ptr = (char*)
+                       heap_allocate(sizeof(char) * 
+                                                 utf_bytes(((classinfo*)klass)->name)+1,true,NULL);
+               
+               utf_sprint_convert_to_latin1(*signature_ptr,((classinfo*)klass)->name);
+       }
 
-       utf_sprint_convert_to_latin1(*signature_ptr, ((classinfo*)klass)->name);
-    *generic_ptr = NULL;
+       if (generic_ptr!= NULL)
+               *generic_ptr = NULL;
 
     return JVMTI_ERROR_NONE;
 }
@@ -1845,7 +1873,7 @@ GetSourceFileName (jvmtiEnv * env, jclass klass, char **source_name_ptr)
     if ((klass == NULL)||(source_name_ptr == NULL)) 
         return JVMTI_ERROR_NULL_POINTER;
     
-    size = (((classinfo*)klass)->sourcefile->blength)+1;
+    size = utf_bytes(((classinfo*)klass)->sourcefile)+1;
 
     *source_name_ptr = (char*) heap_allocate(sizeof(char)* size,true,NULL);
     
@@ -2121,19 +2149,29 @@ GetFieldName (jvmtiEnv * env, jclass klass, jfieldID field,
     CHECK_PHASE(JVMTI_PHASE_START)
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
-        
-    if ((field == NULL)||(name_ptr == NULL)||(signature_ptr == NULL)) 
-        return JVMTI_ERROR_NULL_POINTER;
+
+       if (klass == NULL) 
+               return JVMTI_ERROR_INVALID_CLASS;
+       else 
+               if (!builtin_instanceof(klass,class_java_lang_Class))
+                       return JVMTI_ERROR_INVALID_CLASS;
+    if (field == NULL) return JVMTI_ERROR_INVALID_FIELDID;
     
-    size = (((fieldinfo*)field)->name->blength);
-    *name_ptr = (char*) heap_allocate(sizeof(char)* size,true,NULL);    
-    memcpy(*name_ptr,((fieldinfo*)field)->name->text, size);
+    if (name_ptr != NULL) {
+               size = utf_bytes(((fieldinfo*)field)->name)+1;
+               *name_ptr = (char*) heap_allocate(sizeof(char)* size,true,NULL);
+               utf_sprint_convert_to_latin1(*name_ptr, ((fieldinfo*)field)->name);
+       }
 
-    size = (((fieldinfo*)field)->descriptor->blength);
-    *signature_ptr = (char*) heap_allocate(sizeof(char)* size,true,NULL);    
-    memcpy(*signature_ptr,((fieldinfo*)field)->descriptor->text, size);
+       if (signature_ptr != NULL) {
+               size = utf_bytes(((fieldinfo*)field)->descriptor)+1;
+               *signature_ptr = (char*) heap_allocate(sizeof(char)* size,true,NULL); 
+               utf_sprint_convert_to_latin1(*signature_ptr, 
+                                                                        ((fieldinfo*)field)->descriptor);
+       }
 
-    *generic_ptr = NULL;
+       if (generic_ptr != NULL) 
+               *generic_ptr = NULL;
 
     return JVMTI_ERROR_NONE;
 }
@@ -2155,7 +2193,17 @@ GetFieldDeclaringClass (jvmtiEnv * env, jclass klass, jfieldID field,
     CHECK_PHASE(JVMTI_PHASE_START)
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
-        
+
+       if (klass == NULL) 
+               return JVMTI_ERROR_INVALID_CLASS;
+       else 
+               if (!builtin_instanceof(klass,class_java_lang_Class))
+                       return JVMTI_ERROR_INVALID_CLASS;
+
+    if (field == NULL) return JVMTI_ERROR_INVALID_FIELDID;     
+
+    if (declaring_class_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
+
        *declaring_class_ptr = (jclass) ((fieldinfo*)field)->class;
  
     return JVMTI_ERROR_NONE;
@@ -2176,14 +2224,17 @@ GetFieldModifiers (jvmtiEnv * env, jclass klass, jfieldID field,
     CHECK_PHASE(JVMTI_PHASE_START)
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
-        
-       if (!builtin_instanceof((java_objectheader*)klass, class_java_lang_Class))
-               return JVMTI_ERROR_INVALID_OBJECT;
+
+       if (klass == NULL) 
+               return JVMTI_ERROR_INVALID_CLASS;
+       else 
+               if (!builtin_instanceof(klass,class_java_lang_Class))
+                       return JVMTI_ERROR_INVALID_CLASS;
+
+    if (field == NULL) return JVMTI_ERROR_INVALID_FIELDID;
 
        if (modifiers_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
  
-       /* todo: JVMTI_ERROR_INVALID_FIELDID; */
-       
        *modifiers_ptr = ((fieldinfo*)field)->flags;
        
     return JVMTI_ERROR_NONE;
@@ -2232,20 +2283,20 @@ GetMethodName (jvmtiEnv * env, jmethodID method, char **name_ptr,
 
        if (method == NULL) return JVMTI_ERROR_INVALID_METHODID;
 
-       if (name_ptr == NULL) {
+       if (name_ptr != NULL) {
                *name_ptr = (char*)
-                       heap_allocate(sizeof(char) * (m->name->blength),true,NULL);
+                       heap_allocate(sizeof(char) * (utf_bytes(m->name)+1),true,NULL);
                utf_sprint_convert_to_latin1(*name_ptr, m->name);
        }
        
-       if (signature_ptr == NULL) {
+       if (signature_ptr != NULL) {
                *signature_ptr = (char*)
-                       heap_allocate(sizeof(char) * (m->descriptor->blength),true,NULL);
+                       heap_allocate(sizeof(char)*(utf_bytes(m->descriptor)+1),true,NULL);
                utf_sprint_convert_to_latin1(*signature_ptr, m->descriptor);
        }
 
-       if (generic_ptr == NULL) {
-    /* there is no generic signature attribute */
+       if (generic_ptr != NULL) {
+        /* there is no generic signature attribute */
                *generic_ptr = NULL;
        }
 
@@ -2612,8 +2663,8 @@ GetClassLoaderClasses (jvmtiEnv * env, jobject initiating_loader,
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
 
-/*    if (class_count_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
-         if (classes_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;*/
+    if ((class_count_ptr == NULL) || (classes_ptr == NULL)) 
+               return JVMTI_ERROR_NULL_POINTER;
         
        /* behave like jdk 1.1 and make no distinction between initiating and 
           defining class loaders */
@@ -2657,6 +2708,7 @@ RedefineClasses (jvmtiEnv * env, jint class_count,
     CHECK_PHASE_END;
        CHECK_CAPABILITY(env,can_redefine_classes)    
        CHECK_CAPABILITY(env,can_redefine_any_class)
+
   log_text ("JVMTI-Call: OPTIONAL IMPLEMENT ME!!!");
     return JVMTI_ERROR_NONE;
 }
@@ -2849,7 +2901,7 @@ GetStackTrace (jvmtiEnv * env, jthread thread, jint start_depth,
        
        for (i=start_depth, j=0;i<trace->used;i++,j++) {
                frame_buffer[j].method = (jmethodID)trace->entries[i].method;
-        /* todo: location BCI/MachinePC not avilable - Linenumber not expected */
+        /* XXX todo: location BCI/MachinePC not avilable - Linenumber not expected */
                frame_buffer[j].location = 0;
                }
 
@@ -2923,15 +2975,12 @@ GetAllStackTraces (jvmtiEnv * env, jint max_frame_count,
     
        if (thread_count_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
     
-       /* todo: all threads have to be suspended */ 
-
        if (JVMTI_ERROR_NONE!=GetAllThreads(env,thread_count_ptr,&threads_ptr))
                return JVMTI_ERROR_INTERNAL;
 
        GetThreadListStackTraces(env, *thread_count_ptr, threads_ptr,
                                                         max_frame_count, stack_info_ptr);
 
-       /* todo: resume all threads have to be suspended */ 
        if (er != JVMTI_ERROR_NONE) return er;
 
     return JVMTI_ERROR_NONE;
@@ -3286,8 +3335,8 @@ GenerateEvents (jvmtiEnv * env, jvmtiEvent event_type)
     CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
-        
-  log_text ("JVMTI-Call: IMPLEMENT ME!!!");
+       CHECK_CAPABILITY(env,can_generate_compiled_method_load_events);
+
     return JVMTI_ERROR_NONE;
 }
 
@@ -4003,9 +4052,9 @@ RelinquishCapabilities (jvmtiEnv * env,
     return JVMTI_ERROR_NONE;
 }
 
-/* *****************************************************************************
+/* GetAvailableProcessors *****************************************************
 
-   
+   Get number of processors available to the virtual machine.
 
 *******************************************************************************/
 
index f2d9efaeafd88e57ae5e2d8f4366539e7ca3bc1a..cddaf18cfc2c567ff4203266ffa902068ab3b77d 100644 (file)
@@ -29,7 +29,7 @@ Authors: Martin Platter
 Changes: 
 
 
-$Id: VMFrame.c 4357 2006-01-22 23:33:38Z twisti $
+$Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
 
 */
 
@@ -45,7 +45,7 @@ $Id: VMFrame.c 4357 2006-01-22 23:33:38Z twisti $
  */
 JNIEXPORT struct java_lang_Object* JNICALL Java_gnu_classpath_jdwp_VMFrame_getValue(JNIEnv *env, struct gnu_classpath_jdwp_VMFrame* this, s4 par1) {
     log_text ("JVMTI-Call: IMPLEMENT ME!!!");
-       return 0;
+    return 0;
 }
 
 
index 377150afe52edcf24e730d9112f4d7a8e8a8fa5d..9792ec6c9f4df1f20d77938577e93c1ccbbf939f 100644 (file)
@@ -25,13 +25,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 Contact: cacao@cacaojvm.org
 
 Authors: Samuel Vinson
-Martin Platter
+         Martin Platter
          
 
 Changes: 
 
 
-$Id: $
+$Id: VMMethod.c $
 
 */
 
@@ -40,6 +40,19 @@ $Id: $
 #include "native/jvmti/jvmti.h"
 #include "native/jvmti/VMjdwp.h"
 
+
+void printjvmtierror(char *desc, jvmtiError err) {
+    char* errdesc;
+       
+       if (err == JVMTI_ERROR_NONE) return;
+       (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
+       fprintf(stderr,"%s: jvmti error %s\n",desc, errdesc);
+       fflush(stderr);
+       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+}
+
+
+
 /*
  * Class:     gnu/classpath/jdwp/VMMethod
  * Method:    getName
@@ -48,24 +61,19 @@ $Id: $
 JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getName(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
 {
     jvmtiError err;
-    char* errdesc;
-    char *name, *signature, *generic;
+    char *name;
     jstring stringname;
     
     if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                             GetMethodName(jvmtienv, (jmethodID)this->_methodId,
-                                           &name, &signature, &generic))) {
-        (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-        fprintf(stderr,"jvmti error: %s\n",errdesc);
-        fflush(stderr);
-        (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+                             GetMethodName(jvmtienv, 
+                                                                                  (jmethodID)(long)this->_methodId,
+                                           &name,NULL, NULL))) {
+               printjvmtierror("VMMethod.getName GetMethodName",err);
         return NULL;
     }
     
     stringname = (*env)->NewStringUTF(env,name);
     (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)name);
-    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)signature);
-    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)generic);
 
     return stringname;
 }
@@ -79,24 +87,19 @@ JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getN
 JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getSignature(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
 {
     jvmtiError err;
-    char* errdesc;
-    char *name, *signature, *generic;
+    char *signature;
     struct java_lang_String* stringsignature;
     
     if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                             GetMethodName(jvmtienv, (jmethodID)this->_methodId,
-                                           &name, &signature, &generic))) {
-        (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-        fprintf(stderr,"jvmti error: %s\n",errdesc);
-        fflush(stderr);
-        (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+                             GetMethodName(jvmtienv, 
+                                                                                  (jmethodID)(long)this->_methodId,
+                                           NULL, &signature, NULL))) {
+               printjvmtierror("VMMethod.getSignature GetMethodName",err);
         return NULL;
     }
     
     stringsignature = (*env)->NewStringUTF(env,signature);
-    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)name);
     (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)signature);
-    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)generic);
     
     return stringsignature;
 }
@@ -110,17 +113,13 @@ JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getS
 JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMMethod_getModifiers(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
 {
     jvmtiError err;
-    char* errdesc;
     jint modifiers;
        
-    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                             GetMethodModifiers(jvmtienv, 
-                                                (jmethodID) this->_methodId,
-                                                &modifiers))) {
-        (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-        fprintf(stderr,"jvmti error: %s\n",errdesc);
-        fflush(stderr);
-        (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
+                                                  GetMethodModifiers(jvmtienv, 
+                                                                                         (jmethodID)(long)this->_methodId,
+                                                                                         &modifiers))) {
+               printjvmtierror("VMMethod.getModifiers GetMethodModifiers",err);
         return 0;
     }
     
@@ -147,16 +146,12 @@ JNIEXPORT struct gnu_classpath_jdwp_util_LineTable* JNICALL Java_gnu_classpath_j
     jlocation start,end;
     
     jvmtiError err;
-    char* errdesc;
 
-    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                             GetLineNumberTable(jvmtienv, 
-                                                (jmethodID)this->_methodId, 
-                                                &count, &lne))) {
-        (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-        fprintf(stderr,"jvmti error: %s\n",errdesc);
-        fflush(stderr);
-        (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
+                                                  GetLineNumberTable(jvmtienv, 
+                                                                                         (jmethodID)(long)this->_methodId,
+                                                                                         &count, &lne))) {
+               printjvmtierror("VMMethod.getlinetable GetLineNumberTable",err);
         return NULL;
     }
 
@@ -178,16 +173,13 @@ JNIEXPORT struct gnu_classpath_jdwp_util_LineTable* JNICALL Java_gnu_classpath_j
     }
     (*env)->ReleaseLongArrayElements(env, jlineCI, lineCI, 0);
     (*env)->ReleaseIntArrayElements(env, jlineNum, lineNum, 0);
-    (*jvmtienv)->Deallocate(jvmtienv,lne);
+    (*jvmtienv)->Deallocate(jvmtienv, lne);
 
-    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                             GetMethodLocation(jvmtienv, 
-                                               (jmethodID)this->_methodId, 
-                                                &start, &end))) {
-        (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-        fprintf(stderr,"jvmti error: %s\n",errdesc);
-        fflush(stderr);
-        (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
+                                                  GetMethodLocation(jvmtienv, 
+                                                                                        (jmethodID)(long)this->_methodId, 
+                                                                                        &start, &end))) {
+               printjvmtierror("VMMethod.getlinetable GetMethodLocation",err);
         return NULL;
     }
 
@@ -198,6 +190,52 @@ JNIEXPORT struct gnu_classpath_jdwp_util_LineTable* JNICALL Java_gnu_classpath_j
  
 }
 
+static bool fillVariableTable(JNIEnv *env, jvmtiLocalVariableEntry* entries, 
+                                                         int count, jlongArray *jlineCI, 
+                                                         jobjectArray *names, jobjectArray *sigs, 
+                                                         jintArray *jlengths, jintArray *jslot) {
+       jint *lengths, *slot,i;
+       jclass cl;
+       jlong *lineCI;
+
+       *jlineCI = (*env)->NewLongArray(env, count);
+       if (!*jlineCI) return false;
+
+       cl=(*env)->FindClass(env,"java/lang/String");
+       if (!cl) return false;
+       
+       *names = (*env)->NewObjectArray(env, count, cl, NULL);
+       if (names) return false;
+       sigs = (*env)->NewObjectArray(env, count, cl, NULL);
+       if (sigs) return false;
+       
+       jlengths = (*env)->NewIntArray(env, count);
+       if (!lengths) return false;
+       
+       jslot = (*env)->NewIntArray(env, count);
+       if (!slot) return false;
+       
+       lineCI = (*env)->GetLongArrayElements(env, *jlineCI, NULL);
+       lengths = (*env)->GetIntArrayElements(env, *jlengths, NULL);
+       slot = (*env)->GetIntArrayElements(env, jslot, NULL);
+       
+       for (i=0; i<count; i++) {
+               (*env)->
+                       SetObjectArrayElement(env, *names, i, 
+                                                                 (*env)->NewStringUTF(env,entries[i].name));
+               (*env)->
+                       SetObjectArrayElement(env, *sigs, i, (*env)->NewStringUTF(
+                                                                         env,entries[i].signature));
+               lineCI[i]=entries[i].start_location;
+               lengths[i]=entries[i].length;
+               slot[i]=entries[i].slot;
+       }
+    (*env)->ReleaseLongArrayElements(env, jlineCI, lineCI, 0);
+    (*env)->ReleaseIntArrayElements(env, jlengths, lengths, 0);
+    (*env)->ReleaseIntArrayElements(env, jslot, slot, 0);
+       return true;
+}
+
 
 /*
  * Class:     gnu/classpath/jdwp/VMMethod
@@ -206,8 +244,76 @@ JNIEXPORT struct gnu_classpath_jdwp_util_LineTable* JNICALL Java_gnu_classpath_j
  */
 JNIEXPORT struct gnu_classpath_jdwp_util_VariableTable* JNICALL Java_gnu_classpath_jdwp_VMMethod_getVariableTable(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
 {
-    fprintf(stderr,"VMMethod_getVariableTable: IMPLEMENT ME!!!");
-    return 0;
+       jvmtiLocalVariableEntry* localvarentries;
+       jint entry_count, argCnt, slots; 
+       jclass cl;
+       jmethodID m, vmmethodid;
+    jobject o;
+       jobjectArray names, sigs;
+    jvmtiError err;
+    jlongArray jlineCI;
+       jintArray jlengths, jslot;
+
+       vmmethodid = (jmethodID)(long)this->_methodId;
+
+       err= (*jvmtienv)->GetLocalVariableTable(jvmtienv, 
+                                                                                       vmmethodid,
+                                                                                       &entry_count, 
+                                                                                       &localvarentries);
+    if (JVMTI_ERROR_NONE != err) { 
+               if (err == JVMTI_ERROR_ABSENT_INFORMATION) {
+                       /* no local variable table available for this method. 
+                          return an empty local variable table */
+                       argCnt = slots = 0;
+                       names = sigs = jlineCI = jlengths = jslot = NULL;
+               } else {
+                       printjvmtierror("VMMethod.getVariableTable GetLocalVariableTable",err);
+                       return NULL;
+               }
+       } else {
+               if (JVMTI_ERROR_NONE != (err= 
+                                                                (*jvmtienv)->GetArgumentsSize(jvmtienv, 
+                                                                                                                          vmmethodid, 
+                                                                                                                          &argCnt))) {
+                       printjvmtierror("VMMethod.getVariableTable GetArgumentsSize",err);
+                       return NULL;
+               }
+
+               if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->GetMaxLocals(jvmtienv, 
+                                                                                                                               vmmethodid,
+                                                                                                                               &slots))) {
+                       printjvmtierror("VMMethod.getVariableTable GetMaxLocals",err);
+                       return NULL;
+               }
+               
+               slots = slots - argCnt;
+               if (!fillVariableTable(env, localvarentries, entry_count, &jlineCI, 
+                                                          &names, &sigs, &jlengths, &jslot)) 
+                       return NULL;
+               (*jvmtienv)->
+                       Deallocate(jvmtienv, (unsigned char*)localvarentries->signature);
+               (*jvmtienv)->
+                       Deallocate(jvmtienv, (unsigned char*)localvarentries->name);
+               if (localvarentries->generic_signature != NULL)
+                       (*jvmtienv)-> Deallocate(jvmtienv, (unsigned char*)
+                                                                        localvarentries->generic_signature);
+
+
+               (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)localvarentries);
+       }
+       
+    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.util.VariableTable");
+    if (!cl) return NULL;
+
+    m = (*env)->
+               GetMethodID(env, cl,"<init>", 
+                                       "(II[J[Ljava/lang/String;[Ljava/lang/String;[I[I)V");
+    if (!m) return NULL;
+
+    o = (*env)->NewObject(env, cl, m, argCnt, slots, jlineCI, 
+                                                 names, sigs, jlengths, jslot);        
+
+    return (struct gnu_classpath_jdwp_util_VariableTable*) o;
 }
 
 /*
index 3428d9d5ad363834c4ad2848d68c73dff70acf90..cbf9c24af42d17fe2c1ff53f7b34bc7c975c1411 100644 (file)
@@ -29,7 +29,7 @@ Authors: Martin Platter
 Changes: Samuel Vinson
 
 
-$Id: VMVirtualMachine.c 4969 2006-05-29 09:41:02Z motse $
+$Id: VMVirtualMachine.c 4996 2006-05-31 13:53:16Z motse $
 
 */
 
@@ -54,7 +54,10 @@ $Id: VMVirtualMachine.c 4969 2006-05-29 09:41:02Z motse $
  */
 JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1)
 {
-    (*jvmtienv)->SuspendThread(jvmtienv, (jthread) par1);
+       jvmtiError err; 
+
+    err = (*jvmtienv)->SuspendThread(jvmtienv, (jthread) par1);
+       printjvmtierror("VMVirtualMachine.suspendThread SuspendThread", err);
 }
 
 /*
@@ -64,7 +67,10 @@ JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread(JN
  */
 JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_resumeThread(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1)
 {
-    (*jvmtienv)->ResumeThread(jvmtienv, (jthread) par1);
+       jvmtiError err; 
+
+    err = (*jvmtienv)->ResumeThread(jvmtienv, (jthread) par1);
+       printjvmtierror("VMVirtualMachine.resumethread ResumeThread", err);
 }
 
 
@@ -87,14 +93,10 @@ JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClasse
     jint count;
     jclass* classes;
        jvmtiError err;
-       char* errdesc;
 
        if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
                GetLoadedClasses(jvmtienv, &count, &classes))) {
-               (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-               fprintf(stderr,"jvmti error: %s\n",errdesc);
-               (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
-               fflush(stderr);
+               printjvmtierror("VMVirtualMachine_getAllLoadedClassCount GetLoadedClasses",err);
                return 0;
        }
        (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)classes);
@@ -115,13 +117,10 @@ JNIEXPORT struct java_util_Iterator* JNICALL Java_gnu_classpath_jdwp_VMVirtualMa
        jobject *ol,*oi;
        int i;
        jvmtiError err;
-       char* errdesc;
 
        if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
                GetLoadedClasses(jvmtienv, &classcount, &classes))) {
-               (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-               fprintf(stderr,"jvmti error: %s\n",errdesc);
-               fflush(stderr);
+               printjvmtierror("VMVirtualMachine_getAllLoadedClasses GetLoadedClasses",err);
                
                /* we should throw JDWP Exception INTERNAL = 113;*/
 /*             env->ThrowNew(env,ec,"jvmti error occoured");  */
@@ -163,7 +162,11 @@ JNIEXPORT struct java_util_Iterator* JNICALL Java_gnu_classpath_jdwp_VMVirtualMa
  */
 JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
        jint status;
-       (*jvmtienv)->GetClassStatus(jvmtienv, (jclass) par1, &status);
+       jvmtiError err;
+
+       err = (*jvmtienv)->GetClassStatus(jvmtienv, (jclass) par1, &status);
+       printjvmtierror("VMVirtualMachine_getClassStatus GetClassStatus", err);
+
        return status;
 }
 
@@ -176,7 +179,6 @@ JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_get
     jint count;
     jmethodID* methodID, m;
        jvmtiError err;
-       char* errdesc;
        
        jclass *cl;
        jobject *ol;
@@ -186,10 +188,7 @@ JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_get
     if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
                                                         GetClassMethods(jvmtienv, (jclass) par1, 
                                                                                         &count, &methodID))) {
-               (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-               fprintf(stderr,"jvmti error: %s\n",errdesc);
-               (*jvmtienv)->Deallocate(jvmtienv, (unsigned char *)errdesc);
-               fflush(stderr);
+               printjvmtierror("VMVirtualMachine_getAllClassMethods GetClassMethods", err);
                return NULL;
        }
        
@@ -203,7 +202,7 @@ JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_get
        
        joa = (*env)->NewObjectArray(env, (jsize)count, cl , NULL);
        if (!joa) return NULL;
-       fprintf(stderr, "VMVirtualMachine_getAllClassMethods 3\n");
+
     for (i = 0; i < count; i++) {
        ol = (*env)->
                        CallStaticObjectMethod(env,clazz,m,(jobject)par1, methodID[i]);
@@ -268,7 +267,9 @@ JNIEXPORT struct gnu_classpath_jdwp_VMFrame* JNICALL Java_gnu_classpath_jdwp_VMV
  */
 JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
        jint count;
-       (*jvmtienv)->GetFrameCount(jvmtienv, (jthread)par1, &count);
+       jvmtiError err;
+       err = (*jvmtienv)->GetFrameCount(jvmtienv, (jthread)par1, &count);
+       printjvmtierror("VMVirtualMachine_getFrameCount GetFrameCount", err);
        return count;
 }
 
@@ -280,8 +281,11 @@ JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount(JNIE
  */
 JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getThreadStatus(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
        jint status;
-       if (JVMTI_ERROR_NONE != (*jvmtienv)->GetThreadState(jvmtienv, (jthread)par1, &status))
+       jvmtiError err; 
+       if (JVMTI_ERROR_NONE != (err = (*jvmtienv)->GetThreadState(jvmtienv, (jthread)par1, &status))) {
+               printjvmtierror("VMVirtualMachine_getThreadStatus GetThreadState", err);
                return 0;
+       }
        if (status && JVMTI_THREAD_STATE_ALIVE) {
                if (status && JVMTI_THREAD_STATE_WAITING) {             
                        return 4; /* WAIT - see JdwpConstants */
@@ -329,9 +333,14 @@ JNIEXPORT struct gnu_classpath_jdwp_util_MethodResult* JNICALL Java_gnu_classpat
 JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getSourceFile(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
        char* srcname;
        jstring str;
+       jvmtiError err; 
+
+    if (JVMTI_ERROR_NONE !=(err=(*jvmtienv)->
+               GetSourceFileName(jvmtienv, (jclass)par1, &srcname))) {
+               printjvmtierror("VMVirtualMachine.getSourceFile GetSourceFileName", err);
+               return NULL;
+       }
 
-    (*jvmtienv)->
-               GetSourceFileName(jvmtienv, (jclass)par1, &srcname);
        str = (*env)->NewString(env,(jchar*)srcname,(jsize)strlen(srcname));
 
        return (struct java_lang_String*)str;
@@ -371,15 +380,17 @@ JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_registerEvent(JN
        jbyte kind;
        jfieldID kindid;
        jclass erc;
+       jvmtiError err;
 
        erc = (*env)->FindClass(env,"gnu.classpath.jdwp.event.EventRequest");
        
        kindid = (*env)->GetFieldID(env, erc, "_kind", "B");
        kind = (*env)->GetByteField(env, (jobject)par1, kindid);
 
-       (*jvmtienv)->
+       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
                SetEventNotificationMode(jvmtienv, JVMTI_ENABLE, 
-                                                                EventKind2jvmtiEvent(kind), NULL);
+                                                                EventKind2jvmtiEvent(kind), NULL)))
+               printjvmtierror("VMVirtualMachine_registerEvent SetEventNotificationMode",err);
 
        /* todo: error handling, suspend policy */
 }