Changes:
- $Id: VMjdwp.c 4944 2006-05-23 15:31:19Z motse $
+ $Id: VMjdwp.c 4954 2006-05-25 21:59:49Z motse $
*/
#include "native/jvmti/jvmti.h"
-#include "native/jvmti/cacaodbg.h"
#include "native/jvmti/VMjdwp.h"
-#include "vm/loader.h"
-#include "vm/exceptions.h"
-#include "vm/jit/asmpart.h"
#include <stdlib.h>
+#include <string.h>
-static methodinfo *notifymid = NULL;
-static classinfo *Jdwpclass = NULL;
+static jmethodID notifymid = NULL;
+static jclass Jdwpclass = NULL;
-#define FINDCLASS(jni_env,class,classname) \
- class = load_class_from_sysloader(utf_new_char(classname)); \
- if (!class) throw_main_exception_exit();
-
-
-#define GETJNIMETHOD(jni_env,class,classname,method,methodname,methodsig) \
- FINDCLASS(jni_env,class,classname) \
- method = class_resolveclassmethod (class,utf_new_char(methodname), \
- utf_new_char(methodsig), \
- class_java_lang_Object,true); \
- if (!method) throw_main_exception_exit();
-
-#define GETJNISTATICMETHOD(jni_env,class,classname,method,methodname,methodsig) \
- FINDCLASS(jni_env,class,classname) \
- method = class_resolveclassmethod (class,utf_new_char(methodname), \
- utf_new_char(methodsig), \
- class_java_lang_Object,true); \
- if (!method) throw_main_exception_exit();
-
-
-static void notify (JNIEnv* env, jobject event){
- log_text("VMjdwp notfiy called");
+static void notify (JNIEnv* jni_env, jobject event){
+ fprintf(stderr,"VMjdwp notfiy called");
if (notifymid == NULL) {
- GETJNISTATICMETHOD(env,Jdwpclass,"gnu/classpath/jdwp/Jdwp",notifymid,
- "notify","(Lgnu/classpath/jdwp/event/Event;)V");
-
+ notifymid = (*jni_env)->
+ GetStaticMethodID(jni_env,Jdwpclass,
+ "notify","(Lgnu/classpath/jdwp/event/Event;)V");
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"could not get notify method\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
}
- vm_call_method(notifymid, NULL ,event);
- if (*exceptionptr)
- throw_main_exception_exit();
-
-}
-
-
-static void SingleStep (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location) {
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void Breakpoint (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location) {
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void FieldAccess (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jclass field_klass,
- jobject object,
- jfieldID field)
-{
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void FieldModification (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jclass field_klass,
- jobject object,
- jfieldID field,
- char signature_type,
- jvalue new_value) {
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void FramePop (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jboolean was_popped_by_exception){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void MethodEntry (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void MethodExit (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jboolean was_popped_by_exception,
- jvalue return_value){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void NativeMethodBind (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- void* address,
- void** new_address_ptr){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-static void Exception (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jobject exception,
- jmethodID catch_method,
- jlocation catch_location){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ (*jni_env)->CallStaticVoidMethod(jni_env,Jdwpclass,notifymid,event);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"Exception occourred in notify mehtod\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
-static void ExceptionCatch (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jmethodID method,
- jlocation location,
- jobject exception){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
}
-static void ThreadStart (jvmtiEnv *jvmti_env,
+/*static void ThreadStart (jvmtiEnv *jvmti_env,
JNIEnv* jni_env,
jthread thread){
jclass cl;
throw_main_exception_exit();
notify (jni_env,obj);
-}
+ } */
-static void ThreadEnd (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-static void ClassLoad (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jclass klass){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+/* setup_jdwp_thread **********************************************************
-static void ClassPrepare (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jclass klass){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ Helper function to start JDWP listening thread
-static void ClassFileLoadHook (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jclass class_being_redefined,
- jobject loader,
- const char* name,
- jobject protection_domain,
- jint class_data_len,
- const unsigned char* class_data,
- jint* new_class_data_len,
- unsigned char** new_class_data){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+*******************************************************************************/
-static void VMStart (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env) {
- log_text ("JVMTI-Event:VMStart IMPLEMENT ME!!!");
-}
-
-static void VMInit (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread) {
- classinfo* cl;
- methodinfo* cc;
- java_objectheader* obj;
+static void setup_jdwp_thread(JNIEnv* jni_env) {
+ jobject o;
+ jmethodID m;
+ jstring s;
- log_text ("JVMTI-Event:VMInit");
+ /* new gnu.classpath.jdwp.Jdwp() */
+ Jdwpclass = (*jni_env)->FindClass(jni_env, "gnu/classpath/jdwp/Jdwp");
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"could not find gnu/classpath/jdwp/Jdwp\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
- GETJNIMETHOD(jni_env,cl,"gnu/classpath/jdwp/event/VmInitEvent",cc,"<init>",
- "(Ljava/lang/Thread;)V");
+
+ m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"<init>","()V");
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"could not get Jdwp constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
+
+ o = (*jni_env)->NewObject(jni_env, Jdwpclass, m);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling Jdwp constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
+
+
+ /* configure(jdwpoptions) */
+ m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"configure",
+ "(Ljava/lang/String;)V");
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"could not get Jdwp configure method\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
- fprintf(stderr,"VMjdwp:VMInit: 1\n");
- obj = builtin_new(cl);
- if (!obj) throw_main_exception_exit();
+ s = (*jni_env)->NewStringUTF(jni_env,jdwpoptions);
+ if (s == NULL) {
+ fprintf(stderr,"could not get new java string from jdwp options\n");
+ exit(1);
+ }
- fprintf(stderr,"VMjdwp:VMInit: thread %p\n",thread);
- fflush(stderr);
+ free(jdwpoptions);
+
+ (*jni_env)->CallVoidMethod(jni_env,o,m,s);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"Exception occourred in Jdwp configure\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
- vm_call_method((methodinfo*)cc, obj, thread);
+ m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"_doInitialization","()V");
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"could not get Jdwp _doInitialization method\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
- if (*exceptionptr)
- throw_main_exception_exit();
- notify (jni_env,obj);
+ (*jni_env)->CallVoidMethod(jni_env,o,m);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"Exception occourred in Jdwp _doInitialization\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
}
-static void VMDeath (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env) {
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+static void VMInit (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread) {
+ jclass cl;
+ jmethodID m;
+ jobject eventobj;
-static void CompiledMethodLoad (jvmtiEnv *jvmti_env,
- jmethodID method,
- jint code_size,
- const void* code_addr,
- jint map_length,
- const jvmtiAddrLocationMap* map,
- const void* compile_info) {
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ fprintf(stderr,"JDWP VMInit\n");
-static void CompiledMethodUnload (jvmtiEnv *jvmti_env,
- jmethodID method,
- const void* code_addr){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ /* startup gnu classpath jdwp thread */
+ setup_jdwp_thread(jni_env);
-static void DynamicCodeGenerated (jvmtiEnv *jvmti_env,
- const char* name,
- const void* address,
- jint length){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ fprintf(stderr,"JDWP listening thread started\n");
-static void DataDumpRequest (jvmtiEnv *jvmti_env){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ cl = (*jni_env)->FindClass(jni_env,
+ "gnu/classpath/jdwp/event/VmInitEvent");
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"could not find class VMInitEvent\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
-static void MonitorContendedEnter (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ m = (*jni_env)->GetMethodID(jni_env,cl,"<init>",
+ "(Ljava/lang/Thread;)V");
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"could not get VmInitEvent constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
-static void MonitorContendedEntered (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ eventobj = (*jni_env)->NewObject(jni_env, cl, m, thread);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling VmInitEvent constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ exit(1);
+ }
-static void MonitorWait (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object,
- jlong timeout){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
-static void MonitorWaited (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object,
- jboolean timed_out){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
-}
+ notify (jni_env,eventobj);
-static void VMObjectAlloc (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
- jthread thread,
- jobject object,
- jclass object_klass,
- jlong size){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
+ 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");
+ }
}
-static void ObjectFree (jvmtiEnv *jvmti_env,
- jlong tag){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
+static void VMDeath (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env) {
+ fprintf(stderr,"JVMTI-Event: IMPLEMENT ME!!!");
}
-static void GarbageCollectionStart (jvmtiEnv *jvmti_env){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
+static void usage() {
+ puts("usage jdwp:[help]|(<option>=<value>),*");
+ puts(" transport=[dt_socket|...]");
+ puts(" address=<hostname:port>");
+ puts(" server=[y|n]");
+ puts(" suspend=[y|n]");
}
-static void GarbageCollectionFinish (jvmtiEnv *jvmti_env){
- log_text ("JVMTI-Event: IMPLEMENT ME!!!");
+static bool processoptions(char *options) {
+ int i,len;
+
+ if (strncmp(options,"help",4) == 0) {
+ usage();
+ return false;
+ }
+
+ suspend = true; /* default value */
+
+
+ /* copy options for later use in java jdwp listen thread configure */
+ jdwpoptions = malloc(sizeof(char)*strlen(options));
+ strncpy(jdwpoptions, options, sizeof(char)*strlen(options));
+
+ len = strlen(options);
+
+ i=0;
+ while (i<len) {
+ if (strncmp("suspend=",&options[i],8)==0) {
+ if (8>=strlen(&options[i])) {
+ if ((options[i+8]== 'y') || (options[i+8]== 'n')) {
+ suspend = options[i+8]== 'y';
+ } else {
+ printf("jdwp error argument: %s\n",options);
+ usage();
+ return -1;
+ }
+ }
+ } else {
+ /* these options will be handled by jdwp java configure */
+ if ((strncmp("transport=",options,10)==0) ||
+ (strncmp("server=",options,7)==0)) {
+ } else {
+ printf("jdwp unkown argument: %s\n",options);
+ usage();
+ return false;
+ }
+ }
+ while ((options[i]!=',')&&(i<len)) i++;
+ i++;
+ }
+ return true;
}
-/* it would be more apropriate to call this function from gnu-cp jdwp */
-bool jvmti_VMjdwpInit() {
+JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
+ jint rc;
int end, i=0;
jvmtiCapabilities cap;
jvmtiError e;
- log_text("cacao vm - create new jvmti environment");
- jvmtienv = jvmti_new_environment();
+ fprintf(stderr,"jdwp Agent_OnLoad options: %s\n",options);
+ if (!processoptions(options)) return -1;
+
+ rc = (*vm)->GetEnv(vm, (void**)&jvmtienv, JVMTI_VERSION_1_0);
+ if (rc != JNI_OK) {
+ fprintf(stderr, "jdwp: Unable to get jvmtiEnv error=%d\n", rc);
+ return -1;
+ }
+
/* set eventcallbacks */
if (JVMTI_ERROR_NONE !=
(*jvmtienv)->SetEventCallbacks(jvmtienv,
- &jvmti_jdwp_EventCallbacks,
- sizeof(jvmti_jdwp_EventCallbacks))){
- log_text("unable to setup event callbacks");
- return false;
+ &jvmti_jdwp_EventCallbacks,
+ sizeof(jvmtiEventCallbacks))){
+ fprintf(stderr,"jdwp: unable to setup event callbacks");
+ return -1;
}
-
+
e = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &cap);
if (e == JVMTI_ERROR_NONE) {
e = (*jvmtienv)->AddCapabilities(jvmtienv, &cap);
}
if (e != JVMTI_ERROR_NONE) {
- log_text("error adding jvmti capabilities");
- exit(1);
+ fprintf(stderr,"jdwp: error adding jvmti capabilities");
+ return -1;
}
+
- end = sizeof(jvmti_jdwp_EventCallbacks) / sizeof(void*);
+ end = sizeof(jvmtiEventCallbacks) / sizeof(void*);
for (i = 0; i < end; i++) {
- /* enable standard VM callbacks */
+ /* enable VM callbacks */
if (((void**)&jvmti_jdwp_EventCallbacks)[i] != NULL) {
e = (*jvmtienv)->SetEventNotificationMode(jvmtienv,
- JVMTI_ENABLE,
- JVMTI_EVENT_START_ENUM+i,
- NULL);
-
+ JVMTI_ENABLE,
+ JVMTI_EVENT_START_ENUM+i,
+ NULL);
+
if (JVMTI_ERROR_NONE != e) {
- log_text("unable to setup event notification mode");
- return false;
+ fprintf(stderr,"jdwp: unable to setup event notification mode");
+ return -1;
}
}
}
- return true;
+
+ return 0;
}
- jvmtiEventCallbacks jvmti_jdwp_EventCallbacks = {
+
+jvmtiEventCallbacks jvmti_jdwp_EventCallbacks = {
&VMInit,
&VMDeath,
- &ThreadStart,
- &ThreadEnd,
- &ClassFileLoadHook,
- &ClassLoad,
- &ClassPrepare,
+ NULL, /* &ThreadStart,*/
+ NULL, /* &ThreadEnd, */
+ NULL, /* &ClassFileLoadHook, */
+ NULL, /* &ClassLoad, */
+ NULL, /* &ClassPrepare,*/
NULL, /* &VMStart */
- &Exception,
- &ExceptionCatch,
- &SingleStep,
- &FramePop,
- &Breakpoint,
- &FieldAccess,
- &FieldModification,
- &MethodEntry,
- &MethodExit,
- &NativeMethodBind,
- &CompiledMethodLoad,
- &CompiledMethodUnload,
- &DynamicCodeGenerated,
- &DataDumpRequest,
+ NULL, /* &Exception, */
+ NULL, /* &ExceptionCatch, */
+ NULL, /* &SingleStep, */
+ NULL, /* &FramePop, */
+ NULL, /* &Breakpoint, */
+ NULL, /* &FieldAccess, */
+ NULL, /* &FieldModification, */
+ NULL, /* &MethodEntry, */
+ NULL, /* &MethodExit, */
+ NULL, /* &NativeMethodBind, */
+ NULL, /* &CompiledMethodLoad, */
+ NULL, /* &CompiledMethodUnload, */
+ NULL, /* &DynamicCodeGenerated, */
+ NULL, /* &DataDumpRequest, */
NULL,
- &MonitorWait,
- &MonitorWaited,
- &MonitorContendedEnter,
- &MonitorContendedEntered,
+ NULL, /* &MonitorWait, */
+ NULL, /* &MonitorWaited, */
+ NULL, /* &MonitorContendedEnter, */
+ NULL, /* &MonitorContendedEntered, */
NULL,
NULL,
NULL,
NULL,
- &GarbageCollectionStart,
- &GarbageCollectionFinish,
- &ObjectFree,
- &VMObjectAlloc,
+ NULL, /* &GarbageCollectionStart, */
+ NULL, /* &GarbageCollectionFinish, */
+ NULL, /* &ObjectFree, */
+ NULL, /* &VMObjectAlloc, */
};
Samuel Vinson
- $Id: jvmti.c 4946 2006-05-24 11:00:38Z motse $
+ $Id: jvmti.c 4954 2006-05-25 21:59:49Z motse $
*/
CHECK_PHASE_END;
CHECK_CAPABILITY(env,can_suspend);
- log_text ("JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
- return JVMTI_ERROR_NOT_AVAILABLE;
+ if(thread == NULL) return JVMTI_ERROR_INVALID_THREAD;
+ if (!builtin_instanceof(thread,class_java_lang_Thread))
+ return JVMTI_ERROR_INVALID_THREAD;
+ CHECK_THREAD_IS_ALIVE(thread);
+
+ /* quick try - this should be changed in the future */
+ pthread_kill(((threadobject*)((java_lang_Thread*) thread)->vmThread)->tid,
+ GC_signum1());
+
+
return JVMTI_ERROR_NONE;
}
CHECK_PHASE_END;
CHECK_CAPABILITY(env,can_suspend);
- log_text ("JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
- return JVMTI_ERROR_NOT_AVAILABLE;
+ if(thread == NULL) return JVMTI_ERROR_INVALID_THREAD;
+ if (!builtin_instanceof(thread,class_java_lang_Thread))
+ return JVMTI_ERROR_INVALID_THREAD;
+ CHECK_THREAD_IS_ALIVE(thread);
+
+
+ /* quick try - this should be changed in the future */
+ pthread_kill(((threadobject*)((java_lang_Thread*) thread)->vmThread)->tid,
+ GC_signum2());
return JVMTI_ERROR_NONE;
}
/* SuspendThreadList **********************************************************
-
+ Suspend all threads in the request list.
*******************************************************************************/
SuspendThreadList (jvmtiEnv * env, jint request_count,
const jthread * request_list, jvmtiError * results)
{
+ int i;
+ int suspendme = -1;
+ jthread me;
+
CHECK_PHASE_START
CHECK_PHASE(JVMTI_PHASE_START)
CHECK_PHASE(JVMTI_PHASE_LIVE)
CHECK_PHASE_END;
CHECK_CAPABILITY(env,can_suspend);
-
- log_text ("JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
+
+ if (request_count<0) return JVMTI_ERROR_ILLEGAL_ARGUMENT;
+ if ((request_list==NULL) || (results == NULL))
+ return JVMTI_ERROR_NULL_POINTER;
+
+ me = jvmti_get_current_thread();
+
+ for (i=0;i<request_count;i++) {
+ if (request_list[i] == me)
+ suspendme = i;
+ else
+ results[i]=SuspendThread(env, request_list[i]);
+ }
+
+ if (suspendme != -1)
+ results[suspendme]=SuspendThread(env, request_list[suspendme]);
return JVMTI_ERROR_NONE;
}
/* ResumeThreadList ***********************************************************
-
+ Resumes all threads in the request list.
*******************************************************************************/
ResumeThreadList (jvmtiEnv * env, jint request_count,
const jthread * request_list, jvmtiError * results)
{
+ int i;
+
CHECK_PHASE_START
CHECK_PHASE(JVMTI_PHASE_LIVE)
CHECK_PHASE_END;
CHECK_CAPABILITY(env,can_suspend);
-
- log_text ("JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
+
+ if (request_count<0) return JVMTI_ERROR_ILLEGAL_ARGUMENT;
+ if ((request_list==NULL) || (results == NULL))
+ return JVMTI_ERROR_NULL_POINTER;
+
+ for (i=0;i<request_count;i++)
+ results[i]=ResumeThread(env, request_list[i]);
return JVMTI_ERROR_NONE;
}
if (size_of_callbacks < 0) return JVMTI_ERROR_ILLEGAL_ARGUMENT;
+
if (callbacks == NULL) { /* remove the existing callbacks */
memset(&(((environment* )env)->callbacks), 0,
sizeof(jvmtiEventCallbacks));
*******************************************************************************/
static jvmtiError
-GetPotentialCapabilities (jvmtiEnv * env,
- jvmtiCapabilities * capabilities_ptr)
+GetPotentialCapabilities (jvmtiEnv * env, jvmtiCapabilities * capabilities_ptr)
{
CHECK_PHASE_START
CHECK_PHASE(JVMTI_PHASE_ONLOAD)
0, /* can_generate_exception_events */
0, /* can_generate_frame_pop_events */
0, /* can_generate_breakpoint_events */
- 0, /* can_suspend */
+ 1, /* can_suspend */
0, /* can_redefine_any_class */
0, /* can_get_current_thread_cpu_time */
0, /* can_get_thread_cpu_time */
int i=0,len;
jint retval;
-
len = strlen(opt_arg);
/* separate argumtents */
- while ((opt_arg[i]!='=')&&(i<=len)) i++;
- arg = &opt_arg[i];
+ while ((opt_arg[i]!='=')&&(i<len)) i++;
+ if (i<len)
+ arg = &opt_arg[i+1];
+ else
+ arg = "";
if (agentbypath) {
/* -agentpath */
*libname=heap_allocate(sizeof(char)*i,true,NULL);
- strncpy(*libname,opt_arg,i-1);
- (*libname)[i-1]='\0';
+ strncpy(*libname,opt_arg,i);
+ (*libname)[i]='\0';
} else {
/* -agentlib */
*libname=heap_allocate(sizeof(char)*(i+7),true,NULL);
strncpy(*libname,"lib",3);
- strncpy(&(*libname)[3],opt_arg,i-1);
- strncpy(&(*libname)[i+2],".so",3);
+ strncpy(&(*libname)[3],opt_arg,i);
+ strncpy(&(*libname)[i+3],".so",3);
}
/* try to open the library */