Christian Thalinger
Edwin Steiner
- $Id: headers.c 4938 2006-05-22 09:06:44Z twisti $
+ $Id: headers.c 5019 2006-06-06 21:13:41Z motse $
*/
}
}
+/* jvmti releated functions ************************************************/
+
+#if defined(ENABLE_JVMTI)
+void jvmti_fireEvent(void* d) {;}
+#endif
+
+
/*
* These are local overrides for various environment variables in Emacs.
Changes:
- $Id: VMjdwp.c 4996 2006-05-31 13:53:16Z motse $
+ $Id: VMjdwp.c 5019 2006-06-06 21:13:41Z motse $
*/
}
-
-static jmethodID notifymid = NULL;
-static jclass Jdwpclass = NULL;
+/* class and method IDs */
+static jclass Jdwpclass, threadstartclass,threadendclass, classprepareclass, vmmethodclass, locationclass, breakpointclass;
+static jmethodID notifymid, threadstartmid,threadendmid, classpreparemid,
+ vmmethodmid, locationmid, breakpointmid;
static void notify (JNIEnv* jni_env, jobject event){
- fprintf(stderr,"VMjdwp notfiy called");
-
- if (notifymid == NULL) {
- 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);
- }
- }
-
+ fprintf(stderr,"VMjdwp notfiy called\n");
+
(*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 ThreadStart (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env,
+static void ThreadStart (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
jthread thread){
- jclass cl;
- jmethodID cc;
jobject obj;
- GETJNIMETHOD(jni_env,cl,"gnu/classpath/jdwp/event/ThreadStartEvent",cc,"<init>","(Ljava/lang/Thread;)V");
-
- obj = builtin_new(cl);
- if (!obj) throw_main_exception_exit();
+ obj = (*jni_env)->
+ NewObject(jni_env, threadstartclass, threadstartmid, thread);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling ThreadStartEvent constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ return;
+ }
fprintf(stderr,"VMjdwp:ThreadStart: thread %p\n",thread);
fflush(stderr);
- vm_call_method((methodinfo*)cc, obj, thread);
+ notify (jni_env,obj);
+}
+
+
+static void ThreadEnd (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+ jthread thread){
+ jobject obj;
+
+
+ obj = (*jni_env)->NewObject(jni_env, threadendclass, threadendmid, thread);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling ThreadEndEvent constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ return;
+ }
+
+ fprintf(stderr,"VMjdwp:ThreadEnd: thread %p\n",thread);
+ fflush(stderr);
+
+ notify (jni_env,obj);
+}
+
+
+static void ClassPrepare (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+ jthread thread, jclass klass) {
+ jobject obj;
+ int classstatus;
+ jvmtiError e;
+
+ if (JVMTI_ERROR_NONE !=
+ (e = (*jvmtienv)->GetClassStatus(jvmtienv, klass, &classstatus))) {
+ printjvmtierror("unable to get class status", e);
+ return;
+ }
- if (*exceptionptr)
- throw_main_exception_exit();
+ obj = (*jni_env)->NewObject(jni_env, classprepareclass, classpreparemid, thread, klass, classstatus);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling ClassPrepareEvent constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ return;
+ }
+
+ fprintf(stderr,"VMjdwp:ClassPrepareEvent: thread %p\n",thread);
+ fflush(stderr);
notify (jni_env,obj);
- } */
+}
+
+static void Exception (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
+ jmethodID method, jlocation location, jobject exception,
+ jmethodID catch_method, jlocation catch_location) {
+ /* gnu classpath jdwp has no ExceptionEvent yet */
+ fprintf(stderr,"VMjdwp:Exception: thread %p\n",thread);
+ fflush(stderr);
+
+}
+
+static void Breakpoint (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
+ jmethodID method, jlocation location) {
+ jobject vmmethod, loc, ev;
+ jclass mcl;
+ jvmtiError e;
+
+ if (JVMTI_ERROR_NONE !=
+ (e = (*jvmtienv)->GetMethodDeclaringClass(jvmtienv,
+ method,
+ &mcl))){
+ printjvmtierror("unable to get declaring class", e);
+ return;
+ }
+
+ vmmethod = (*jni_env)->NewObject(jni_env, vmmethodclass, vmmethodmid,
+ mcl, method);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling VMMethod constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ return;
+ }
+
+ loc = (*jni_env)->NewObject(jni_env, locationclass, locationmid,
+ vmmethod, location);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling location constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ return;
+ }
+
+ ev = (*jni_env)->NewObject(jni_env, breakpointclass, breakpointmid,
+ thread, loc);
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+ fprintf(stderr,"error calling breakpoint constructor\n");
+ (*jni_env)->ExceptionDescribe(jni_env);
+ return;
+ }
+
+ fprintf(stderr,"VMjdwp:Breakpoint: thread %p\n",thread);
+ fflush(stderr);
+
+ notify (jni_env,ev);
+}
+
+
+static void MethodEntry (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+ jthread thread, jmethodID method) {
+ /* do not report gnu/classpath/jdwp method entries */
+}
+
+
+static void VMDeath (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env) {
+ fprintf(stderr,"JVMTI-Event: IMPLEMENT ME!!!");
+}
/* setup_jdwp_thread **********************************************************
jstring s;
/* 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);
- }
-
-
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);
}
+
+ jdwpthread = (jthread)o;
/* configure(jdwpoptions) */
}
}
+#define FINDCLASSWITHEXCEPTION(CLASS,SIGNATURE) \
+ CLASS = (*jni_env)->FindClass(jni_env, SIGNATURE); \
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) { \
+ fprintf(stderr,"could not find %s\n", SIGNATURE); \
+ (*jni_env)->ExceptionDescribe(jni_env); \
+ exit(1); \
+ }
+#define GETMIDWITHEXCEPTION(CLASS, CLASSNAME, MID, METHODNAME, METHODSIG) \
+ FINDCLASSWITHEXCEPTION(CLASS, CLASSNAME); \
+ MID = (*jni_env)->GetMethodID(jni_env, CLASS, METHODNAME, METHODSIG); \
+ if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) { \
+ fprintf(stderr,"could not get %s %s\n",CLASSNAME, METHODNAME); \
+ (*jni_env)->ExceptionDescribe(jni_env); \
+ exit(1); \
+ }
+
+
+static void fillidcache(JNIEnv* jni_env) {
+ FINDCLASSWITHEXCEPTION(Jdwpclass, "gnu/classpath/jdwp/Jdwp");
+
+ 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);
+ }
+
+ GETMIDWITHEXCEPTION(threadstartclass,
+ "gnu/classpath/jdwp/event/ThreadStartEvent",
+ threadstartmid, "<init>", "(Ljava/lang/Thread;)V");
+
+
+ GETMIDWITHEXCEPTION(threadendclass,
+ "gnu/classpath/jdwp/event/ThreadEndEvent",
+ threadendmid, "<init>", "(Ljava/lang/Thread;)V");
+
+
+ GETMIDWITHEXCEPTION(classprepareclass,
+ "gnu/classpath/jdwp/event/ClassPrepareEvent",
+ classpreparemid, "<init>",
+ "(Ljava/lang/Thread;Ljava/lang/Class;I)V");
+
+
+ GETMIDWITHEXCEPTION(vmmethodclass, "gnu/classpath/jdwp/VMMethod",
+ vmmethodmid, "<init>", "(Ljava/lang/Class;J)V");
+
+ GETMIDWITHEXCEPTION(locationclass, "gnu/classpath/jdwp/util/Location",
+ locationmid, "<init>",
+ "(Lgnu/classpath/jdwp/VMMethod;J)V");
+
+
+ GETMIDWITHEXCEPTION(
+ breakpointclass,
+ "gnu/classpath/jdwp/event/BreakpointEvent",
+ breakpointmid, "<init>",
+ "(Ljava/lang/Thread;Lgnu/classpath/jdwp/util/Location;)V");
+
+}
static void VMInit (jvmtiEnv *jvmti_env,
JNIEnv* jni_env,
jclass cl;
jmethodID m;
jobject eventobj;
- jvmtiError err;
+ jvmtiError err;
fprintf(stderr,"JDWP VMInit\n");
+ /* get needed jmethodIDs and jclasses for callbacks */
+ fillidcache(jni_env);
+
/* startup gnu classpath jdwp thread */
setup_jdwp_thread(jni_env);
fprintf(stderr,"JDWP listening thread started\n");
+ /* send VmInitEvent */
cl = (*jni_env)->FindClass(jni_env,
"gnu/classpath/jdwp/event/VmInitEvent");
if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
}
}
-static void VMDeath (jvmtiEnv *jvmti_env,
- JNIEnv* jni_env) {
- fprintf(stderr,"JVMTI-Event: IMPLEMENT ME!!!");
-}
-
static void usage() {
puts("usage jdwp:[help]|(<option>=<value>),*");
puts(" transport=[dt_socket|...]");
JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
jint rc;
- int end, i=0;
jvmtiCapabilities cap;
jvmtiError e;
return -1;
}
-
- end = sizeof(jvmtiEventCallbacks) / sizeof(void*);
- for (i = 0; i < end; i++) {
- /* enable VM callbacks */
- if (((void**)&jvmti_jdwp_EventCallbacks)[i] != NULL) {
- e = (*jvmtienv)->SetEventNotificationMode(jvmtienv,
- JVMTI_ENABLE,
- JVMTI_EVENT_START_ENUM+i,
- NULL);
-
- if (JVMTI_ERROR_NONE != e) {
- printjvmtierror("jdwp: unable to setup event notification mode",e);
- return -1;
- }
- }
+ /* only enable needed events. VMVirtualMachine.registerEvent will
+ be used to enable other events by need */
+ if (JVMTI_ERROR_NONE != (e = (*jvmtienv)->
+ SetEventNotificationMode(jvmtienv, JVMTI_ENABLE,
+ JVMTI_EVENT_VM_INIT,
+ NULL))) {
+ printjvmtierror("jdwp unable to enable vm init callback",e);
+ return -1;
}
return 0;
jvmtiEventCallbacks jvmti_jdwp_EventCallbacks = {
&VMInit,
&VMDeath,
- NULL, /* &ThreadStart,*/
- NULL, /* &ThreadEnd, */
+ &ThreadStart,
+ &ThreadEnd,
NULL, /* &ClassFileLoadHook, */
NULL, /* &ClassLoad, */
- NULL, /* &ClassPrepare,*/
+ &ClassPrepare,
NULL, /* &VMStart */
- NULL, /* &Exception, */
+ &Exception,
NULL, /* &ExceptionCatch, */
NULL, /* &SingleStep, */
NULL, /* &FramePop, */
- NULL, /* &Breakpoint, */
+ &Breakpoint,
NULL, /* &FieldAccess, */
NULL, /* &FieldModification, */
- NULL, /* &MethodEntry, */
+ &MethodEntry,
NULL, /* &MethodExit, */
NULL, /* &NativeMethodBind, */
NULL, /* &CompiledMethodLoad, */
extern jvmtiEventCallbacks jvmti_jdwp_EventCallbacks;
char* jdwpoptions;
bool suspend; /* should the virtual machine suspend on startup? */
+jthread jdwpthread;
void printjvmtierror(char *desc, jvmtiError err);
#endif
void jvmti_cacao_debug_init() {
pid_t dbgserver;
- void* addr[2];
/* start new cacaodbgserver if needed*/
pthread_mutex_lock(&dbgcomlock);
if (dbgcom == NULL) {
dbgcom = heap_allocate(sizeof(cacaodbgcommunication),true,NULL);
dbgcom->running = 1;
+ jvmti = true;
breakpointtable_creator();
/* set addresses of hard coded TRAPs */
__asm__ ("movl $cacaodbgserver_quit,%0;"
:"=m"(dbgcom->jvmtibrkpt.brk[CACAODBGSERVERQUIT].addr));
- jvmti_get_threads_breakpoints(addr);
- dbgcom->jvmtibrkpt.brk[THREADSTARTBRK].addr = addr[0];
- dbgcom->jvmtibrkpt.brk[THREADENDBRK].addr = addr[1];
-
dbgserver = fork();
if (dbgserver == (-1)) {
log_text("cacaodbgserver fork error");
cacaodbgcommunication *dbgcom;
-bool jvmti; /* jvmti agent */
+bool jvmti; /* jvmti agent */
extern pthread_mutex_t dbgcomlock;
fflush(gdbout);
getgdboutput(inbuf,160);
- if ((match=strstr(inbuf,DATAEVALUATE))==NULL) {
+ if ((match=strstr(inbuf,DATAEVALUATE)) == NULL) {
fprintf(stderr,"dataevaluate: no matching value\n");
return -1;
}
- return strtoll(&match[strlen(DATAEVALUATE)],NULL,16);
+ return strtoll(&match[strlen(DATAEVALUATE)], NULL, 16);
}
getgdboutput(inbuf,INBUFLEN);
fprintf(stderr,"gdbin: %s\n",inbuf);
SENDCMD("-gdb-exit\n");
- return false;
+ return;
}
}
Samuel Vinson
- $Id: jvmti.c 4996 2006-05-31 13:53:16Z motse $
+ $Id: jvmti.c 5019 2006-06-06 21:13:41Z motse $
*/
#define CHECK_CAPABILITY(env,CAP) if(((environment*) \
env)->capabilities.CAP == 0) \
return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
-#define CHECK_THREAD_IS_ALIVE(t) if(check_thread_is_alive(t)== \
+#define CHECK_THREAD_IS_ALIVE(t) if(check_thread_is_alive(t) == \
JVMTI_ERROR_THREAD_NOT_ALIVE) \
return JVMTI_ERROR_THREAD_NOT_ALIVE;
*******************************************************************************/
static jvmtiError check_thread_is_alive(jthread t) {
- if(t==NULL) return JVMTI_ERROR_THREAD_NOT_ALIVE;
- if(((java_lang_Thread*) t)->vmThread==NULL)
+ if(t == NULL) return JVMTI_ERROR_THREAD_NOT_ALIVE;
+ if(((java_lang_Thread*) t)->vmThread == NULL)
return JVMTI_ERROR_THREAD_NOT_ALIVE;
return JVMTI_ERROR_NONE;
}
functionptr ec;
env = envs;
- while (env!=NULL) {
+ while (env != NULL) {
if (env->events[e-JVMTI_EVENT_START_ENUM].mode == JVMTI_DISABLE) {
evm = env->events[e-JVMTI_EVENT_START_ENUM].next;
/* test if the event is enable for some threads */
- while (evm!=NULL) {
+ while (evm != NULL) {
if (evm->mode == JVMTI_ENABLE) {
- data->jvmti_env=&env->env;
- ec = ((functionptr*)(&env->callbacks))[e-JVMTI_EVENT_START_ENUM];
- execute_callback(e, ec, data);
+ ec = ((functionptr*)
+ (&env->callbacks))[e-JVMTI_EVENT_START_ENUM];
+ if (ec != NULL) {
+ data->jvmti_env=&env->env;
+ execute_callback(e, ec, data);
+ }
}
evm=evm->next;
}
} else { /* event enabled globally */
data->jvmti_env=&env->env;
ec = ((functionptr*)(&env->callbacks))[e-JVMTI_EVENT_START_ENUM];
- execute_callback(e, ec, data);
+ if (ec != NULL) execute_callback(e, ec, data);
}
env=env->next;
jthread thread;
/* XXX todo : respect event order JVMTI-Spec:Multiple Co-located Events */
- if (d->ev != JVMTI_EVENT_VM_START)
- thread = jvmti_get_current_thread();
- else
+ if (d->ev == JVMTI_EVENT_VM_START)
thread = NULL;
+ else
+ thread = jvmti_get_current_thread();
+
d->thread = thread;
dofireEvent(d->ev,d);
CHECK_THREAD_IS_ALIVE(event_thread);
}
-
cacao_env = (environment*) env;
if ((mode != JVMTI_ENABLE) && (mode != JVMTI_DISABLE))
return JVMTI_ERROR_ILLEGAL_ARGUMENT;
case JVMTI_EVENT_VM_OBJECT_ALLOC:
CHECK_CAPABILITY(env,can_generate_vm_object_alloc_events)
break;
- case JVMTI_EVENT_THREAD_START:
- jvmti_set_system_breakpoint(THREADSTARTBRK, mode);
- break;
- case JVMTI_EVENT_THREAD_END:
- jvmti_set_system_breakpoint(THREADENDBRK, mode);
- break;
-
default:
/* all other events are required */
if ((event_type < JVMTI_EVENT_START_ENUM) ||
break;
}
+
if (event_thread != NULL) {
/* thread level control */
if ((JVMTI_EVENT_VM_INIT == mode) ||
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());
-
+ /* threads_suspend_thread will implement suspend
+ threads_suspend_thread (
+ (threadobject*)((java_lang_Thread*) thread)->vmThread))*/
return JVMTI_ERROR_NONE;
}
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());
+ /* threads_resume_thread will implement resume
+ threads_resume_thread (
+ (threadobject*)((java_lang_Thread*) thread)->vmThread))*/
return JVMTI_ERROR_NONE;
}
CHECK_PHASE_END;
CHECK_CAPABILITY(env,can_get_owned_monitor_info);
- if ((owned_monitors_ptr==NULL)||(owned_monitor_count_ptr==NULL))
+ if ((owned_monitors_ptr == NULL)||(owned_monitor_count_ptr == NULL))
return JVMTI_ERROR_NULL_POINTER;
if (thread == NULL) {
CHECK_PHASE_END;
CHECK_CAPABILITY(env, can_get_current_contended_monitor)
- if (monitor_ptr==NULL) return JVMTI_ERROR_NULL_POINTER;
+ if (monitor_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
*monitor_ptr=NULL;
if(!builtin_instanceof(thread,class_java_lang_Thread))
lrp=lock_global_pool;
- while ((lrp != NULL)&&(monitor==NULL)) {
+ while ((lrp != NULL)&&(monitor == NULL)) {
for (j=0; j<lrp->header.size; j++) {
/* if((lrp->lr[j].owner==(threadobject*)thread)&&(lrp->lr[j].waiting)) {
monitor=lrp->lr[j].o;
CHECK_PHASE(JVMTI_PHASE_LIVE)
CHECK_PHASE_END;
- log_text("GetTopThreadGroups called");
-
if ((groups_ptr == NULL) || (group_count_ptr == NULL))
return JVMTI_ERROR_NULL_POINTER;
/* getcacaostacktrace *********************************************************
Helper function that retrives stack trace for specified thread.
- Has to take care of suspend/resume issuses
-
+
*******************************************************************************/
+
static jvmtiError getcacaostacktrace(stacktracebuffer** trace, jthread thread) {
threadobject *t;
+ bool resume;
- if (thread == NULL)
+ if (thread == NULL) {
t = jvmti_get_current_thread();
- else {
+ *trace = stacktrace_create(t);
+ } else {
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 - this needs a working thread suspend */
- return JVMTI_ERROR_INTERNAL;
+/* if (t != jvmti_get_current_thread())
+ resume = threads_suspend_thread_if_running(thread);
+
+ *trace = stacktrace_create(thread );
+
+ if (resume)
+ threads_resume_thread ( thread );*/
}
- *trace = stacktrace_create(t);
-
return JVMTI_ERROR_NONE;
}
/* GetFrameCount **************************************************************
- Get the number of frames in the specified thread's stack.
+ Get the number of frames in the specified thread's stack. Calling function
+ has to take care of suspending/resuming thread.
*******************************************************************************/
if(count_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
er = getcacaostacktrace(&trace, thread);
- if (er==JVMTI_ERROR_NONE) {
+ if (er == JVMTI_ERROR_NONE) {
heap_free(trace);
return er;
}
*thread_state_ptr = 0;
#if defined(ENABLE_THREADS)
- if((th->vmThread==NULL)&&(th->group==NULL)) { /* alive ? */
+ if((th->vmThread == NULL)&&(th->group == NULL)) { /* alive ? */
/* not alive */
if (((threadobject*)th->vmThread)->tid == 0)
*thread_state_ptr = JVMTI_THREAD_STATE_TERMINATED;
if (((methodinfo*)method)->flags & ACC_NATIVE)
return JVMTI_ERROR_NATIVE_METHOD;
-
+
*max_ptr = (jint) ((methodinfo*)method)->maxlocals;
return JVMTI_ERROR_NONE;
if (((methodinfo*)method)->flags & ACC_NATIVE)
return JVMTI_ERROR_NATIVE_METHOD;
-/* todo *size_ptr = (jint)((methodinfo*)method)->paramcount;*/
+ *size_ptr = (jint)((methodinfo*)method)->parseddesc->paramslots;
return JVMTI_ERROR_NONE;
}
-/* GetLineNumberTable ***********************************************************
+/* GetLineNumberTable **********************************************************
Return table of source line number entries for a given method
if ((method == NULL) || (entry_count_ptr == NULL) || (table_ptr == NULL))
return JVMTI_ERROR_NULL_POINTER;
+
if (((methodinfo*)method)->flags & ACC_NATIVE)
return JVMTI_ERROR_NATIVE_METHOD;
+
if (((methodinfo*)method)->linenumbers == NULL)
return JVMTI_ERROR_ABSENT_INFORMATION;
CHECK_PHASE(JVMTI_PHASE_LIVE)
CHECK_PHASE_END;
- if ((method == NULL) || (start_location_ptr == NULL) ||
- (end_location_ptr == NULL)) return JVMTI_ERROR_NULL_POINTER;
+ if (method == NULL) return JVMTI_ERROR_INVALID_METHODID;
+
+ if (((methodinfo*)method)->flags & ACC_NATIVE)
+ return JVMTI_ERROR_NATIVE_METHOD;
+
+ if ((start_location_ptr == NULL) || (end_location_ptr == NULL))
+ return JVMTI_ERROR_NULL_POINTER;
/* XXX we return the location of the most recent code. Don't know
* if there is a way to teach jvmti that a method can have more
fprintf(stderr,"GetMethodLocation *** XXX todo \n");
- if (!m->code)
- return JVMTI_ERROR_INTERNAL;
-
+
+ /* -1 states location information is not available */
+ *start_location_ptr = (jlocation)-1;
+ *end_location_ptr = (jlocation)-1;
+
+/*
*start_location_ptr = (jlocation)m->code->mcode;
- *end_location_ptr = (jlocation)(m->code->mcode)+m->code->mcodelength;
+ *end_location_ptr = (jlocation)(m->code->mcode)+m->code->mcodelength;*/
return JVMTI_ERROR_NONE;
}
while (nameentry != NULL) { /* iterate over hashlink */
/* filter pseudo classes $NEW$,$NULL$,$ARRAYSTUB$ out */
- if (nameentry->name->text[0]=='$')
+ if (nameentry->name->text[0] == '$')
{
*class_count_ptr -= 1;
break;
CHECK_CAPABILITY(env,can_suspend);
if (request_count<0) return JVMTI_ERROR_ILLEGAL_ARGUMENT;
- if ((request_list==NULL) || (results == NULL))
+ if ((request_list == NULL) || (results == NULL))
return JVMTI_ERROR_NULL_POINTER;
me = jvmti_get_current_thread();
CHECK_CAPABILITY(env,can_suspend);
if (request_count<0) return JVMTI_ERROR_ILLEGAL_ARGUMENT;
- if ((request_list==NULL) || (results == NULL))
+ if ((request_list == NULL) || (results == NULL))
return JVMTI_ERROR_NULL_POINTER;
for (i=0;i<request_count;i++)
if (max_frame_count <0) return JVMTI_ERROR_ILLEGAL_ARGUMENT;
er = getcacaostacktrace(&trace, thread);
- if (er==JVMTI_ERROR_NONE) {
+ if (er == JVMTI_ERROR_NONE) {
heap_free(trace);
return er;
}
CHECK_PHASE(JVMTI_PHASE_LIVE)
CHECK_PHASE_END;
- if ((extension_count_ptr== NULL)||(extensions == NULL))
+ if ((extension_count_ptr == NULL)||(extensions == NULL))
return JVMTI_ERROR_NULL_POINTER;
/* cacao has no extended functions yet */
CHECK_PHASE(JVMTI_PHASE_LIVE)
CHECK_PHASE_END;
- if ((extension_count_ptr== NULL)||(extensions == NULL))
+ if ((extension_count_ptr == NULL)||(extensions == NULL))
return JVMTI_ERROR_NULL_POINTER;
/* cacao has no extended events yet */
static jvmtiError
GetJLocationFormat (jvmtiEnv * env, jvmtiJlocationFormat * format_ptr)
{
- *format_ptr = JVMTI_JLOCATION_MACHINEPC;
+ *format_ptr = JVMTI_JLOCATION_OTHER;
return JVMTI_ERROR_NONE;
}
0, /* can_access_local_variables */
0, /* can_maintain_original_method_order */
0, /* can_generate_single_step_events */
- 0, /* can_generate_exception_events */
+ 1, /* can_generate_exception_events */
0, /* can_generate_frame_pop_events */
0, /* can_generate_breakpoint_events */
1, /* can_suspend */
0, /* can_redefine_any_class */
0, /* can_get_current_thread_cpu_time */
0, /* can_get_thread_cpu_time */
- 0, /* can_generate_method_entry_events */
+ 1, /* can_generate_method_entry_events */
0, /* can_generate_method_exit_events */
0, /* can_generate_all_class_hook_events */
0, /* can_generate_compiled_method_load_events */
len = strlen(opt_arg);
/* separate argumtents */
- while ((opt_arg[i]!='=')&&(i<len)) i++;
+ while ((opt_arg[i] != '=') && (i<len)) i++;
if (i<len)
arg = &opt_arg[i+1];
else
Changes:
- $Id: jvmti.h 4944 2006-05-23 15:31:19Z motse $
+ $Id: jvmti.h 5019 2006-06-06 21:13:41Z motse $
*/
#ifndef _JVMTI_H
#define _JVMTI_H
#include "native/jni.h"
-#include <sys/types.h>
#define JVMTI_VERSION_INTERFACE_JNI 0x00000000
{
jvmtiError err;
char *signature;
- struct java_lang_String* stringsignature;
+ jstring stringsignature;
if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
GetMethodName(jvmtienv,
Changes: Samuel Vinson
-$Id: VMVirtualMachine.c 4996 2006-05-31 13:53:16Z motse $
+$Id: VMVirtualMachine.c 5019 2006-06-06 21:13:41Z motse $
*/
EventKind2jvmtiEvent(kind), NULL)))
printjvmtierror("VMVirtualMachine_registerEvent SetEventNotificationMode",err);
- /* todo: error handling, suspend policy */
}
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_DISABLE,
- EventKind2jvmtiEvent(kind), NULL);
+ EventKind2jvmtiEvent(kind), NULL)))
+ printjvmtierror("VMVirtualMachine_registerEvent SetEventNotificationMode",err);
- /* todo: error handling, suspend policy */
}
* Signature: (B)V
*/
JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_clearEvents(JNIEnv *env, jclass clazz, s4 par1) {
- /* jvmti events are not saved */
- log_text ("VMVirtualMachine_clearEvents IMPLEMENT ME!!!");
+ /* jvmti events are not saved - there is nothing to clear */
}
Changes: Christian Thalinger
Edwin Steiner
- $Id: threads.c 4958 2006-05-26 11:57:20Z twisti $
+ $Id: threads.c 5019 2006-06-06 21:13:41Z motse $
*/
# include "boehm-gc/include/gc.h"
#endif
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
#if defined(__DARWIN__)
/* Darwin has no working semaphore implementation. This one is taken
methodinfo *method;
functionptr function;
+#if defined(ENABLE_JVMTI)
+ genericEventData d;
+#endif
+
#if defined(ENABLE_INTRP)
u1 *intrp_thread_stack;
#if defined(ENABLE_JVMTI)
/* breakpoint for thread start event */
- __asm__("threadstart:");
+ if (jvmti) {
+ d.ev = JVMTI_EVENT_THREAD_START;
+ jvmti_fireEvent(&d);
+ }
#endif
#if defined(ENABLE_JVMTI)
/* breakpoint for thread end event */
- __asm__("threadend:");
+ if (jvmti) {
+ d.ev = JVMTI_EVENT_THREAD_END;
+ jvmti_fireEvent(&d);
+ }
#endif
}
#endif
-
-#if defined(ENABLE_JVMTI)
-/* jvmti_get_threads_breakpoints ***********************************************
-
- gets all breakpoints from this file
-
-*******************************************************************************/
-
-void jvmti_get_threads_breakpoints(void **brks) {
- __asm__ ("movl $threadstart,%0;" :"=m"(brks[0]));
- __asm__ ("movl $threadend,%0;" :"=m"(brks[1]));
-}
-#endif
-
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Changes: Christian Thalinger
- $Id: threads.h 4953 2006-05-25 12:28:51Z twisti $
+ $Id: threads.h 5019 2006-06-06 21:13:41Z motse $
*/
void threads_dump(void);
-#if defined(ENABLE_JVMTI)
-void jvmti_get_threads_breakpoints(void **brks);
-#endif
/******************************************************************************/
/* Recursive Mutex Implementation for Darwin */
/******************************************************************************/