##
## 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
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 \
##
## 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
libjdwp_la_SOURCES = \
VMjdwp.c \
- VMjdwp.h
-
+ VMjdwp.h \
## Local variables:
## mode: Makefile
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;
jclass cl;
jmethodID m;
jobject eventobj;
+ jvmtiError err;
fprintf(stderr,"JDWP VMInit\n");
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);
}
}
/* 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;
}
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;
}
}
char* jdwpoptions;
bool suspend; /* should the virtual machine suspend on startup? */
+void printjvmtierror(char *desc, jvmtiError err);
#endif
Samuel Vinson
- $Id: jvmti.c 4969 2006-05-29 09:41:02Z motse $
+ $Id: jvmti.c 4996 2006-05-31 13:53:16Z motse $
*/
#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>
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 ***************************************************************
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;
}
int i,j,size=20;
java_objectheader **om;
lock_record_pool_t* lrp;
+ threadobject* t;
log_text("GetOwnedMonitorInfo called");
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)
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);
(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;
*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*));
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;
}
/* 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;
{
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)) {
lock_monitor_exit((threadobject*)THREADOBJECT, (java_objectheader*)monitor->name);
- /* GC will clean monitor up */
+ heap_free(monitor);
#else
log_text ("DestroyRawMonitor not supported");
#endif
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;
}
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);
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;
}
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;
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;
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;
}
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 */
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;
}
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;
}
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;
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;
}
return JVMTI_ERROR_NONE;
}
-/* *****************************************************************************
+/* GetAvailableProcessors *****************************************************
-
+ Get number of processors available to the virtual machine.
*******************************************************************************/
Changes:
-$Id: VMFrame.c 4357 2006-01-22 23:33:38Z twisti $
+$Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
*/
*/
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;
}
Contact: cacao@cacaojvm.org
Authors: Samuel Vinson
-Martin Platter
+ Martin Platter
Changes:
-$Id: $
+$Id: VMMethod.c $
*/
#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
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;
}
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;
}
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;
}
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;
}
}
(*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;
}
}
+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
*/
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;
}
/*
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 $
*/
*/
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);
}
/*
*/
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);
}
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);
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"); */
*/
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;
}
jint count;
jmethodID* methodID, m;
jvmtiError err;
- char* errdesc;
jclass *cl;
jobject *ol;
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;
}
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]);
*/
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;
}
*/
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 */
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;
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 */
}