1 /* src/native/vm/VMjdwp.c - jvmti->jdwp interface
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Author: Martin Platter
32 $Id: VMjdwp.c 4892 2006-05-06 18:29:55Z motse $
36 #include "native/jvmti/jvmti.h"
37 #include "native/jvmti/cacaodbg.h"
38 #include "native/jvmti/VMjdwp.h"
39 #include "vm/loader.h"
40 #include "vm/exceptions.h"
41 #include "vm/jit/asmpart.h"
46 static methodinfo *notifymid = NULL;
47 static classinfo *Jdwpclass = NULL;
50 #define FINDCLASS(jni_env,class,classname) \
51 class = load_class_from_sysloader(utf_new_char(classname)); \
52 if (!class) throw_main_exception_exit();
55 #define GETJNIMETHOD(jni_env,class,classname,method,methodname,methodsig) \
56 FINDCLASS(jni_env,class,classname) \
57 method = class_resolveclassmethod (class,utf_new_char(methodname), \
58 utf_new_char(methodsig), \
59 class_java_lang_Object,true); \
60 if (!method) throw_main_exception_exit();
62 #define GETJNISTATICMETHOD(jni_env,class,classname,method,methodname,methodsig) \
63 FINDCLASS(jni_env,class,classname) \
64 method = class_resolveclassmethod (class,utf_new_char(methodname), \
65 utf_new_char(methodsig), \
66 class_java_lang_Object,true); \
67 if (!method) throw_main_exception_exit();
70 static void notify (JNIEnv* env, jobject event){
71 log_text("VMjdwp notfiy called");
73 if (notifymid == NULL) {
74 GETJNISTATICMETHOD(env,Jdwpclass,"gnu/classpath/jdwp/Jdwp",notifymid,
75 "notify","(Lgnu/classpath/jdwp/event/Event;)V");
79 vm_call_method(notifymid, NULL ,event);
81 throw_main_exception_exit();
86 static void SingleStep (jvmtiEnv *jvmti_env,
91 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
94 static void Breakpoint (jvmtiEnv *jvmti_env,
99 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
102 static void FieldAccess (jvmtiEnv *jvmti_env,
111 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
114 static void FieldModification (jvmtiEnv *jvmti_env,
124 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
127 static void FramePop (jvmtiEnv *jvmti_env,
131 jboolean was_popped_by_exception){
132 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
135 static void MethodEntry (jvmtiEnv *jvmti_env,
139 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
142 static void MethodExit (jvmtiEnv *jvmti_env,
146 jboolean was_popped_by_exception,
147 jvalue return_value){
148 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
151 static void NativeMethodBind (jvmtiEnv *jvmti_env,
156 void** new_address_ptr){
157 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
160 static void Exception (jvmtiEnv *jvmti_env,
166 jmethodID catch_method,
167 jlocation catch_location){
168 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
171 static void ExceptionCatch (jvmtiEnv *jvmti_env,
177 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
180 static void ThreadStart (jvmtiEnv *jvmti_env,
187 GETJNIMETHOD(jni_env,cl,"gnu/classpath/jdwp/event/ThreadStartEvent",cc,"<init>","(Ljava/lang/Thread;)V");
189 obj = builtin_new(cl);
190 if (!obj) throw_main_exception_exit();
192 fprintf(stderr,"VMjdwp:ThreadStart: thread %p\n",thread);
195 vm_call_method((methodinfo*)cc, obj, thread);
198 throw_main_exception_exit();
200 notify (jni_env,obj);
203 static void ThreadEnd (jvmtiEnv *jvmti_env,
206 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
209 static void ClassLoad (jvmtiEnv *jvmti_env,
213 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
216 static void ClassPrepare (jvmtiEnv *jvmti_env,
220 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
223 static void ClassFileLoadHook (jvmtiEnv *jvmti_env,
225 jclass class_being_redefined,
228 jobject protection_domain,
230 const unsigned char* class_data,
231 jint* new_class_data_len,
232 unsigned char** new_class_data){
233 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
236 static void VMStart (jvmtiEnv *jvmti_env,
238 log_text ("JVMTI-Event:VMStart IMPLEMENT ME!!!");
241 static void VMInit (jvmtiEnv *jvmti_env,
246 java_objectheader* obj;
248 log_text ("JVMTI-Event:VMInit");
250 GETJNIMETHOD(jni_env,cl,"gnu/classpath/jdwp/event/VmInitEvent",cc,"<init>",
251 "(Ljava/lang/Thread;)V");
253 fprintf(stderr,"VMjdwp:VMInit: 1\n");
255 obj = builtin_new(cl);
256 if (!obj) throw_main_exception_exit();
258 fprintf(stderr,"VMjdwp:VMInit: thread %p\n",thread);
261 vm_call_method((methodinfo*)cc, obj, thread);
264 throw_main_exception_exit();
266 notify (jni_env,obj);
269 static void VMDeath (jvmtiEnv *jvmti_env,
271 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
275 static void CompiledMethodLoad (jvmtiEnv *jvmti_env,
278 const void* code_addr,
280 const jvmtiAddrLocationMap* map,
281 const void* compile_info) {
282 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
285 static void CompiledMethodUnload (jvmtiEnv *jvmti_env,
287 const void* code_addr){
288 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
291 static void DynamicCodeGenerated (jvmtiEnv *jvmti_env,
295 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
298 static void DataDumpRequest (jvmtiEnv *jvmti_env){
299 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
302 static void MonitorContendedEnter (jvmtiEnv *jvmti_env,
306 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
309 static void MonitorContendedEntered (jvmtiEnv *jvmti_env,
313 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
316 static void MonitorWait (jvmtiEnv *jvmti_env,
321 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
324 static void MonitorWaited (jvmtiEnv *jvmti_env,
329 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
332 static void VMObjectAlloc (jvmtiEnv *jvmti_env,
338 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
341 static void ObjectFree (jvmtiEnv *jvmti_env,
343 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
346 static void GarbageCollectionStart (jvmtiEnv *jvmti_env){
347 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
350 static void GarbageCollectionFinish (jvmtiEnv *jvmti_env){
351 log_text ("JVMTI-Event: IMPLEMENT ME!!!");
355 /* it would be more apropriate to call this function from gnu-cp jdwp */
358 jvmtiCapabilities cap;
361 log_text("cacao vm - create new jvmti environment");
362 jvmtienv = new_jvmtienv();
364 /* set eventcallbacks */
365 if (JVMTI_ERROR_NONE !=
366 (*jvmtienv)->SetEventCallbacks(jvmtienv,
367 &jvmti_jdwp_EventCallbacks,
368 sizeof(jvmti_jdwp_EventCallbacks))){
369 log_text("unable to setup event callbacks");
373 e = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &cap);
374 if (e == JVMTI_ERROR_NONE) {
375 e = (*jvmtienv)->AddCapabilities(jvmtienv, &cap);
377 if (e != JVMTI_ERROR_NONE) {
378 log_text("error adding jvmti capabilities");
382 end = sizeof(jvmti_jdwp_EventCallbacks) / sizeof(void*);
383 for (i = 0; i < end; i++) {
384 /* enable standard VM callbacks */
385 if (((void**)&jvmti_jdwp_EventCallbacks)[i] != NULL) {
386 e = (*jvmtienv)->SetEventNotificationMode(jvmtienv,
388 JVMTI_EVENT_START_ENUM+i,
391 if (JVMTI_ERROR_NONE != e) {
392 log_text("unable to setup event notification mode");
400 jvmtiEventCallbacks jvmti_jdwp_EventCallbacks = {
420 &CompiledMethodUnload,
421 &DynamicCodeGenerated,
426 &MonitorContendedEnter,
427 &MonitorContendedEntered,
432 &GarbageCollectionStart,
433 &GarbageCollectionFinish,
440 * These are local overrides for various environment variables in Emacs.
441 * Please do not remove this and leave it at the end of the file, where
442 * Emacs will automagically detect them.
443 * ---------------------------------------------------------------------
446 * indent-tabs-mode: t