src/vm/vm.c (vm_create): rename jvmti function calls
authormotse <none@none>
Tue, 23 May 2006 15:31:19 +0000 (15:31 +0000)
committermotse <none@none>
Tue, 23 May 2006 15:31:19 +0000 (15:31 +0000)
src/cacao/cacao.c (main): rename jvmti function calls

src/native/jni.c (GetEnv): rename jvmti function calls. jvmti version changed to JVMTI_VERSION_INTERFACE_JVMTI

src/native/vm/VMVirtualMachine.c (getAllLoadedClassesCount): (Samuel Vinson) implemented.
(getAllLoadedClassesCount): jvmti Deallocate call added. (sv): CallObjectMethod fix
(getAllClassMethods): (Samuel Vinson) implemented.
(getClassMethod): (Samuel Vinson) implemented.

src/native/jvmti/jvmti.h: added JVMTI_VERSION interface and mask

src/native/jvmti/cacaodbgserver.h: msg queue/shared mem related things removed. gdb related defines added.

src/native/jvmti/dbg.h: remove ptrace related things

src/native/jvmti/cacaodbg.c change setsysbrkpt name to jvmti_set_system_breakpoint, addbrkpt to jvmti_add_breakpoint, allthreads to jvmti_get_all_threads
(jvmti_cacao_debug_init): new function where fork/exec of cacaodbgserver takes place
(jvmti_set_system_breakpoint): added functionality for brkpt delete and asm label for cacaodbgserver support
(jvmti_cacaodbgserver_quit): new function for killing cacaodbgserver properly
(jvmti_cacao_generic_breakpointhandler): new function. This is the entry point for every breakpointhandler and start for a new jvmti event
(jvmti_cacao_debug_init): new function for starting up cacaodbgserver process.

src/native/jvmti/VMjdwp.c (jvmti_VMjdwpInit): function renamed

src/native/jvmti/Makefile.am: delete dbg.c. (sv) add compile/install support for cacaodbgserver.

src/native/jvmti/cacaodbg.h: breakpoint counter added to struct _brkpt. change setsysbrkpt name to jvmti_set_system_breakpoint, addbrkpt to jvmti_add_breakpoint, allthreads to jvmti_get_all_threads, fireEvent to jvmti_fireEvent, agentload to jvmti_agentload agentunload to jvmti_agentunload, getcurrentthread to jvmti_get_current_thread, set_jvmti_phase to jvmti_set_phase, new_jvmtienv to jvmti_new_environment, VMjdwpinit to jvmti_VMjdwpInit. added breakpoint table constants. removed global jdwp, jvmti, suspend, transport, agentarg variables

src/native/jvmti/jvmti.c all jvmti-environment function changed to static functions. execcallback renamed to execute_callback. fireEvent renamed to jvmti_fireEvent.
(execute_callback): add phase checks
(GetClassMethods): bugfix in copying jmethodIDs
(DisposeEnvironment): relocate work to jvmti_cacaodbgserver_quit
(jvmti_new_environment) : relocate forking new process to jvmti_cacao_debug_init
(CHECK_ADD_CAPABILITY): bugfix in adding capabilities
(GetClassMethods): bugfix coping methodinfo pointers
(SetEventNotificationMode): setsysbrkpt calls added.
rename jvmti function names.

src/native/jvmti/cacaodbgserver.c changed to support gdb insted of using ptrace directly.
(getchildprocptrace): removed
(waitloop): removed
(startgdb): new function. start a new gdb session.
(getgdboutput): new helper function for getting gdb output.
(dataevaluate): new helper function for getting value for a given expression
(commonbreakpointhandler): new function which handles SIGTRAPs and gdb breakpoint hits.
(controlloop) : new function handle communication with gdb
(main): removed old code. added calls to startgdb and controlloop

src/native/jvmti/dbg.c removed

src/threads/native/threads.h: removed threads_set_current_threadobject. added jvmti_get_threads_breakpoints

src/threads/native/threads.c: (threads_startup_thread) add thread start/end asm lables
(threads_set_current_threadobject): removed jvmti thread start support.
(jvmti_get_threads_breakpoints) new function that gets addresses of asm lables.

src/threads/native/lock.h: added definition of lock_global_pool_lock and lock_global_pool

17 files changed:
src/cacao/cacao.c
src/native/jni.c
src/native/jvmti/Makefile.am
src/native/jvmti/VMjdwp.c
src/native/jvmti/cacaodbg.c
src/native/jvmti/cacaodbg.h
src/native/jvmti/cacaodbgserver.c
src/native/jvmti/cacaodbgserver.h
src/native/jvmti/dbg.c [deleted file]
src/native/jvmti/dbg.h
src/native/jvmti/jvmti.c
src/native/jvmti/jvmti.h
src/native/vm/VMVirtualMachine.c
src/threads/native/lock.h
src/threads/native/threads.c
src/threads/native/threads.h
src/vm/vm.c

index bf021ad1657660cf11a5ae653f1952a9d01d4ceb..57a51f63545de682b8dba8c2b35bf7bd025549b4 100644 (file)
@@ -31,7 +31,7 @@
             Philipp Tomsich
             Christian Thalinger
 
-   $Id: cacao.c 4921 2006-05-15 14:24:36Z twisti $
+   $Id: cacao.c 4944 2006-05-23 15:31:19Z motse $
 
 */
 
@@ -181,6 +181,7 @@ static char *getmainclassnamefromjar(char *mainstring)
 void exit_handler(void);
 
 
+
 /* main ************************************************************************
 
    The main program.
@@ -216,7 +217,7 @@ int main(int argc, char **argv)
 
 #if defined(ENABLE_JVMTI)
        pthread_mutex_init(&dbgcomlock,NULL);
-       set_jvmti_phase(JVMTI_PHASE_START);
+       jvmti_set_phase(JVMTI_PHASE_START);
 #endif
 
        /* do we have a main class? */
@@ -307,10 +308,10 @@ int main(int argc, char **argv)
                /*class_showmethods(currentThread->group->header.vftbl->class); */
 
 #if defined(ENABLE_JVMTI)
-               /* start the jdwp listening */
+               /* start the jdwp listening thread*/
                if (jdwp) {
                        log_text("cacao vm - init VMjdwp");
-                       if (!VMjdwpInit()) exit(1);
+                       if (!jvmti_VMjdwpInit()) exit(1);
                        setup_jdwp_thread(transport);
                        if (!suspend) {
                                fprintf(stderr,"suspend false -> continue debuggee\n");
@@ -320,9 +321,7 @@ int main(int argc, char **argv)
                        }
                }
 
-               set_jvmti_phase(JVMTI_PHASE_LIVE);
-
-               log_text("debuggee: herewe go");
+               jvmti_set_phase(JVMTI_PHASE_LIVE);
 #endif
 
                (void) vm_call_method(m, NULL, oa);
index 17bf3d0ef865bb264273326e494879e59e8ee21c..cdc19b6c42720b83d34888d798114fd8fcb43842 100644 (file)
@@ -32,7 +32,7 @@
             Christian Thalinger
                        Edwin Steiner
 
-   $Id: jni.c 4921 2006-05-15 14:24:36Z twisti $
+   $Id: jni.c 4944 2006-05-23 15:31:19Z motse $
 
 */
 
@@ -5447,8 +5447,10 @@ jint GetEnv(JavaVM *vm, void **env, jint version)
        }
 
 #if defined(ENABLE_JVMTI)
-       if (version == JVMTI_VERSION_1_0) {
-               *env = (void *) new_jvmtienv();
+       if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE) 
+               == JVMTI_VERSION_INTERFACE_JVMTI) {
+
+               *env = (void *) jvmti_new_environment();
 
                if (env != NULL)
                        return JNI_OK;
index c78b6adf0e70b952fe1edc6f095f417833e829ea..114a1f438e06ca3017ccb784e9e6c0948982f3f5 100644 (file)
@@ -28,7 +28,7 @@
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4892 2006-05-06 18:29:55Z motse $
+## $Id: Makefile.am 4944 2006-05-23 15:31:19Z motse $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -42,14 +42,17 @@ libjvmti_la_SOURCES = \
        VMjdwp.c \
        VMjdwp.h \
        dbg.h\
-        dbg.c\
         cacaodbg.h \
         cacaodbg.c
+bin_PROGRAMS = \
+       cacaodbgserver
 
+cacaodbgserver_SOURCES = \
+       cacaodbgserver.c \
+       cacaodbgserver.h
 
-## seperate cacaodbgserver executable
-##     cacaodbgserver.c \
-##     cacaodbgserver.h \
+cacaodbgserver_LDADD = \
+       libjvmti.la
 
 ## Local variables:
 ## mode: Makefile
index e96be458b35bc1d724447400e4a716382348c703..b4b013394087b751cbf790422f39e253d34b8644 100644 (file)
@@ -29,7 +29,7 @@
    Changes:             
 
 
-   $Id: VMjdwp.c 4892 2006-05-06 18:29:55Z motse $
+   $Id: VMjdwp.c 4944 2006-05-23 15:31:19Z motse $
 
 */
 
@@ -353,13 +353,13 @@ static void GarbageCollectionFinish (jvmtiEnv *jvmti_env){
 
 
 /* it would be more apropriate to call this function from gnu-cp jdwp */
-bool VMjdwpInit() {
+bool jvmti_VMjdwpInit() {
        int end, i=0;
        jvmtiCapabilities cap;
        jvmtiError e;
 
        log_text("cacao vm - create new jvmti environment");
-       jvmtienv = new_jvmtienv();
+       jvmtienv = jvmti_new_environment();
 
        /* set eventcallbacks */
        if (JVMTI_ERROR_NONE != 
index bfeee43b53a905ede73cb9896860e0f60d879dde..96dae2473d63b75589d5b94537b3620561c2da55 100644 (file)
@@ -36,7 +36,6 @@
 
 #include "native/jvmti/jvmti.h"
 #include "native/jvmti/cacaodbg.h"
-#include "native/jvmti/cacaodbgserver.h"
 #include "native/jvmti/dbg.h"
 #include "vm/vm.h"
 #include "vm/loader.h"
 #include <signal.h>
 #include <stdlib.h>
 #include <assert.h>
+#include <sys/wait.h>
 
 
-/* allthreads *****************************************************************
+/* jvmti_get_all_threads ******************************************************
 
    Gets an array of threadobjects of all threads
 
 *******************************************************************************/
-jvmtiError allthreads (jint * threads_count_ptr, threadobject*** threads_ptr) {
+jvmtiError jvmti_get_all_threads (jint * threads_count_ptr, 
+                                                                 threadobject*** threads_ptr) {
     int i = 0, cnt = 8; 
     threadobject *thread, **tthreads;
        
@@ -79,7 +80,7 @@ jvmtiError allthreads (jint * threads_count_ptr, threadobject*** threads_ptr) {
                   tthreads[i] = thread;
                   i++;
                }
-               thread = thread->info.prev;
+               thread = thread->prev;
 
                /* repeat until we got the pointer to the mainthread twice */
        } while (mainthreadobj != thread);
@@ -96,24 +97,24 @@ jvmtiError allthreads (jint * threads_count_ptr, threadobject*** threads_ptr) {
 }
 
 
-/* getcurrentthread ***********************************************************
+/* jvmti_get_current_thread ***************************************************
 
    Get jthread structure of current thread. 
 
 *******************************************************************************/
-jthread getcurrentthread() {
+jthread jvmti_get_current_thread() {
        return (jthread)(threads_get_current_threadobject())->o.thread;
 }
 
 
 
-/* brktablecreator*************************************************************
+/*  breakpointtable_creator ***************************************************
 
    helper function to enlarge the breakpoint table if needed
 
 *******************************************************************************/
 
-static void brktablecreator() {
+static void breakpointtable_creator() {
        struct _brkpt* tmp;
        struct brkpts *jvmtibrkpt;
 
@@ -134,54 +135,69 @@ static void brktablecreator() {
 }
 
 
-/* setsysbrkpt ****************************************************************
+/* jvmti_set_system_breakpoint ************************************************
 
    sets a system breakpoint in breakpoint table and calls set breakpoint
 
 *******************************************************************************/
 
-void setsysbrkpt(int sysbrk, void* addr) {     
+void jvmti_set_system_breakpoint(int sysbrk, bool mode) {      
        struct brkpts *jvmtibrkpt;
 
        pthread_mutex_lock(&dbgcomlock);
-       jvmtibrkpt = &dbgcom->jvmtibrkpt;;
+       jvmtibrkpt = &dbgcom->jvmtibrkpt;
 
+       assert (sysbrk < BEGINUSERBRK); 
        if (jvmtibrkpt->size == jvmtibrkpt->num)
-               brktablecreator();
-
-       assert (sysbrk < BEGINUSERBRK);
-       jvmtibrkpt->brk[sysbrk].addr = addr;
-
-
-       dbgcom->setbrkpt = true;
-       dbgcom->brkaddr = addr;
-       jvmtibrkpt->brk[sysbrk].orig = dbgcom->brkorig;
+               breakpointtable_creator();
+
+       if (mode) {
+               /* add breakpoint*/
+               if (jvmtibrkpt->brk[sysbrk].count > 0) {
+                       jvmtibrkpt->brk[sysbrk].count++;
+                       pthread_mutex_unlock(&dbgcomlock);
+                       return;
+               }
+               dbgcom->addbrkpt = true;
+               dbgcom->brkaddr = jvmtibrkpt->brk[sysbrk].addr;
+       } else {
+               /* remove breakpoint*/          
+               if ((jvmtibrkpt->brk[sysbrk].count == 1) ) {
+                       jvmtibrkpt->brk[sysbrk].count--;
+                       /* remove breakpoint */
+                       dbgcom->addbrkpt = false;
+                       dbgcom->brkaddr = jvmtibrkpt->brk[sysbrk].addr;
+               } else {
+                       /* avoid negative counter values */
+                       if (jvmtibrkpt->brk[sysbrk].count > 0) jvmtibrkpt->brk[sysbrk].count--;
+                       pthread_mutex_unlock(&dbgcomlock);
+                       return;
+               }
+       }
        pthread_mutex_unlock(&dbgcomlock);
-
        /* call cacaodbgserver */
+       __asm__ ("setsysbrkpt:");
        TRAP; 
-
-       fprintf (stderr,"setsysbrk %d %X  done\n",sysbrk, addr);
 }
 
 
-/* addbrkpt *******************************************************************
+/* jvmti_add_breakpoint *******************************************************
 
    adds a breakpoint to breakpoint table and calls set breakpoint
 
 *******************************************************************************/
 
-void addbrkpt(void* addr, jmethodID method, jlocation location) {
+void jvmti_add_breakpoint(void* addr, jmethodID method, jlocation location) {
        struct brkpts *jvmtibrkpt;
 
        pthread_mutex_lock(&dbgcomlock);
        jvmtibrkpt = &dbgcom->jvmtibrkpt;;
 
        if (jvmtibrkpt->size == jvmtibrkpt->num)
-               brktablecreator();
+               breakpointtable_creator();
 
        assert (jvmtibrkpt->size > jvmtibrkpt->num);
-       fprintf (stderr,"add brk add: %X\n",addr);
+       fprintf (stderr,"add brk add: %p\n",addr);
        jvmtibrkpt->brk[jvmtibrkpt->num].addr = addr;
        jvmtibrkpt->brk[jvmtibrkpt->num].method = method;
        jvmtibrkpt->brk[jvmtibrkpt->num].location = location;
@@ -256,50 +272,112 @@ void setup_jdwp_thread(char* transport) {
        vm_call_method(m,o);
 }
 
-/* cacaobreakpointhandler **********************************************************
 
-   handles breakpoints. called by cacaodbgserver.
+/* jvmti_cacaodbgserver_quit **************************************************
+
+   quits cacaodbgserver if the last jvmti environment gets disposed
 
 *******************************************************************************/
+void jvmti_cacaodbgserver_quit(){
+       pthread_mutex_lock(&dbgcomlock);
+       dbgcom->running--;
+       if (dbgcom->running  == 0) {
+               __asm__ ("cacaodbgserver_quit:");
+               TRAP;
+               /* get cacaodbserver exit */
+               wait(NULL);
+       }
+       dbgcom = NULL;
+       pthread_mutex_unlock(&dbgcomlock);
+}
 
-void cacaobreakpointhandler() {
-       basic_event ev;
-       genericEventData data;
-       int i;
-
-       /* XXX to be continued :-) */
-
-       fprintf(stderr,"breakpoint handler called\n");
-       log_text(" - signal %d", ev.signal);
-       switch (ev.signal) {
-       case SIGTRAP:
-               /* search the breakpoint that has been triggered */
-               i=0;
-               while ((ev.ip!=dbgcom->jvmtibrkpt.brk[i].addr) && (i<dbgcom->jvmtibrkpt.num)) i++;
-               
-               fprintf(stderr,"cacaodbglisten SIGTRAP switch after while loop i %d\n",i);
-               
-               switch (i) {
-               case SETTHREADOBJECTBRK:
-                       /* threads_set_current_threadobject */
-                       fprintf(stderr,"IP %X == threads_set_current_threadobject\n",ev.ip);
-                       data.ev=JVMTI_EVENT_THREAD_START;
-                       fireEvent(&data);
-                       break;
-               default:
-                       if ((i >= BEGINUSERBRK) && (i<dbgcom->jvmtibrkpt.num)) {
-                               log_text("todo: user defined breakpoints are not handled yet");
-                       } else 
-                               log_text("breakpoint not handled - continue anyway");
-               }
+
+
+/* jvmti_cacao_generic_breakpointhandler **************************************
+
+   convert cacao breakpoints in jvmti events and fire event
+
+*******************************************************************************/
+
+static void jvmti_cacao_generic_breakpointhandler(int kindofbrk){
+       genericEventData data; 
+
+       switch (kindofbrk) {
+       case THREADSTARTBRK:
+               data.ev=JVMTI_EVENT_THREAD_START; 
+               break;
+       case THREADENDBRK:
+               data.ev=JVMTI_EVENT_THREAD_END; 
+               break;
+       case CLASSLOADBRK:
+               data.ev=JVMTI_EVENT_CLASS_LOAD; 
+               break;
+       case CLASSPREPARERK:
+               data.ev=JVMTI_EVENT_CLASS_PREPARE; 
                break;
-       case SIGQUIT:
-               log_text("debugger process SIGQUIT");
-               data.ev=JVMTI_EVENT_VM_DEATH;
-               fireEvent(&data);               
+       case CLASSFILELOADHOOKBRK:
+               data.ev=JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; 
+               break;
+       case COMPILEDMETHODLOADBRK:
+               data.ev=JVMTI_EVENT_COMPILED_METHOD_LOAD; 
+               break;
+       case COMPILEDMETHODUNLOADBRK:
+               data.ev=JVMTI_EVENT_COMPILED_METHOD_UNLOAD; 
                break;
        default:
-               log_text("signal not handled");
+               fprintf(stderr,"unhandled kind of cacao break %d\n",kindofbrk);
+               return;
+       }
+       jvmti_fireEvent(&data);
+}
+
+
+
+/* jvmti_cacao_debug_init ***************************************************************
+
+   starts up a new cacaodbgserver process if needed
+
+*******************************************************************************/
+
+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;
+
+               breakpointtable_creator();
+               /* set addresses of hard coded TRAPs */
+               __asm__ ("movl $setsysbrkpt,%0;" 
+                        :"=m"(dbgcom->jvmtibrkpt.brk[SETSYSBRKPT].addr));
+               __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");
+                       exit(1);
+               } else {
+                       if (dbgserver == 0) {
+                               if (execlp("cacaodbgserver","cacaodbgserver",(char *) NULL) == -1) {
+                                       log_text("unable to execute cacaodbgserver");
+                                       exit(1);
+                               }
+                       }
+               }
+               pthread_mutex_unlock(&dbgcomlock);
+               /* let cacaodbgserver get ready */
+               sleep(1);
+       } else {
+               dbgcom->running++;
+               pthread_mutex_unlock(&dbgcomlock);
        }
 }
 
index 928fe7d905bef450672601c75b5800999cd1dfc4..0d97a7b5ad35c87ac96a397defc0161a9742b33e 100644 (file)
@@ -43,7 +43,6 @@
 
 
 
-
 typedef struct {
        jvmtiEvent ev;
        jvmtiEnv *jvmti_env;
@@ -73,11 +72,36 @@ typedef struct {
 } genericEventData;
 
 
+
+#if defined(ENABLE_THREADS)
+struct _jrawMonitorID {
+    java_lang_String *name;
+};
+
+
+#endif
+
+
+/* constants where system breakpoints are stored in the breakpoint table       */
+#define SETSYSBRKPT             0 /* used for setsysbrkpt calls                */
+#define CACAODBGSERVERQUIT      1 
+#define NOTHARDCODEDBRK         2 /* here is where the first not hard coded 
+                                                                    breakpoint is stored                      */
+#define THREADSTARTBRK          2 
+#define THREADENDBRK            3 
+#define CLASSLOADBRK            4
+#define CLASSPREPARERK          5
+#define CLASSFILELOADHOOKBRK    6
+#define COMPILEDMETHODLOADBRK   7
+#define COMPILEDMETHODUNLOADBRK 8
+#define BEGINUSERBRK            9 /* here is where the first user breakpoint  
+                                                                    is stored                                 */
+
 struct _brkpt {
     jmethodID method;
     jlocation location;
     void* addr; /* memory address          */
-    long orig;  /* original memory content */
+       int count;
 };
 
 
@@ -90,62 +114,38 @@ struct brkpts {
 
 typedef struct {
        int running;
-       void* breakpointhandler;
-       bool setbrkpt;
+       bool addbrkpt;
        void* brkaddr;
-       long brkorig;
        struct brkpts jvmtibrkpt;
 } cacaodbgcommunication;
 
 cacaodbgcommunication *dbgcom;
 
-#if defined(ENABLE_THREADS)
-struct _jrawMonitorID {
-    java_lang_String *name;
-};
-
-struct _threadmap {
-       pthread_t tid;
-       threadobject* cacaothreadobj;   
-};
-
-struct threadmap {
-       struct _threadmap* map;
-       int num;
-       int size;
-};
-
-struct threadmap thmap;
-#endif
-
 
-/* constants where system breakpoints are stored in the breakpoint table     */
-#define SETTHREADOBJECTBRK    0 /* used for EVENT_THREAD_START               */
-#define BEGINUSERBRK          1 /* here is where the first user breakpoint is 
-                                                                  stored                                    */
+bool jdwp;                  /* debugger via jdwp                               */
+bool jvmti;                 /* jvmti agent                                     */
 
-
-bool jdwp;                  /* debugger via jdwp                              */
-bool jvmti;                 /* jvmti agent                                    */
-
-char *transport, *agentarg; /* arguments for jdwp transport and agent load    */
-bool suspend;               /* should the virtual machine suspend on startup? */
+char *transport, *agentarg; /* arguments for jdwp transport and agent load     */
+bool suspend;               /* should the virtual machine suspend on startup?  */
 
 extern pthread_mutex_t dbgcomlock;
 
 void setup_jdwp_thread(char* transport);
-void cacaobreakpointhandler();
-jvmtiEnv* new_jvmtienv();
-void set_jvmti_phase(jvmtiPhase p);
-void fireEvent(genericEventData* data);
-bool VMjdwpInit();
-void agentload(char* opt_arg, bool agentbypath, lt_dlhandle  *handle, char **libname);
-void agentunload();
-void addbrkpt(void* addr, jmethodID method, jlocation location);
-void setsysbrkpt(int sysbrk, void* addr);
-jvmtiError allthreads (jint * threads_count_ptr, threadobject *** threads_ptr);
-jthread getcurrentthread();
-
+void jvmti_cacao_breakpointhandler();
+bool jvmti_VMjdwpInit();
+jvmtiEnv* jvmti_new_environment();
+void jvmti_set_phase(jvmtiPhase p);
+void jvmti_fireEvent(genericEventData* data);
+void jvmti_agentload(char* opt_arg, bool agentbypath, 
+                                        lt_dlhandle  *handle, char **libname);
+void jvmti_agentunload();
+void jvmti_add_breakpoint(void* addr, jmethodID method, jlocation location);
+void jvmti_set_system_breakpoint(int sysbrk, bool mode);
+jvmtiError jvmti_get_all_threads (jint * threads_count_ptr, 
+                                                                 threadobject *** threads_ptr);
+jthread jvmti_get_current_thread();
+void jvmti_cacao_debug_init();
+void jvmti_cacaodbgserver_quit();
 #endif
 
 /*
index 51a520bc49c5f88f6c6ead919d972fc814e97b0e..fd5dd1f829e65d8419c44c38e0765f9b9813343a 100644 (file)
@@ -1,5 +1,5 @@
 /* src/native/jvmti/cacaodbgserver.c - contains the cacaodbgserver process. This
-                                       process controls the debuggee/cacao vm.
+                                       process controls the cacao vm through gdb
 
    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
@@ -30,7 +30,7 @@
    Changes: Edwin Steiner
             Samuel Vinson
 
-   $Id: cacao.c,v 3.165 2006/01/03 23:44:38 twisti Exp $
+   $Id$
 
 */
 
 #include <sys/wait.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <assert.h>
+#include <string.h>
 
-pid_t debuggee;
+FILE *gdbin, *gdbout; /* file descriptor for gdb pipes */
 
-/* getchildprocptrace *********************************************************
+struct _pending_brkpt {
+       int brknumber;
+       unsigned long threadid;
+       char* regs;
+};
 
-   Get data count number of bytes from address addr for child process address 
-   space. Requested  data is stored in the array pointed to by ptr.
+struct _pending_brkpt *pending_brkpts;
+int pending_brkpts_size;
 
-*******************************************************************************/
-static void getchildprocptrace (char *ptr, void* addr, int cnt) {
-       long i, longcnt;
-       long *p = (long*) ptr;
-       
-       longcnt = cnt/sizeof(long);
-       for (i=0; i<longcnt; i++) {
-               p[i]=GETMEM(debuggee,addr);
-               if (p[i]==-1)
-               {
-                       fprintf(stderr,"cacaodbgserver process: getchildprocptrace: %ld\n",i);
-                       perror("cacaodbgserver process: getchildprocptrace:");
-                       exit(1);
-               }
-               addr+=sizeof(long);
+
+static void closepipeend (int fd) {
+       if (close(fd) == -1) {
+               perror("unable to close pipe - ");
+               exit(1);
        }
-       i = GETMEM(debuggee,addr);
-       memcpy(p+longcnt,&i,cnt%sizeof(long));
 }
 
+/* startgdb *******************************************************************
 
-/* waitloop *******************************************************************
-
-   waits and handles signals from debuggee/child process. Returns true if 
-   cacaodbgserver should exit.
+   starts a gdb session and creates two pipes connection gdb stdout/stdin to
+   gdbin/gdbout
 
 *******************************************************************************/
 
-static bool waitloop(void* dbgcvm) {
-    int status,retval,signal;
-    void* ip;
-       basic_event ev;
-       cacaodbgcommunication vm;
-       long data;
-       struct _brkpt* brk;
+static void startgdb() {
+       char gdbargs[20];
+       int cacao2gdbpipe[2],gdb2cacaopipe[2];
 
-       fprintf(stderr,"waitloop\n");
+       pipe(cacao2gdbpipe);
+       pipe(gdb2cacaopipe);
 
-       retval = wait(&status);
+       snprintf(gdbargs,20,"--pid=%d",getppid());              
 
-       fprintf(stderr,"cacaodbgserver: waitloop we got something to do\n");
-       if (retval == -1) {
-               fprintf(stderr,"error in waitloop\n");
-               perror("cacaodbgserver process: waitloop: ");
-               return true;
-       }
-       
-       if (retval != debuggee) {
-               fprintf(stderr,"cacaodbgserver got signal from process other then debuggee/cacao vm\n");
-               return false;
-       }
-       
-       if (WIFSTOPPED(status)) {
-               signal = WSTOPSIG(status);
-               
-               /* ignore SIGSEGV, SIGPWR, SIGBUS and SIGXCPU for now.
-                  todo: in future this signals could be used to detect Garbage 
-                  Collection Start/Finish or NullPointerException Events */
-               if ((signal == SIGSEGV) || (signal == SIGPWR) || 
-                       (signal == SIGBUS)      || (signal == SIGXCPU)) {
-                       fprintf(stderr,"cacaodbgserver: ignore internal signal (%d)\n",signal);
-                       CONT(debuggee,signal);
-                       return false;
-               }
-               
-               if (signal == SIGABRT) {
-                       fprintf(stderr,"cacaodbgserver: got SIGABRT from debugee - exit\n");
-                       return true;
-               }
-               
-               ip = getip(debuggee);
-               ip--; /* EIP has already been incremented */
-               fprintf(stderr,"got signal: %d IP %X\n",signal,ip);
-               
-                       
-               ev.signal = signal;
-               ev.ip = ip;
-               
-               /* handle breakpoint */
-               getchildprocptrace((char*)&vm,dbgcvm,sizeof(cacaodbgcommunication));
+       switch(fork()) {
+       case -1:
+               fprintf(stderr,"cacaodbgserver: fork error\n");
+               exit(1);
+       case 0:         
+               /* child */
+               closepipeend(gdb2cacaopipe[0]); /* read end */
+               closepipeend(cacao2gdbpipe[1]); /* write end */
                
-               if (vm.setbrkpt) {
-                       /* set a breakpoint */
-                       setbrk(debuggee, vm.brkaddr, &vm.brkorig);
-                       CONT(debuggee,0);
-                       return false;
-               }
+               /* connect stdin of gdb to cacao2gdbpipe */
+               dup2(cacao2gdbpipe[0],0);
+               /* connect stdout of gdb to gdb2cacaopipe */
+               dup2(gdb2cacaopipe[1],1);
 
-               if (signal == SIGTRAP) {
-                       /* Breakpoint hit. Place original instruction and notify cacao vm to
-                          handle it */
-                       fprintf(stderr,"breakpoint hit\n");
+               if (execlp("gdb","gdb","--interpreter=mi" ,gdbargs,(char *) NULL)==-1){
+                       fprintf(stderr,"cacaodbgserver: unable to start gdb\n");
+                       exit(1);
                }
+       default:
+               /* parent */
+               closepipeend(gdb2cacaopipe[1]); /* write end */
+               closepipeend(cacao2gdbpipe[0]); /* read end */
 
-               return false;
+               gdbin = fdopen(gdb2cacaopipe[0],"r");
+               gdbout = fdopen(cacao2gdbpipe[1],"w");
        }
-       
-       if (WIFEXITED(status)) {
-               fprintf(stderr,"cacaodbgserver: debuggee/cacao vm exited.\n");
-               return true;
+
+}
+
+
+#define SENDCMD(CMD) \
+       fprintf(gdbout,"%s",CMD); \
+       fflush(gdbout); \
+
+
+static void getgdboutput(char *inbuf,int buflen) {
+       int i=0;
+       inbuf[0]='\0';
+       do {
+               i += strlen(&inbuf[i]);
+               if (fgets(&inbuf[i],buflen-i,gdbin)==NULL) {
+                       perror("cacaodbgserver: ");
+                       exit(1);
+               }
+       } while(!(strncmp(OUTPUTEND,&inbuf[i],OUTPUTENDSIZE)==0));
+}
+
+
+/* dataevaluate ***************************************************************
+
+   evaluates expr returning long in gdb and returns the result 
+
+*******************************************************************************/
+
+static unsigned long dataevaluate(char *expr) {
+       char *match, inbuf[160];
+
+       fprintf(gdbout,"-data-evaluate-expression %s\n",expr); 
+       fflush(gdbout); 
+
+       getgdboutput(inbuf,160);
+       if ((match=strstr(inbuf,DATAEVALUATE))==NULL) {
+               fprintf(stderr,"dataevaluate: no matching value\n");
+               return -1;
        }
-       
-       if (WIFSIGNALED(status)) {
-               fprintf(stderr,"cacaodbgserver: child terminated by signal %d\n",WTERMSIG(status));
+       return strtoll(&match[strlen(DATAEVALUATE)],NULL,16);
+}
+
+
+/* commonbreakpointhandler *****************************************************
+
+   called by gdb and hard coded breakpoint handler
+
+*******************************************************************************/
+
+static bool commonbreakpointhandler(char* sigbuf, int sigtrap) {
+       int numberofbreakpoints, i;
+       char tmp[INBUFLEN], *match;
+       unsigned long addr;
+
+       if ((match=strstr(sigbuf,SIGADDR))==NULL) {
+               fprintf(stderr,"commonbreakpointhandler: no matching address(%s)\n",
+                               sigbuf);
                return true;
        }
-       
-       if (WIFCONTINUED(status)) {
-               fprintf(stderr,"cacaodbgserver: continued\n");
+
+       addr = strtoll(&match[strlen(SIGADDR)],NULL,16);
+       if (sigtrap) addr--;
+
+
+       numberofbreakpoints = (int)dataevaluate("dbgcom->jvmtibrkpt.num");
+
+       i = -1;
+       do {
+               i++; 
+               snprintf(tmp,INBUFLEN,"dbgcom->jvmtibrkpt.brk[%d].addr",i);
+       } while ((i<numberofbreakpoints) && (dataevaluate(tmp) != addr));
+
+       assert(i<numberofbreakpoints);
+
+       /* handle system breakpoints */
+       switch(i) {
+       case SETSYSBRKPT:
+               /* add a breakpoint */
+               fprintf(gdbout,"break *0x%lx\n",dataevaluate("dbgcom->brkaddr"));
+               fflush(gdbout);
+               getgdboutput(tmp,INBUFLEN);
+               break;
+       case CACAODBGSERVERQUIT:
+               SENDCMD("-gdb-exit\n");
                return false;
+       default:
+               /* other breakpoints -> call jvmti_cacao_generic_breakpointhandler 
+                  in the cacao vm */
+               fprintf(gdbout,"call jvmti_cacao_generic_breakpointhandler(%d)\n",i);
+               fflush(gdbout);
+               getgdboutput(tmp,INBUFLEN);             
        }
-       
-       
-       fprintf(stderr,"wait not handled(child not exited or stopped)\n");
-       fprintf(stderr,"retval: %d status: %d\n",retval,status);
-       CONT(debuggee,0);               
-       return false;
+       SENDCMD(CONTINUE);
+       getgdboutput(tmp,INBUFLEN);
+       return true;
 }
 
-/* main (cacaodbgserver) ******************************************************
+/* controlloop ****************************************************************
 
-   main function for cacaodbgserver process.
+   this function controls the gdb behaviour
 
 *******************************************************************************/
 
-int main(int argc, char **argv) {
+static void controlloop() {
+       char inbuf[INBUFLEN], *match;
        bool running = true;
-       void *dbgcvm;
-       int status;
-       
-       if (argc != 2) {
-               fprintf(stderr,"cacaodbgserver: not enough arguments\n");
-               fprintf(stderr, "cacaodbgserver cacaodbgcommunicationaddress\n");
-
-               fprintf(stderr,"argc %d argv[0] %s\n",argc,argv[0]);
-               exit(1);
-       }
-
-       dbgcvm=(cacaodbgcommunication*)strtol(argv[1],NULL,16);
 
-       fprintf(stderr,"cacaodbgserver started pid %d ppid %d\n",getpid(), getppid());
+       pending_brkpts_size = 5;
+       pending_brkpts = malloc(sizeof(struct _pending_brkpt)*pending_brkpts_size);
 
-       debuggee = getppid();
+       getgdboutput(inbuf,INBUFLEN);   /* read gdb welcome message */
 
-       if (TRACEATTACH(debuggee) == -1) perror("cacaodbgserver: ");
+       SENDCMD("handle SIGSEGV SIGPWR SIGXCPU SIGBUS noprint nostop\n");
+       getgdboutput(inbuf,INBUFLEN);
 
-       fprintf(stderr,"cacaovm attached\n");
+       SENDCMD("print dbgcom\n");
+       getgdboutput(inbuf,INBUFLEN);
 
-       if (wait(&status) == -1) {
-               fprintf(stderr,"error initial wait\n");
-               perror("cacaodbgserver: ");
-               exit(1);
-       }
+       SENDCMD(CONTINUE);
+       getgdboutput(inbuf,INBUFLEN);
 
-       if (WIFSTOPPED(status)) 
-               if (WSTOPSIG(status) == SIGSTOP)
-                       CONT(debuggee,0);
-       
        while(running) {
-               running = !waitloop(dbgcvm);
+               getgdboutput(inbuf,INBUFLEN);
+
+               if ((match=strstr(inbuf,HCSIGTRAP))!=NULL) {
+                       running = commonbreakpointhandler(match,1);
+                       continue;
+                       }
+
+               if ((match=strstr(inbuf,GDBBREAKPOINT))!=NULL) {
+                       running = commonbreakpointhandler(match,0);
+                       continue;
+               }
+
+               if (strstr(inbuf,EXITEDNORMALLY) != NULL) {
+                       /* quit gdb */
+                       SENDCMD ("-gdb-exit");
+                       running = false;
+                       continue;
+               }
+                       
+               if ((inbuf[0]!=LOGSTREAMOUTPUT) && (inbuf[0]!=CONSOLESTREAMOUTPUT))
+                       fprintf(stderr,"gdbin not handled %s\n",inbuf);
        }
-       fprintf(stderr,"cacaodbgserver exit\n");
+
+       free(pending_brkpts);
+}
+
+/* main (cacaodbgserver) ******************************************************
+
+   main function for cacaodbgserver process.
+
+*******************************************************************************/
+
+int main(int argc, char **argv) {
+       startgdb();
+
+       controlloop();
+
+       return 0;
 }
 
 
index dd39fc7dac5ff5eb3744d9fc35c9a81673d77b18..b496bd44ee383d8d5ed75e8278b94833db2cbc5e 100644 (file)
 #ifndef _CACAODBGSERVER_H
 #define _CACAODBGSERVER_H
 
-#include "vm/global.h"
-#include <semaphore.h>
-
-/* supported message types */
-#define MSGQCACAODBGSRV  1  /* messages for cacaodbgserver process  */
-#define MSGQDEBUGGER     2  /* messages for debugger process        */
-#define MSGQPTRACESND    3  /* messages for ptrace request          */
-#define MSGQPTRACERCV    4  /* messages for ptrace return value     */
-
-/* supported ptrace loop calls */
-#define PTCONT           1  /* ptrace continue                      */
-#define PTPEEKDATA       2  /* ptrace peek data                     */
-#define PTSETBRK         3  /* set breakpiont                       */
-#define PTDELBRK         4  /* delete breakpiont                    */
-#define PTGETREG         5  /* get registers                        */
-
-
-typedef struct {
-       long mtype;
-       int kind; 
-       void* addr;
-       int data;
-       long ldata;
-} ptrace_request;
-
-typedef struct {
-       long mtype;
-       bool successful;
-       int  datasize;
-       char data[1];
-} ptrace_reply;
-
-
-typedef struct {
-       long mtype;
-       int signal; 
-       void *ip;
-} basic_event;
-
-typedef struct {
-       bool running;           /* true if debuggee process is running             */
-       int hastostop;          /* if greater then zero the debugger needs the 
-                                                          debuggee to be stopped                          */
-} cacaodbgserver_data;
-
-
-int  msgqid;                    /* message queue for the communication between 
-                                                              debugger/jdwp and cacaodbgserver process    */
-int shmid;                      /* shared memory for saving running state      */
-sem_t workingdata_lock;         /* semaphore for cacaodbgserver_data shared  
-                                                              memory structure                            */
-cacaodbgserver_data *cdbgshmem; /* cacaodbgserver shared memory pointer        */
-
-
-
-void cacaodbgserver();          /* entry point function to cacaodbgserver proc */
+#define INBUFLEN 8192
+
+#define CONTINUE      "-exec-continue\n"
+
+#define HCSIGTRAP "*stopped,reason=\"signal-received\",signal-name=\"SIGTRAP\"" 
+#define GDBBREAKPOINT       "*stopped,reason=\"breakpoint-hit\""
+#define EXITEDNORMALLY      "*stopped,reason=\"exited-normally\""
+#define REGNAMES            "^done,register-names=["
+#define CURRENTTHREAD       "~\"*"
+#define SIGADDR             "frame={addr=\""
+#define DATAEVALUATE        "value=\""
+#define LOGSTREAMOUTPUT     '&'
+#define CONSOLESTREAMOUTPUT '~'
+#define OUTPUTEND           "(gdb)"
+#define OUTPUTENDSIZE       5
+
 
 #endif
 
diff --git a/src/native/jvmti/dbg.c b/src/native/jvmti/dbg.c
deleted file mode 100644 (file)
index 7af016d..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* src/native/jvmti/dbg.c - jvmti os/architecture support
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Martin Platter
-
-   Changes: 
-
-
-   $Id: cacao.c,v 3.165 2006/01/03 23:44:38 twisti Exp $
-
-*/
-
-/* at the moment linux/i386 is the only plattform available */
-#if defined(__LINUX__)  && defined (__I386__)
-
-#include "dbg.h"
-#include <sys/ptrace.h>
-#include <linux/user.h>
-
-#include <stdio.h>
-
-void* getip(pid_t pid) {
-    struct user_regs_struct regs;
-
-    GETREGS(pid,regs);
-    return (void*)regs.eip;
-}
-
-void setip(pid_t pid, void* ip) {
-    struct user_regs_struct regs;
-
-    GETREGS(pid,regs);
-    regs.eip=(long)ip; 
-    ptrace(PTRACE_SETREGS, pid, 0, &regs); 
-}
-
-void setbrk(pid_t pid, void* addr, long* orig) {
-    long ins;
-
-       *orig = GETMEM(pid,addr);
-
-       ins = (*orig & ~0x000000FF) | TRAPINS; 
-
-       fprintf (stderr,"pid %d set brk at %p orig: %X new: %X\n",pid,addr,*orig,ins);
-       if (ptrace(PTRACE_POKEDATA, pid, (caddr_t) addr, ins)==-1) 
-               perror("setbrk error ");
-}
-
-#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
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
index 52f63f295b29fa405a12ad5030c28a87a5d7c4f3..05c0762a45deea16e51bd603993df3d73fad296a 100644 (file)
@@ -29,7 +29,7 @@
    Changes:             
 
    
-   $Id: dbg.h 4892 2006-05-06 18:29:55Z motse $
+   $Id: dbg.h 4944 2006-05-23 15:31:19Z motse $
 
 */
 
 #ifndef _DBG_H
 #define _DBG_H
 
-#include <sys/types.h>
-#include <sys/ptrace.h>
-
-#define TRACEATTACH(pid) ptrace(PTRACE_ATTACH, pid, 0, 0)
-#define DETACH(pid,sig)  ptrace(PTRACE_DETACH, pid, 0, sig)
 #define TRAPINS 0xcc /* opcode for brk */
-#define TRAP asm("int3")
-#define GETMEM(pid, addr) ptrace(PTRACE_PEEKDATA, pid, addr, 0)
-#define CONT(pid,sig) if(ptrace(PTRACE_CONT, pid, 0, sig)==-1) \
-                         perror("continue failed: ");
-#define DISABLEBRK(pid,ins,addr) ptrace(PTRACE_POKEDATA, pid, (caddr_t) addr, ins)
-#define GETREGS(pid,regs) ptrace(PTRACE_GETREGS, pid, 0, &regs)
-
-void* getip(pid_t pid);
-void setip(pid_t pid, void* ip);
-
-void setbrk(pid_t pid, void* addr,long* orig);
+#define TRAP __asm__("int3") 
 
 #endif
 #endif
index eb01fdf9fa90cb4f5a9e642cdde6f4a9b890c81c..97552b381dce3ec3e8888f0604f94d7908aa5faa 100644 (file)
@@ -31,7 +31,7 @@
             Samuel Vinson
 
    
-   $Id: jvmti.c 4926 2006-05-15 21:32:09Z edwin $
+   $Id: jvmti.c 4944 2006-05-23 15:31:19Z motse $
 
 */
 
@@ -53,6 +53,7 @@
 #include "vm/stringlocal.h"
 #include "mm/memory.h"
 #include "threads/native/threads.h"
+#include "threads/native/lock.h"
 #include "vm/exceptions.h"
 #include "native/include/java_util_Vector.h"
 #include "native/include/java_io_PrintStream.h"
@@ -81,7 +82,6 @@
 #include <pthread.h>
 #endif 
 
-#include "native/jvmti/stacktrace.h"
 #include "dbg.h"
 
 
@@ -122,7 +122,7 @@ static struct jvmtiEnv_struct JVMTI_EnvTable;
 static jvmtiCapabilities JVMTI_Capabilities;
 static lt_ptr unload;
 
-#define CHECK_PHASE_START  if (!(0 
+#define CHECK_PHASE_START  if (!(false 
 #define CHECK_PHASE(chkphase) || (phase == chkphase)
 #define CHECK_PHASE_END  )) return JVMTI_ERROR_WRONG_PHASE
 #define CHECK_CAPABILITY(env,CAP) if(((environment*)env)->capabilities.CAP == 0) \
@@ -152,20 +152,25 @@ static jvmtiError check_thread_is_alive(jthread t) {
    in the data structure.
 
 *******************************************************************************/
-static void execcallback(jvmtiEvent e, functionptr ec, genericEventData* data) {
+static void execute_callback(jvmtiEvent e, functionptr ec, 
+                                                        genericEventData* data) {
        JNIEnv* jni_env = (JNIEnv*)_Jv_env;
 
        fprintf(stderr,"execcallback called (event: %d)\n",e);
 
        switch (e) {
        case JVMTI_EVENT_VM_INIT:
+               if (phase != JVMTI_PHASE_LIVE) return;
     case JVMTI_EVENT_THREAD_START:
     case JVMTI_EVENT_THREAD_END: 
-               ((jvmtiEventThreadStart)ec) (data->jvmti_env, jni_env, data->thread);
+               if ((phase == JVMTI_PHASE_START) || (phase == JVMTI_PHASE_LIVE))
+                       ((jvmtiEventThreadStart)ec)(data->jvmti_env,jni_env,data->thread);
                break;
 
-
     case JVMTI_EVENT_CLASS_FILE_LOAD_HOOK:
+               if ((phase == JVMTI_PHASE_START) || 
+                       (phase == JVMTI_PHASE_LIVE)  ||
+                       (phase == JVMTI_PHASE_PRIMORDIAL))
                ((jvmtiEventClassFileLoadHook)ec) (data->jvmti_env, 
                                                                                   jni_env, 
                                                                                   data->klass,
@@ -181,158 +186,175 @@ static void execcallback(jvmtiEvent e, functionptr ec, genericEventData* data) {
 
     case JVMTI_EVENT_CLASS_PREPARE: 
     case JVMTI_EVENT_CLASS_LOAD:
-               ((jvmtiEventClassLoad)ec) (data->jvmti_env, jni_env, 
-                                                                  data->thread, data->klass);
+               if ((phase == JVMTI_PHASE_START) || (phase == JVMTI_PHASE_LIVE))
+                       ((jvmtiEventClassLoad)ec) (data->jvmti_env, jni_env, 
+                                                                          data->thread, data->klass);
                break;
 
     case JVMTI_EVENT_VM_DEATH:
+               if (phase != JVMTI_PHASE_LIVE) return;
     case JVMTI_EVENT_VM_START: 
+               if ((phase == JVMTI_PHASE_START) || (phase == JVMTI_PHASE_LIVE))
                ((jvmtiEventVMStart)ec) (data->jvmti_env, jni_env);
                break;
 
-    case JVMTI_EVENT_EXCEPTION:
-               ((jvmtiEventException)ec) (data->jvmti_env, jni_env, 
-                                                                  data->thread, 
-                                                                  data->method, 
-                                                                  data->location,
-                                                                  data->object,
-                                                                  data->catch_method,
-                                                                  data->catch_location);
-               break;
-               
-    case JVMTI_EVENT_EXCEPTION_CATCH:
-               ((jvmtiEventExceptionCatch)ec) (data->jvmti_env, jni_env, 
-                                                                               data->thread, 
-                                                                               data->method, 
-                                                                               data->location,
-                                                                               data->object);
-               break;
-
-    case JVMTI_EVENT_BREAKPOINT:
-    case JVMTI_EVENT_SINGLE_STEP: 
-               ((jvmtiEventSingleStep)ec) (data->jvmti_env, jni_env, 
-                                                                       data->thread, 
-                                                                       data->method, 
-                                                                       data->location);
-               break;
-
-    case JVMTI_EVENT_FRAME_POP:
-               ((jvmtiEventFramePop)ec) (data->jvmti_env, jni_env, 
-                                                                 data->thread, 
-                                                                 data->method, 
-                                                                 data->b);
-               break;
-
-    case JVMTI_EVENT_FIELD_ACCESS: 
-               ((jvmtiEventFieldAccess)ec) (data->jvmti_env, jni_env, 
-                                                                        data->thread, 
-                                                                        data->method, 
-                                                                        data->location,
-                                                                        data->klass,
-                                                                        data->object,
-                                                                        data->field);
-               break;
-
-    case JVMTI_EVENT_FIELD_MODIFICATION:
-               ((jvmtiEventFieldModification)ec) (data->jvmti_env, jni_env, 
-                                                                                  data->thread, 
-                                                                                  data->method, 
-                                                                                  data->location,
-                                                                                  data->klass,
-                                                                                  data->object,
-                                                                                  data->field,
-                                                                                  data->signature_type,
-                                                                                  data->value);
-               break;
-
-    case JVMTI_EVENT_METHOD_ENTRY:
-               ((jvmtiEventMethodEntry)ec) (data->jvmti_env, jni_env, 
-                                                                        data->thread, 
-                                                                        data->method);
-               break;
-
-    case JVMTI_EVENT_METHOD_EXIT: 
-               ((jvmtiEventMethodExit)ec) (data->jvmti_env, jni_env, 
-                                                                       data->thread, 
-                                                                       data->method,
-                                                                       data->b,
-                                                                       data->value);
-               break;
-
     case JVMTI_EVENT_NATIVE_METHOD_BIND:
-               ((jvmtiEventNativeMethodBind)ec) (data->jvmti_env, jni_env, 
-                                                                                 data->thread, 
-                                                                                 data->method,
-                                                                                 data->address,
-                                                                                 data->new_address_ptr);
-               break;
-
-    case JVMTI_EVENT_COMPILED_METHOD_LOAD:
-               ((jvmtiEventCompiledMethodLoad)ec) (data->jvmti_env, 
-                                                                                       data->method,
-                                                                                       data->jint1,
-                                                                                       data->address,
-                                                                                       data->jint2,
-                                                                                       data->map,
-                                                                                       data->compile_info);
-               break;
-               
-    case JVMTI_EVENT_COMPILED_METHOD_UNLOAD:
-               ((jvmtiEventCompiledMethodUnload)ec) (data->jvmti_env,
+               if ((phase == JVMTI_PHASE_START) || 
+                       (phase == JVMTI_PHASE_LIVE)  ||
+                       (phase == JVMTI_PHASE_PRIMORDIAL))
+                       ((jvmtiEventNativeMethodBind)ec) (data->jvmti_env, jni_env, 
+                                                                                         data->thread, 
                                                                                          data->method,
-                                                                                         data->address);
+                                                                                         data->address,
+                                                                                         data->new_address_ptr);
                break;
+       
 
     case JVMTI_EVENT_DYNAMIC_CODE_GENERATED:
-               ((jvmtiEventDynamicCodeGenerated)ec) (data->jvmti_env,
-                                                                                         data->name,
-                                                                                         data->address,
-                                                                                         data->jint1);
+               if ((phase == JVMTI_PHASE_START) || 
+                       (phase == JVMTI_PHASE_LIVE)  ||
+                       (phase == JVMTI_PHASE_PRIMORDIAL))
+                       ((jvmtiEventDynamicCodeGenerated)ec) (data->jvmti_env,
+                                                                                                 data->name,
+                                                                                                 data->address,
+                                                                                                 data->jint1);
                break;
 
-    case JVMTI_EVENT_GARBAGE_COLLECTION_START:
-    case JVMTI_EVENT_GARBAGE_COLLECTION_FINISH:
-    case JVMTI_EVENT_DATA_DUMP_REQUEST: 
-               ((jvmtiEventDataDumpRequest)ec) (data->jvmti_env);
-               break;
 
-    case JVMTI_EVENT_MONITOR_WAIT:
-               ((jvmtiEventMonitorWait)ec) (data->jvmti_env, jni_env, 
-                                                                        data->thread, 
-                                                                        data->object,
-                                                                        data->jlong);
-               break;
 
-    case JVMTI_EVENT_MONITOR_WAITED:
-               ((jvmtiEventMonitorWaited)ec) (data->jvmti_env, jni_env, 
+       default:
+               if (phase != JVMTI_PHASE_LIVE) return;
+               switch (e) {
+               case JVMTI_EVENT_EXCEPTION:                     
+                       ((jvmtiEventException)ec) (data->jvmti_env, jni_env, 
                                                                           data->thread, 
+                                                                          data->method, 
+                                                                          data->location,
                                                                           data->object,
-                                                                          data->b);
-               break;
-
-
-    case JVMTI_EVENT_MONITOR_CONTENDED_ENTERED:
-    case JVMTI_EVENT_MONITOR_CONTENDED_ENTER:
-               ((jvmtiEventMonitorContendedEnter)ec) (data->jvmti_env, jni_env, 
+                                                                          data->catch_method,
+                                                                          data->catch_location);
+                       break;
+                       
+               case JVMTI_EVENT_EXCEPTION_CATCH:
+                       ((jvmtiEventExceptionCatch)ec) (data->jvmti_env, jni_env, 
+                                                                                       data->thread, 
+                                                                                       data->method, 
+                                                                                       data->location,
+                                                                                       data->object);
+                       break;
+
+               case JVMTI_EVENT_BREAKPOINT:
+               case JVMTI_EVENT_SINGLE_STEP:
+                       ((jvmtiEventSingleStep)ec) (data->jvmti_env, jni_env, 
+                                                                               data->thread, 
+                                                                               data->method, 
+                                                                               data->location);
+                       break;
+
+               case JVMTI_EVENT_FRAME_POP:
+                       ((jvmtiEventFramePop)ec) (data->jvmti_env, jni_env, 
+                                                                         data->thread, 
+                                                                         data->method, 
+                                                                         data->b);
+                       break;
+
+
+               case JVMTI_EVENT_FIELD_ACCESS: 
+                       ((jvmtiEventFieldAccess)ec) (data->jvmti_env, jni_env, 
+                                                                                data->thread, 
+                                                                                data->method, 
+                                                                                data->location,
+                                                                                data->klass,
+                                                                                data->object,
+                                                                                data->field);
+                       break;
+
+               case JVMTI_EVENT_FIELD_MODIFICATION:
+
+                       ((jvmtiEventFieldModification)ec) (data->jvmti_env, jni_env, 
                                                                                           data->thread, 
-                                                                                          data->object);
-               break;
+                                                                                          data->method, 
+                                                                                          data->location,
+                                                                                          data->klass,
+                                                                                          data->object,
+                                                                                          data->field,
+                                                                                          data->signature_type,
+                                                                                          data->value);
+                       break;
+
+               case JVMTI_EVENT_METHOD_ENTRY:
+                       ((jvmtiEventMethodEntry)ec) (data->jvmti_env, jni_env, 
+                                                                                data->thread, 
+                                                                                data->method);
+                       break;
+
+               case JVMTI_EVENT_METHOD_EXIT: 
+                       ((jvmtiEventMethodExit)ec) (data->jvmti_env, jni_env, 
+                                                                               data->thread, 
+                                                                               data->method,
+                                                                               data->b,
+                                                                               data->value);
+                       break;
+
+               case JVMTI_EVENT_COMPILED_METHOD_LOAD:
+                       ((jvmtiEventCompiledMethodLoad)ec) (data->jvmti_env, 
+                                                                                               data->method,
+                                                                                               data->jint1,
+                                                                                               data->address,
+                                                                                               data->jint2,
+                                                                                               data->map,
+                                                                                               data->compile_info);
+                       break;
+               
+               case JVMTI_EVENT_COMPILED_METHOD_UNLOAD:
+                       ((jvmtiEventCompiledMethodUnload)ec) (data->jvmti_env,
+                                                                                                 data->method,
+                                                                                                 data->address);
+                       break;
+
+               case JVMTI_EVENT_GARBAGE_COLLECTION_START:
+               case JVMTI_EVENT_GARBAGE_COLLECTION_FINISH:
+               case JVMTI_EVENT_DATA_DUMP_REQUEST: 
+                       ((jvmtiEventDataDumpRequest)ec) (data->jvmti_env);
+                       break;
+
+               case JVMTI_EVENT_MONITOR_WAIT:
+                       ((jvmtiEventMonitorWait)ec) (data->jvmti_env, jni_env, 
+                                                                                data->thread, 
+                                                                                data->object,
+                                                                                data->jlong);
+                       break;
+
+               case JVMTI_EVENT_MONITOR_WAITED:
+                       ((jvmtiEventMonitorWaited)ec) (data->jvmti_env, jni_env, 
+                                                                                  data->thread, 
+                                                                                  data->object,
+                                                                                  data->b);
+                       break;
 
-    case JVMTI_EVENT_OBJECT_FREE: 
-               ((jvmtiEventObjectFree)ec) (data->jvmti_env, data->jlong);
-               break;
 
-    case JVMTI_EVENT_VM_OBJECT_ALLOC:
-               ((jvmtiEventVMObjectAlloc)ec) (data->jvmti_env, jni_env, 
-                                                                          data->thread, 
-                                                                          data->object,
-                                                                          data->klass,
-                                                                          data->jlong);
-               break;
+               case JVMTI_EVENT_MONITOR_CONTENDED_ENTERED:
+               case JVMTI_EVENT_MONITOR_CONTENDED_ENTER:
+                       ((jvmtiEventMonitorContendedEnter)ec) (data->jvmti_env, jni_env,
+                                                                                                  data->thread, 
+                                                                                                  data->object);
+                       break;
 
+               case JVMTI_EVENT_OBJECT_FREE: 
+                       ((jvmtiEventObjectFree)ec) (data->jvmti_env, data->jlong);
+                       break;
 
-       default:
-               log_text ("unknown event");
+               case JVMTI_EVENT_VM_OBJECT_ALLOC:
+                       ((jvmtiEventVMObjectAlloc)ec) (data->jvmti_env, jni_env, 
+                                                                                  data->thread, 
+                                                                                  data->object,
+                                                                                  data->klass,
+                                                                                  data->jlong);
+                       break;
+               default:
+                       log_text ("unknown event");
+               }
+               break;
        }
 }
 
@@ -356,14 +378,14 @@ static void dofireEvent(jvmtiEvent e, genericEventData* data) {
                                if (evm->mode == JVMTI_ENABLE) {
                                        data->jvmti_env=&env->env;
                                        ec = ((functionptr*)(&env->callbacks))[e-JVMTI_EVENT_START_ENUM];
-                                       execcallback(e, ec, data);
+                                       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];
-                       execcallback(e, ec, data);
+                       execute_callback(e, ec, data);
                }
                
                env=env->next;
@@ -377,22 +399,17 @@ static void dofireEvent(jvmtiEvent e, genericEventData* data) {
    missing EventData.
 
 *******************************************************************************/
-void fireEvent(genericEventData* d) {
+void jvmti_fireEvent(genericEventData* d) {
        jthread thread;
-    /* todo : respect event order JVMTI-Spec:Multiple Co-located Events */
+    /* XXX todo : respect event order JVMTI-Spec:Multiple Co-located Events */
 
        if (d->ev != JVMTI_EVENT_VM_START)
-               thread = getcurrentthread();
+               thread = jvmti_get_current_thread();
        else
                thread = NULL;
 
-       fprintf (stderr,"jvmti: fireEvent: %d\n",d->ev);
        d->thread = thread;
        dofireEvent(d->ev,d);
-
-       /* if we need to send a VM_INIT event then also send a THREAD_START event */
-       if (d->ev == JVMTI_EVENT_VM_INIT) 
-               dofireEvent(JVMTI_EVENT_THREAD_START,d);
 }
 
 
@@ -402,7 +419,7 @@ void fireEvent(genericEventData* d) {
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetEventNotificationMode (jvmtiEnv * env, jvmtiEventMode mode,
                          jvmtiEvent event_type, jthread event_thread, ...)
 {
@@ -420,11 +437,12 @@ SetEventNotificationMode (jvmtiEnv * env, jvmtiEventMode mode,
                CHECK_THREAD_IS_ALIVE(event_thread);
        }
        
+
        cacao_env = (environment*) env;    
        if ((mode != JVMTI_ENABLE) && (mode != JVMTI_DISABLE))
                return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 
-       switch (event_type) { /* check capability */
+       switch (event_type) { /* check capability and set system breakpoint */
     case JVMTI_EVENT_EXCEPTION:
        case JVMTI_EVENT_EXCEPTION_CATCH:
                CHECK_CAPABILITY(env,can_generate_exception_events)
@@ -473,6 +491,13 @@ SetEventNotificationMode (jvmtiEnv * env, jvmtiEventMode mode,
     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) ||
@@ -517,7 +542,7 @@ SetEventNotificationMode (jvmtiEnv * env, jvmtiEventMode mode,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetAllThreads (jvmtiEnv * env, jint * threads_count_ptr,
               jthread ** threads_ptr)
 {
@@ -525,8 +550,6 @@ GetAllThreads (jvmtiEnv * env, jint * threads_count_ptr,
        int i;
        jvmtiError retval;
        
-       log_text ("GetAllThreads called");
-
     CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
@@ -534,7 +557,7 @@ GetAllThreads (jvmtiEnv * env, jint * threads_count_ptr,
     if ((threads_count_ptr == NULL) || (threads_ptr == NULL)) 
         return JVMTI_ERROR_NULL_POINTER;
 
-       retval=allthreads(threads_count_ptr, &threads);
+       retval=jvmti_get_all_threads(threads_count_ptr, &threads);
        if (retval != JVMTI_ERROR_NONE) return retval;
 
        *threads_ptr = 
@@ -553,7 +576,7 @@ GetAllThreads (jvmtiEnv * env, jint * threads_count_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SuspendThread (jvmtiEnv * env, jthread thread)
 {
        CHECK_PHASE_START
@@ -573,7 +596,7 @@ SuspendThread (jvmtiEnv * env, jthread thread)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 ResumeThread (jvmtiEnv * env, jthread thread)
 {
     CHECK_PHASE_START
@@ -594,7 +617,7 @@ ResumeThread (jvmtiEnv * env, jthread thread)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 StopThread (jvmtiEnv * env, jthread thread, jobject exception)
 {
        CHECK_PHASE_START
@@ -614,7 +637,7 @@ StopThread (jvmtiEnv * env, jthread thread, jobject exception)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 InterruptThread (jvmtiEnv * env, jthread thread)
 {
        CHECK_PHASE_START
@@ -641,13 +664,11 @@ InterruptThread (jvmtiEnv * env, jthread thread)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadInfo (jvmtiEnv * env, jthread t, jvmtiThreadInfo * info_ptr)
 {
        java_lang_Thread* th = (java_lang_Thread*)t;
 
-       log_text("GetThreadInfo called");
-
     CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
@@ -666,7 +687,7 @@ GetThreadInfo (jvmtiEnv * env, jthread t, jvmtiThreadInfo * info_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread,
                     jint * owned_monitor_count_ptr,
                     jobject ** owned_monitors_ptr)
@@ -675,7 +696,7 @@ GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread,
        java_objectheader **om;
        lock_record_pool_t* lrp;
 
-       log_text("GetOwnedMonitorInfo called - todo: fix object mapping");
+       log_text("GetOwnedMonitorInfo called");
 
        CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_LIVE)
@@ -699,7 +720,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==(threadobject*)thread)&&
                           (!lrp->lr[j].waiting)) {
                                if (i>=size) {
                                        MREALLOC(om,java_objectheader*,size,size*2);
@@ -707,7 +728,7 @@ GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread,
                                }
                                om[i]=lrp->lr[j].o;
                                i++;
-                       }
+                               }*/
                }
                lrp=lrp->header.next;
        }
@@ -731,7 +752,7 @@ GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetCurrentContendedMonitor (jvmtiEnv * env, jthread thread,
                            jobject * monitor_ptr)
 {
@@ -761,10 +782,10 @@ GetCurrentContendedMonitor (jvmtiEnv * env, jthread thread,
 
        while ((lrp != NULL)&&(monitor==NULL)) {
                for (j=0; j<lrp->header.size; j++) {
-                       if((lrp->lr[j].owner==(threadobject*)thread)&&(lrp->lr[j].waiting)) {
+/*                     if((lrp->lr[j].owner==(threadobject*)thread)&&(lrp->lr[j].waiting)) {
                                monitor=lrp->lr[j].o;
                                break;
-                       }
+                               }*/
                }
                lrp=lrp->header.next;
        }
@@ -800,7 +821,7 @@ static void *threadstartup(void *t) {
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RunAgentThread (jvmtiEnv * env, jthread thread, jvmtiStartFunction proc,
                const void *arg, jint priority)
 {
@@ -837,7 +858,7 @@ RunAgentThread (jvmtiEnv * env, jthread thread, jvmtiStartFunction proc,
        }
        pthread_attr_setschedparam(&threadattr,&sp);
        if (pthread_create(&((threadobject*) 
-                                                thread)->info.tid, &threadattr, &threadstartup, &rap)) {
+                                                thread)->tid, &threadattr, &threadstartup, &rap)) {
                log_text("pthread_create failed");
                assert(0);
        }
@@ -853,7 +874,7 @@ RunAgentThread (jvmtiEnv * env, jthread thread, jvmtiStartFunction proc,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetTopThreadGroups (jvmtiEnv * env, jint * group_count_ptr,
                    jthreadGroup ** groups_ptr)
 {
@@ -918,7 +939,7 @@ GetTopThreadGroups (jvmtiEnv * env, jint * group_count_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadGroupInfo (jvmtiEnv * env, jthreadGroup group,
                    jvmtiThreadGroupInfo * info_ptr)
 {
@@ -958,7 +979,7 @@ GetThreadGroupInfo (jvmtiEnv * env, jthreadGroup group,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadGroupChildren (jvmtiEnv * env, jthreadGroup group,
                        jint * thread_count_ptr, jthread ** threads_ptr,
                        jint * group_count_ptr, jthreadGroup ** groups_ptr)
@@ -1023,7 +1044,7 @@ static jvmtiError getcacaostacktrace(stacktracebuffer** trace, jthread thread) {
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetFrameCount (jvmtiEnv * env, jthread thread, jint * count_ptr)
 {
        stacktracebuffer* trace;
@@ -1055,7 +1076,7 @@ GetFrameCount (jvmtiEnv * env, jthread thread, jint * count_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadState (jvmtiEnv * env, jthread thread, jint * thread_state_ptr)
 {
        java_lang_Thread* th = (java_lang_Thread*)thread;
@@ -1074,7 +1095,7 @@ GetThreadState (jvmtiEnv * env, jthread thread, jint * thread_state_ptr)
 #if defined(ENABLE_THREADS)
        if((th->vmThread==NULL)&&(th->group==NULL)) { /* alive ? */
                /* not alive */
-               if (((threadobject*)th->vmThread)->info.tid == 0)
+               if (((threadobject*)th->vmThread)->tid == 0)
                        *thread_state_ptr = JVMTI_THREAD_STATE_TERMINATED;
        } else {
                /* alive */
@@ -1106,7 +1127,7 @@ GetThreadState (jvmtiEnv * env, jthread thread, jint * thread_state_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetFrameLocation (jvmtiEnv * env, jthread thread, jint depth,
                  jmethodID * method_ptr, jlocation * location_ptr)
 {
@@ -1127,7 +1148,7 @@ GetFrameLocation (jvmtiEnv * env, jthread thread, jint depth,
        if ((method_ptr == NULL)&&(location_ptr == NULL)) 
                return JVMTI_ERROR_NULL_POINTER;
        
-       sfi = ((threadobject*)thread)->info._stackframeinfo;
+       sfi = ((threadobject*)thread)->_stackframeinfo;
        
        i = 0;
        while ((sfi != NULL) && (i<depth)) {
@@ -1150,7 +1171,7 @@ GetFrameLocation (jvmtiEnv * env, jthread thread, jint depth,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 NotifyFramePop (jvmtiEnv * env, jthread thread, jint depth)
 {
        CHECK_PHASE_START
@@ -1168,7 +1189,7 @@ NotifyFramePop (jvmtiEnv * env, jthread thread, jint depth)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLocalObject (jvmtiEnv * env,
                jthread thread, jint depth, jint slot, jobject * value_ptr)
 {
@@ -1187,7 +1208,7 @@ GetLocalObject (jvmtiEnv * env,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLocalInt (jvmtiEnv * env,
             jthread thread, jint depth, jint slot, jint * value_ptr)
 {
@@ -1205,7 +1226,7 @@ GetLocalInt (jvmtiEnv * env,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLocalLong (jvmtiEnv * env, jthread thread, jint depth, jint slot,
              jlong * value_ptr)
 {
@@ -1225,7 +1246,7 @@ GetLocalLong (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLocalFloat (jvmtiEnv * env, jthread thread, jint depth, jint slot,
               jfloat * value_ptr)
 {
@@ -1245,7 +1266,7 @@ GetLocalFloat (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLocalDouble (jvmtiEnv * env, jthread thread, jint depth, jint slot,
                jdouble * value_ptr)
 {
@@ -1265,7 +1286,7 @@ GetLocalDouble (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetLocalObject (jvmtiEnv * env, jthread thread, jint depth, jint slot,
                jobject value)
 {
@@ -1285,7 +1306,7 @@ SetLocalObject (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetLocalInt (jvmtiEnv * env, jthread thread, jint depth, jint slot,
             jint value)
 {
@@ -1305,7 +1326,7 @@ SetLocalInt (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetLocalLong (jvmtiEnv * env, jthread thread, jint depth, jint slot,
              jlong value)
 {
@@ -1325,7 +1346,7 @@ SetLocalLong (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetLocalFloat (jvmtiEnv * env, jthread thread, jint depth, jint slot,
               jfloat value)
 {
@@ -1345,7 +1366,7 @@ SetLocalFloat (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetLocalDouble (jvmtiEnv * env, jthread thread, jint depth, jint slot,
                jdouble value)
 {
@@ -1365,7 +1386,7 @@ SetLocalDouble (jvmtiEnv * env, jthread thread, jint depth, jint slot,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 CreateRawMonitor (jvmtiEnv * env, const char *name,
                  jrawMonitorID * monitor_ptr)
 {
@@ -1395,7 +1416,7 @@ CreateRawMonitor (jvmtiEnv * env, const char *name,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 DestroyRawMonitor (jvmtiEnv * env, jrawMonitorID monitor)
 {
        CHECK_PHASE_START
@@ -1427,7 +1448,7 @@ DestroyRawMonitor (jvmtiEnv * env, jrawMonitorID monitor)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RawMonitorEnter (jvmtiEnv * env, jrawMonitorID monitor)
 {
        if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String))
@@ -1449,7 +1470,7 @@ RawMonitorEnter (jvmtiEnv * env, jrawMonitorID monitor)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RawMonitorExit (jvmtiEnv * env, jrawMonitorID monitor)
 {
        if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String))
@@ -1475,7 +1496,7 @@ RawMonitorExit (jvmtiEnv * env, jrawMonitorID monitor)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RawMonitorWait (jvmtiEnv * env, jrawMonitorID monitor, jlong millis)
 {
        if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String))
@@ -1504,7 +1525,7 @@ RawMonitorWait (jvmtiEnv * env, jrawMonitorID monitor, jlong millis)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RawMonitorNotify (jvmtiEnv * env, jrawMonitorID monitor)
 {
        if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String))
@@ -1530,7 +1551,7 @@ RawMonitorNotify (jvmtiEnv * env, jrawMonitorID monitor)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RawMonitorNotifyAll (jvmtiEnv * env, jrawMonitorID monitor)
 {
        if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String))
@@ -1556,14 +1577,14 @@ RawMonitorNotifyAll (jvmtiEnv * env, jrawMonitorID monitor)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetBreakpoint (jvmtiEnv * env, jmethodID method, jlocation location)
 {
        CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
        CHECK_CAPABILITY(env,can_generate_breakpoint_events)
-        
+
                /* addbrkpt */
   log_text ("JVMTI-Call: TBD OPTIONAL IMPLEMENT ME!!!");
     return JVMTI_ERROR_NONE;
@@ -1576,7 +1597,7 @@ SetBreakpoint (jvmtiEnv * env, jmethodID method, jlocation location)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 ClearBreakpoint (jvmtiEnv * env, jmethodID method, jlocation location)
 {
        CHECK_PHASE_START
@@ -1595,7 +1616,7 @@ ClearBreakpoint (jvmtiEnv * env, jmethodID method, jlocation location)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetFieldAccessWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 {
        CHECK_PHASE_START
@@ -1614,7 +1635,7 @@ SetFieldAccessWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 ClearFieldAccessWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 {
        CHECK_PHASE_START
@@ -1633,7 +1654,7 @@ ClearFieldAccessWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetFieldModificationWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 {
        CHECK_PHASE_START
@@ -1652,7 +1673,7 @@ SetFieldModificationWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 ClearFieldModificationWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 {
        CHECK_PHASE_START
@@ -1672,7 +1693,7 @@ ClearFieldModificationWatch (jvmtiEnv * env, jclass klass, jfieldID field)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 Allocate (jvmtiEnv * env, jlong size, unsigned char **mem_ptr)
 {
     
@@ -1694,10 +1715,11 @@ Allocate (jvmtiEnv * env, jlong size, unsigned char **mem_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 Deallocate (jvmtiEnv * env, unsigned char *mem)
 {
     /* let Boehm GC do the job */
+       heap_free(mem);
     return JVMTI_ERROR_NONE;
 }
 
@@ -1709,7 +1731,7 @@ Deallocate (jvmtiEnv * env, unsigned char *mem)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetClassSignature (jvmtiEnv * env, jclass klass, char **signature_ptr,
                   char **generic_ptr)
 {
@@ -1747,7 +1769,7 @@ GetClassSignature (jvmtiEnv * env, jclass klass, char **signature_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetClassStatus (jvmtiEnv * env, jclass klass, jint * status_ptr)
 {
        classinfo *c;
@@ -1791,7 +1813,7 @@ GetClassStatus (jvmtiEnv * env, jclass klass, jint * status_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetSourceFileName (jvmtiEnv * env, jclass klass, char **source_name_ptr)
 {
     int size; 
@@ -1822,7 +1844,7 @@ GetSourceFileName (jvmtiEnv * env, jclass klass, char **source_name_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetClassModifiers (jvmtiEnv * env, jclass klass, jint * modifiers_ptr)
 {
        CHECK_PHASE_START
@@ -1848,15 +1870,17 @@ GetClassModifiers (jvmtiEnv * env, jclass klass, jint * modifiers_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetClassMethods (jvmtiEnv * env, jclass klass, jint * method_count_ptr,
                 jmethodID ** methods_ptr)
 {
-    CHECK_PHASE_START
+       int i;
+
+       CHECK_PHASE_START
     CHECK_PHASE(JVMTI_PHASE_START)
     CHECK_PHASE(JVMTI_PHASE_LIVE)
     CHECK_PHASE_END;
-        
+       
     if ((klass == NULL)||(methods_ptr == NULL)||(method_count_ptr == NULL)) 
         return JVMTI_ERROR_NULL_POINTER;
 
@@ -1866,10 +1890,10 @@ GetClassMethods (jvmtiEnv * env, jclass klass, jint * method_count_ptr,
     *method_count_ptr = (jint)((classinfo*)klass)->methodscount;
     *methods_ptr = (jmethodID*) 
         heap_allocate(sizeof(jmethodID) * (*method_count_ptr),true,NULL);
-    
-    memcpy (*methods_ptr, ((classinfo*)klass)->methods, 
-            sizeof(jmethodID) * (*method_count_ptr));
-    
+
+    for (i=0; i<*method_count_ptr;i++)
+               (*methods_ptr)[i]=(jmethodID) &(((classinfo*)klass)->methods[i]);
+
     return JVMTI_ERROR_NONE;
 }
 
@@ -1881,7 +1905,7 @@ GetClassMethods (jvmtiEnv * env, jclass klass, jint * method_count_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetClassFields (jvmtiEnv * env, jclass klass, jint * field_count_ptr,
                jfieldID ** fields_ptr)
 {
@@ -1910,7 +1934,7 @@ GetClassFields (jvmtiEnv * env, jclass klass, jint * field_count_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetImplementedInterfaces (jvmtiEnv * env, jclass klass,
                          jint * interface_count_ptr,
                          jclass ** interfaces_ptr)
@@ -1955,7 +1979,7 @@ GetImplementedInterfaces (jvmtiEnv * env, jclass klass,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IsInterface (jvmtiEnv * env, jclass klass, jboolean * is_interface_ptr)
 {
     CHECK_PHASE_START
@@ -1977,7 +2001,7 @@ IsInterface (jvmtiEnv * env, jclass klass, jboolean * is_interface_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IsArrayClass (jvmtiEnv * env, jclass klass, jboolean * is_array_class_ptr)
 {
     CHECK_PHASE_START
@@ -2001,7 +2025,7 @@ IsArrayClass (jvmtiEnv * env, jclass klass, jboolean * is_array_class_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetClassLoader (jvmtiEnv * env, jclass klass, jobject * classloader_ptr)
 {
     CHECK_PHASE_START
@@ -2024,7 +2048,7 @@ GetClassLoader (jvmtiEnv * env, jclass klass, jobject * classloader_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetObjectHashCode (jvmtiEnv * env, jobject object, jint * hash_code_ptr)
 {
        CHECK_PHASE_START
@@ -2048,7 +2072,7 @@ GetObjectHashCode (jvmtiEnv * env, jobject object, jint * hash_code_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetObjectMonitorUsage (jvmtiEnv * env, jobject object,
                       jvmtiMonitorUsage * info_ptr)
 {
@@ -2069,7 +2093,7 @@ GetObjectMonitorUsage (jvmtiEnv * env, jobject object,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetFieldName (jvmtiEnv * env, jclass klass, jfieldID field,
              char **name_ptr, char **signature_ptr, char **generic_ptr)
 {
@@ -2105,7 +2129,7 @@ GetFieldName (jvmtiEnv * env, jclass klass, jfieldID field,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetFieldDeclaringClass (jvmtiEnv * env, jclass klass, jfieldID field,
                        jclass * declaring_class_ptr)
 {
@@ -2126,7 +2150,7 @@ GetFieldDeclaringClass (jvmtiEnv * env, jclass klass, jfieldID field,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetFieldModifiers (jvmtiEnv * env, jclass klass, jfieldID field,
                   jint * modifiers_ptr)
 {
@@ -2154,7 +2178,7 @@ GetFieldModifiers (jvmtiEnv * env, jclass klass, jfieldID field,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IsFieldSynthetic (jvmtiEnv * env, jclass klass, jfieldID field,
                  jboolean * is_synthetic_ptr)
 {
@@ -2176,7 +2200,7 @@ IsFieldSynthetic (jvmtiEnv * env, jclass klass, jfieldID field,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetMethodName (jvmtiEnv * env, jmethodID method, char **name_ptr,
               char **signature_ptr, char **generic_ptr)
 {
@@ -2190,8 +2214,6 @@ GetMethodName (jvmtiEnv * env, jmethodID method, char **name_ptr,
     if ((method == NULL) || (name_ptr == NULL) || (signature_ptr == NULL)
         || (generic_ptr == NULL)) return JVMTI_ERROR_NULL_POINTER;
 
-       if (m->name == NULL) return JVMTI_ERROR_INTERNAL;
-
     *name_ptr = (char*)
                heap_allocate(sizeof(char) * (m->name->blength),true,NULL);
        utf_sprint_convert_to_latin1(*name_ptr, m->name);
@@ -2213,7 +2235,7 @@ GetMethodName (jvmtiEnv * env, jmethodID method, char **name_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetMethodDeclaringClass (jvmtiEnv * env, jmethodID method,
                         jclass * declaring_class_ptr)
 {
@@ -2237,7 +2259,7 @@ GetMethodDeclaringClass (jvmtiEnv * env, jmethodID method,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetMethodModifiers (jvmtiEnv * env, jmethodID method, jint * modifiers_ptr)
 {
     CHECK_PHASE_START
@@ -2262,7 +2284,7 @@ GetMethodModifiers (jvmtiEnv * env, jmethodID method, jint * modifiers_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetMaxLocals (jvmtiEnv * env, jmethodID method, jint * max_ptr)
 {
     CHECK_PHASE_START
@@ -2289,7 +2311,7 @@ GetMaxLocals (jvmtiEnv * env, jmethodID method, jint * max_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetArgumentsSize (jvmtiEnv * env, jmethodID method, jint * size_ptr)
 {
     CHECK_PHASE_START
@@ -2315,7 +2337,7 @@ GetArgumentsSize (jvmtiEnv * env, jmethodID method, jint * size_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLineNumberTable (jvmtiEnv * env, jmethodID method,
                    jint * entry_count_ptr, jvmtiLineNumberEntry ** table_ptr)
 {
@@ -2358,7 +2380,7 @@ GetLineNumberTable (jvmtiEnv * env, jmethodID method,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetMethodLocation (jvmtiEnv * env, jmethodID method,
                   jlocation * start_location_ptr,
                   jlocation * end_location_ptr)
@@ -2395,7 +2417,7 @@ GetMethodLocation (jvmtiEnv * env, jmethodID method,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLocalVariableTable (jvmtiEnv * env, jmethodID method,
                       jint * entry_count_ptr,
                       jvmtiLocalVariableEntry ** table_ptr)
@@ -2418,7 +2440,7 @@ GetLocalVariableTable (jvmtiEnv * env, jmethodID method,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetBytecodes (jvmtiEnv * env, jmethodID method,
              jint * bytecode_count_ptr, unsigned char **bytecodes_ptr)
 {
@@ -2448,7 +2470,7 @@ GetBytecodes (jvmtiEnv * env, jmethodID method,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IsMethodNative (jvmtiEnv * env, jmethodID method, jboolean * is_native_ptr)
 {
     CHECK_PHASE_START
@@ -2475,7 +2497,7 @@ IsMethodNative (jvmtiEnv * env, jmethodID method, jboolean * is_native_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IsMethodSynthetic (jvmtiEnv * env, jmethodID method,
                   jboolean * is_synthetic_ptr)
 {
@@ -2496,7 +2518,7 @@ IsMethodSynthetic (jvmtiEnv * env, jmethodID method,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetLoadedClasses (jvmtiEnv * env, jint * class_count_ptr, jclass ** classes_ptr)
 {
        int i,j;
@@ -2579,7 +2601,7 @@ GetLoadedClasses (jvmtiEnv * env, jint * class_count_ptr, jclass ** classes_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetClassLoaderClasses (jvmtiEnv * env, jobject initiating_loader,
                       jint * class_count_ptr, jclass ** classes_ptr)
 {
@@ -2605,7 +2627,7 @@ GetClassLoaderClasses (jvmtiEnv * env, jobject initiating_loader,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 PopFrame (jvmtiEnv * env, jthread thread)
 {
     CHECK_PHASE_START
@@ -2624,7 +2646,7 @@ PopFrame (jvmtiEnv * env, jthread thread)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RedefineClasses (jvmtiEnv * env, jint class_count,
                 const jvmtiClassDefinition * class_definitions)
 {
@@ -2645,12 +2667,12 @@ RedefineClasses (jvmtiEnv * env, jint class_count,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetVersionNumber (jvmtiEnv * env, jint * version_ptr)
 {
     if (version_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
 
-    *version_ptr = JVMTI_VERSION_1_0;
+    *version_ptr = JVMTI_VERSION;
     
     return JVMTI_ERROR_NONE;
 }
@@ -2663,7 +2685,7 @@ GetVersionNumber (jvmtiEnv * env, jint * version_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetCapabilities (jvmtiEnv * env, jvmtiCapabilities * capabilities_ptr)
 {
     if (capabilities_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
@@ -2680,7 +2702,7 @@ GetCapabilities (jvmtiEnv * env, jvmtiCapabilities * capabilities_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetSourceDebugExtension (jvmtiEnv * env, jclass klass,
                         char **source_debug_extension_ptr)
 {
@@ -2701,7 +2723,7 @@ GetSourceDebugExtension (jvmtiEnv * env, jclass klass,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IsMethodObsolete (jvmtiEnv * env, jmethodID method,
                  jboolean * is_obsolete_ptr)
 {
@@ -2722,7 +2744,7 @@ IsMethodObsolete (jvmtiEnv * env, jmethodID method,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SuspendThreadList (jvmtiEnv * env, jint request_count,
                   const jthread * request_list, jvmtiError * results)
 {
@@ -2744,7 +2766,7 @@ SuspendThreadList (jvmtiEnv * env, jint request_count,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 ResumeThreadList (jvmtiEnv * env, jint request_count,
                  const jthread * request_list, jvmtiError * results)
 {
@@ -2765,7 +2787,7 @@ ResumeThreadList (jvmtiEnv * env, jint request_count,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetStackTrace (jvmtiEnv * env, jthread thread, jint start_depth,
               jint max_frame_count, jvmtiFrameInfo * frame_buffer,
               jint * count_ptr)
@@ -2810,7 +2832,7 @@ GetStackTrace (jvmtiEnv * env, jthread thread, jint start_depth,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadListStackTraces (jvmtiEnv * env, jint thread_count,
                          const jthread * thread_list,
                          jint max_frame_count,
@@ -2855,7 +2877,7 @@ GetThreadListStackTraces (jvmtiEnv * env, jint thread_count,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetAllStackTraces (jvmtiEnv * env, jint max_frame_count,
                   jvmtiStackInfo ** stack_info_ptr, jint * thread_count_ptr)
 {
@@ -2889,7 +2911,7 @@ GetAllStackTraces (jvmtiEnv * env, jint max_frame_count,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadLocalStorage (jvmtiEnv * env, jthread thread, void **data_ptr)
 {
        jvmtiThreadLocalStorage *tls;
@@ -2980,7 +3002,7 @@ SetThreadLocalStorage (jvmtiEnv * jenv, jthread thread, const void *data)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetTag (jvmtiEnv * env, jobject object, jlong * tag_ptr)
 {
        CHECK_PHASE_START
@@ -2999,7 +3021,7 @@ GetTag (jvmtiEnv * env, jobject object, jlong * tag_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetTag (jvmtiEnv * env, jobject object, jlong tag)
 {
        CHECK_PHASE_START
@@ -3019,7 +3041,7 @@ SetTag (jvmtiEnv * env, jobject object, jlong tag)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 ForceGarbageCollection (jvmtiEnv * env)
 {
        CHECK_PHASE_START
@@ -3038,7 +3060,7 @@ ForceGarbageCollection (jvmtiEnv * env)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IterateOverObjectsReachableFromObject (jvmtiEnv * env, jobject object,
                                       jvmtiObjectReferenceCallback
                                       object_reference_callback,
@@ -3060,7 +3082,7 @@ IterateOverObjectsReachableFromObject (jvmtiEnv * env, jobject object,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IterateOverReachableObjects (jvmtiEnv * env, jvmtiHeapRootCallback
                             heap_root_callback,
                             jvmtiStackReferenceCallback
@@ -3084,7 +3106,7 @@ IterateOverReachableObjects (jvmtiEnv * env, jvmtiHeapRootCallback
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IterateOverHeap (jvmtiEnv * env, jvmtiHeapObjectFilter object_filter,
                 jvmtiHeapObjectCallback heap_object_callback,
                 void *user_data)
@@ -3105,7 +3127,7 @@ IterateOverHeap (jvmtiEnv * env, jvmtiHeapObjectFilter object_filter,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 IterateOverInstancesOfClass (jvmtiEnv * env, jclass klass,
                             jvmtiHeapObjectFilter object_filter,
                             jvmtiHeapObjectCallback
@@ -3127,7 +3149,7 @@ IterateOverInstancesOfClass (jvmtiEnv * env, jclass klass,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetObjectsWithTags (jvmtiEnv * env, jint tag_count, const jlong * tags,
                    jint * count_ptr, jobject ** object_result_ptr,
                    jlong ** tag_result_ptr)
@@ -3148,7 +3170,7 @@ GetObjectsWithTags (jvmtiEnv * env, jint tag_count, const jlong * tags,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetJNIFunctionTable (jvmtiEnv * env,
                     const jniNativeInterface * function_table)
 { 
@@ -3171,7 +3193,7 @@ SetJNIFunctionTable (jvmtiEnv * env,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetJNIFunctionTable (jvmtiEnv * env, jniNativeInterface ** function_table)
 {
     CHECK_PHASE_START
@@ -3194,7 +3216,7 @@ GetJNIFunctionTable (jvmtiEnv * env, jniNativeInterface ** function_table)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetEventCallbacks (jvmtiEnv * env,
                   const jvmtiEventCallbacks * callbacks,
                   jint size_of_callbacks)
@@ -3224,7 +3246,7 @@ SetEventCallbacks (jvmtiEnv * env,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GenerateEvents (jvmtiEnv * env, jvmtiEvent event_type)
 {
     CHECK_PHASE_START
@@ -3242,7 +3264,7 @@ GenerateEvents (jvmtiEnv * env, jvmtiEvent event_type)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetExtensionFunctions (jvmtiEnv * env, jint * extension_count_ptr,
                       jvmtiExtensionFunctionInfo ** extensions)
 {
@@ -3267,7 +3289,7 @@ GetExtensionFunctions (jvmtiEnv * env, jint * extension_count_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetExtensionEvents (jvmtiEnv * env, jint * extension_count_ptr,
                    jvmtiExtensionEventInfo ** extensions)
 {
@@ -3292,7 +3314,7 @@ GetExtensionEvents (jvmtiEnv * env, jint * extension_count_ptr,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetExtensionEventCallback (jvmtiEnv * env, jint extension_event_index,
                           jvmtiExtensionEvent callback)
 {
@@ -3312,7 +3334,7 @@ SetExtensionEventCallback (jvmtiEnv * env, jint extension_event_index,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 DisposeEnvironment (jvmtiEnv * env)
 {
        environment* cacao_env = (environment*)env;
@@ -3343,12 +3365,7 @@ DisposeEnvironment (jvmtiEnv * env)
        cacao_env->tls = NULL;
 
 
-       pthread_mutex_lock(&dbgcomlock);
-       dbgcom->running--;
-       if (dbgcom->running  == 0) {
-               TRAP;
-       }
-       pthread_mutex_unlock(&dbgcomlock);
+       jvmti_cacaodbgserver_quit();
 
     /* let the GC do the rest */
     return JVMTI_ERROR_NONE;
@@ -3365,7 +3382,7 @@ DisposeEnvironment (jvmtiEnv * env)
                                     memcpy(*name_ptr, &str, sizeof(str)); \
                                     break
 
-jvmtiError
+static jvmtiError
 GetErrorName (jvmtiEnv * env, jvmtiError error, char **name_ptr)
 {
     if (name_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
@@ -3479,7 +3496,7 @@ GetErrorName (jvmtiEnv * env, jvmtiError error, char **name_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetJLocationFormat (jvmtiEnv * env, jvmtiJlocationFormat * format_ptr)
 {
     *format_ptr = JVMTI_JLOCATION_MACHINEPC;
@@ -3494,7 +3511,7 @@ GetJLocationFormat (jvmtiEnv * env, jvmtiJlocationFormat * format_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetSystemProperties (jvmtiEnv * env, jint * count_ptr, char ***property_ptr)
 {
        jmethodID mid, moremid;
@@ -3574,7 +3591,7 @@ GetSystemProperties (jvmtiEnv * env, jint * count_ptr, char ***property_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetSystemProperty (jvmtiEnv * env, const char *property, char **value_ptr)
 {
     jmethodID mid;
@@ -3626,7 +3643,7 @@ GetSystemProperty (jvmtiEnv * env, const char *property, char **value_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetSystemProperty (jvmtiEnv * env, const char *property, const char *value)
 {
     jmethodID mid;
@@ -3669,7 +3686,7 @@ SetSystemProperty (jvmtiEnv * env, const char *property, const char *value)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetPhase (jvmtiEnv * env, jvmtiPhase * phase_ptr)
 {
     if (phase_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
@@ -3685,7 +3702,7 @@ GetPhase (jvmtiEnv * env, jvmtiPhase * phase_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetCurrentThreadCpuTimerInfo (jvmtiEnv * env, jvmtiTimerInfo * info_ptr)
 {
        CHECK_PHASE_START
@@ -3705,7 +3722,7 @@ GetCurrentThreadCpuTimerInfo (jvmtiEnv * env, jvmtiTimerInfo * info_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetCurrentThreadCpuTime (jvmtiEnv * env, jlong * nanos_ptr)
 {
        CHECK_PHASE_START
@@ -3724,7 +3741,7 @@ GetCurrentThreadCpuTime (jvmtiEnv * env, jlong * nanos_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadCpuTimerInfo (jvmtiEnv * env, jvmtiTimerInfo * info_ptr)
 {
        CHECK_PHASE_START
@@ -3743,7 +3760,7 @@ GetThreadCpuTimerInfo (jvmtiEnv * env, jvmtiTimerInfo * info_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetThreadCpuTime (jvmtiEnv * env, jthread thread, jlong * nanos_ptr)
 {
        CHECK_PHASE_START
@@ -3760,7 +3777,7 @@ GetThreadCpuTime (jvmtiEnv * env, jthread thread, jlong * nanos_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetTimerInfo (jvmtiEnv * env, jvmtiTimerInfo * info_ptr)
 {
     if (info_ptr == NULL) return JVMTI_ERROR_NULL_POINTER;
@@ -3779,7 +3796,7 @@ GetTimerInfo (jvmtiEnv * env, jvmtiTimerInfo * info_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetTime (jvmtiEnv * env, jlong * nanos_ptr)
 {
     /* Note: this implementation copied directly from Japhar's, by Chris Toshok. */
@@ -3804,7 +3821,7 @@ GetTime (jvmtiEnv * env, jlong * nanos_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetPotentialCapabilities (jvmtiEnv * env,
                          jvmtiCapabilities * capabilities_ptr)
 {
@@ -3821,11 +3838,13 @@ GetPotentialCapabilities (jvmtiEnv * env,
 }
 
 
-#define CHECK_ADD_CAPABILITY(env,CAN)      \
-        if ((capabilities_ptr->CAN == 1) && \
-           (JVMTI_Capabilities.CAN == 0))   \
-           return JVMTI_ERROR_NOT_AVAILABLE; \
-        env->capabilities.CAN = 1;
+#define CHECK_ADD_CAPABILITY(env,CAN)          \
+        if (capabilities_ptr->CAN == 1) {      \
+           if (JVMTI_Capabilities.CAN == 0)    \
+             return JVMTI_ERROR_NOT_AVAILABLE; \
+           else                                \
+             env->capabilities.CAN = 1;        \
+        }                                     
 
 /* AddCapabilities ************************************************************
 
@@ -3834,7 +3853,7 @@ GetPotentialCapabilities (jvmtiEnv * env,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 AddCapabilities (jvmtiEnv * env, const jvmtiCapabilities * capabilities_ptr)
 {
     environment* cacao_env;
@@ -3898,7 +3917,7 @@ AddCapabilities (jvmtiEnv * env, const jvmtiCapabilities * capabilities_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 RelinquishCapabilities (jvmtiEnv * env,
                        const jvmtiCapabilities * capabilities_ptr)
 {
@@ -3957,7 +3976,7 @@ RelinquishCapabilities (jvmtiEnv * env,
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetAvailableProcessors (jvmtiEnv * env, jint * processor_count_ptr)
 {
        CHECK_PHASE_START
@@ -3980,7 +3999,7 @@ GetAvailableProcessors (jvmtiEnv * env, jint * processor_count_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetEnvironmentLocalStorage (jvmtiEnv * env, void **data_ptr)
 {
     if ((env == NULL) || (data_ptr == NULL)) return JVMTI_ERROR_NULL_POINTER;
@@ -3997,7 +4016,7 @@ GetEnvironmentLocalStorage (jvmtiEnv * env, void **data_ptr)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetEnvironmentLocalStorage (jvmtiEnv * env, const void *data)
 {
     if (env == NULL) return JVMTI_ERROR_NULL_POINTER;
@@ -4014,7 +4033,7 @@ SetEnvironmentLocalStorage (jvmtiEnv * env, const void *data)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 AddToBootstrapClassLoaderSearch (jvmtiEnv * env, const char *segment)
 {
     char* tmp_bcp;
@@ -4043,7 +4062,7 @@ AddToBootstrapClassLoaderSearch (jvmtiEnv * env, const char *segment)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 SetVerboseFlag (jvmtiEnv * env, jvmtiVerboseFlag flag, jboolean value)
 {
     switch (flag) {
@@ -4072,7 +4091,7 @@ SetVerboseFlag (jvmtiEnv * env, jvmtiVerboseFlag flag, jboolean value)
 
 *******************************************************************************/
 
-jvmtiError
+static jvmtiError
 GetObjectSize (jvmtiEnv * env, jobject object, jlong * size_ptr)
 {
     CHECK_PHASE_START
@@ -4297,7 +4316,7 @@ static struct jvmtiEnv_struct JVMTI_EnvTable = {
 };
 
 
-void set_jvmti_phase(jvmtiPhase p) {
+void jvmti_set_phase(jvmtiPhase p) {
        genericEventData d;
 
        fprintf (stderr,"set JVMTI phase %d\n",p);
@@ -4313,13 +4332,13 @@ void set_jvmti_phase(jvmtiPhase p) {
     case JVMTI_PHASE_START: 
                phase = p;
                d.ev = JVMTI_EVENT_VM_START;
-               /* this event is sent during start or live phase */
-               log_text("set sysbrk in setthreadobj");
-               setsysbrkpt(SETTHREADOBJECTBRK,(void*)&threads_set_current_threadobject);
         break;
     case JVMTI_PHASE_LIVE: 
                phase = p; 
                d.ev = JVMTI_EVENT_VM_INIT;
+               jvmti_fireEvent(&d);
+               /* thread start event for main thread */
+               d.ev = JVMTI_EVENT_THREAD_START;
                break;
     case JVMTI_PHASE_DEAD:
                phase = p;
@@ -4330,13 +4349,11 @@ void set_jvmti_phase(jvmtiPhase p) {
                exit(1);
     }
 
-       fireEvent(&d);
+       jvmti_fireEvent(&d);
 }
 
-jvmtiEnv* new_jvmtienv() {
+jvmtiEnv* jvmti_new_environment() {
     environment* env;
-       pid_t dbgserver;
-       char* comaddr;
 
        if (envs == NULL) {
                envs = heap_allocate(sizeof(environment),true,NULL);
@@ -4357,38 +4374,14 @@ jvmtiEnv* new_jvmtienv() {
     RelinquishCapabilities(&(env->env),&(env->capabilities));
     env->EnvironmentLocalStorage = NULL;
        env->tls = NULL;
-
-       /* start new cacaodbgserver if needed*/
-       pthread_mutex_lock(&dbgcomlock);
-       if (dbgcom == NULL) {
-               dbgcom = heap_allocate(sizeof(cacaodbgcommunication),true,NULL);                
-               dbgcom->running = 1;
-               dbgcom->breakpointhandler = (void*)cacaobreakpointhandler;
-               dbgserver = fork();
-               if (dbgserver  == (-1)) {
-                       log_text("cacaodbgserver fork error");
-                       exit(1);
-               } else {
-                       if (dbgserver == 0) {
-                               comaddr = MNEW(char,11);
-                               snprintf(comaddr,11,"%p",dbgcom);
-                               if (execlp("cacaodbgserver","cacaodbgserver",comaddr,(char *) NULL) == -1) {
-                                       log_text("unable to execute cacaodbgserver");
-                                       exit(1);
-                               }
-                       }
-               }
-       } else {
-               dbgcom->running++;
-       }
-       pthread_mutex_unlock(&dbgcomlock);
-       sched_yield();
-
+       
+       /* initialize cacao debugging facilities */
+       jvmti_cacao_debug_init();
 
        return (jvmtiEnv*)env;
 }
 
-void agentload(char* opt_arg, bool agentbypath, lt_dlhandle  *handle, char **libname) {
+void jvmti_agentload(char* opt_arg, bool agentbypath, lt_dlhandle  *handle, char **libname) {
        lt_ptr onload;
        char *arg;
        int i=0,len;
@@ -4437,7 +4430,7 @@ void agentload(char* opt_arg, bool agentbypath, lt_dlhandle  *handle, char **lib
        if (retval != 0) exit (retval);
 }
 
-void agentunload() {
+void jvmti_agentunload() {
        if (unload != NULL) {
                ((JNIEXPORT void JNICALL (*) (JavaVM *vm)) unload) 
                        ((JavaVM*) &_Jv_JNIInvokeInterface);
index 1ff62419432b45c153f7b2f890b77bc7f5efae35..69fc3df1ae4297714d199fd63d49443ae2a97703 100644 (file)
@@ -30,7 +30,7 @@
    Changes:             
 
    
-   $Id: jvmti.h 4892 2006-05-06 18:29:55Z motse $
+   $Id: jvmti.h 4944 2006-05-23 15:31:19Z motse $
 
 */
 #ifndef _JVMTI_H
 #include "native/jni.h"
 #include <sys/types.h>
 
+
+#define JVMTI_VERSION_INTERFACE_JNI   0x00000000
+#define JVMTI_VERSION_INTERFACE_JVMTI 0x30000000
+#define JVMTI_VERSION_MASK_INTERFACE_TYPE 0x70000000
 #define JVMTI_VERSION_1_0 0x30010000
 #define JVMTI_VERSION     JVMTI_VERSION_1_0 
 
+
 typedef jobject jthread;
 typedef jobject jthreadGroup;
 typedef jlong jlocation;
index 2d220093343461cecafa96f58ea99fd7db4a606f..8844f2b394ac8728eb565ca35faf1a6ee48e914b 100644 (file)
@@ -29,7 +29,7 @@ Authors: Martin Platter
 Changes: Samuel Vinson
 
 
-$Id: VMVirtualMachine.c 4892 2006-05-06 18:29:55Z motse $
+$Id: VMVirtualMachine.c 4944 2006-05-23 15:31:19Z motse $
 
 */
 
@@ -86,8 +86,18 @@ JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getSuspendCount(JN
 JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClassesCount(JNIEnv *env, jclass clazz) {
     jint count;
     jclass* classes;
+       jvmtiError err;
+       char* errdesc;
 
-    (*jvmtienv)->GetLoadedClasses(jvmtienv, &count, &classes);
+       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);
+               return 0;
+       }
+       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)classes);
     return count;
 }
 
@@ -112,10 +122,14 @@ JNIEXPORT struct java_util_Iterator* JNICALL Java_gnu_classpath_jdwp_VMVirtualMa
                (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
                fprintf(stderr,"jvmti error: %s\n",errdesc);
                fflush(stderr);
-/*             env->ThrowNew(env,ec,"jvmti error occoured");*/
+               
+               /* we should throw JDWP Exception INTERNAL = 113;*/
+/*             env->ThrowNew(env,ec,"jvmti error occoured");  */
+               return NULL;
        }
        
        cl = (*env)->FindClass(env,"java.lang.Class");
+       if (!cl) return NULL;
 
        /* Arrays.asList(Object[] classes)->List.Iterator()->Iterator */
        joa = (*env)->NewObjectArray(env, (jsize)classcount, cl , NULL);
@@ -123,6 +137,7 @@ JNIEXPORT struct java_util_Iterator* JNICALL Java_gnu_classpath_jdwp_VMVirtualMa
 
        for (i = 0; i < classcount; i++) 
                (*env)->SetObjectArrayElement(env,joa,(jsize)i, (jobject)classes[i]);
+       (*jvmtienv)->Deallocate(jvmtienv, (unsigned char*)classes);
        
        cl = (*env)->FindClass(env,"java.util.Arrays");
        if (!cl) return NULL;
@@ -137,7 +152,7 @@ JNIEXPORT struct java_util_Iterator* JNICALL Java_gnu_classpath_jdwp_VMVirtualMa
        if (!cl) return NULL;
        m = (*env)->GetMethodID(env,cl,"iterator","()Ljava/util/Iterator;");
        if (!m) return NULL;
-       oi = (*env)->CallObjectMethod(env,*ol,m);
+       oi = (*env)->CallObjectMethod(env,ol,m);
                
        return (struct java_util_Iterator*)oi;
 }
@@ -158,8 +173,43 @@ JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus(JNI
  * Signature: (Ljava/lang/Class;)[Lgnu/classpath/jdwp/VMMethod;
  */
 JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllClassMethods(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
-    log_text ("VMVirtualMachine_getAllClassMethods: IMPLEMENT ME !!!");
-       return NULL;
+    jint count;
+    jmethodID* methodID, m;
+       jvmtiError err;
+       char* errdesc;
+       
+       jclass *cl;
+       jobject *ol;
+       jobjectArray joa;
+       int i;
+       fprintf(stderr, "VMVirtualMachine_getAllClassMethods start\n");
+    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);
+/*             env->ThrowNew(env,ec,"jvmti error occoured");*/
+               return NULL;
+       }
+       
+       fprintf(stderr, "VMVirtualMachine_getAllClassMethods count %d\n", count);
+       m = (*env)->GetStaticMethodID(env, clazz, "getClassMethod", "(Ljava/lang/Class;J)Lgnu/classpath/jdwp/VMMethod;");
+       if (!m) return NULL;
+   
+    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.VMMethod");
+       if (!cl) 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]);
+               if (!ol) return NULL;
+       (*env)->SetObjectArrayElement(env,joa,(jsize)i, ol);
+    }
+       fprintf(stderr, "VMVirtualMachine_getAllClassMethods end\n");
+       return joa;
 }
 
 
@@ -169,8 +219,19 @@ JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_get
  * Signature: (Ljava/lang/Class;J)Lgnu/classpath/jdwp/VMMethod;
  */
 JNIEXPORT struct gnu_classpath_jdwp_VMMethod* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getClassMethod(JNIEnv *env, jclass clazz, struct java_lang_Class* par1, s8 par2) {
-    log_text ("VMVirtualMachine_getAllClassMethod: IMPLEMENT ME !!!");
-       return NULL;
+       jclass *cl;
+    jmethodID m;
+    jobject *ol;
+       
+    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.VMMethod");
+       if (!cl) return NULL;
+       
+       m = (*env)->GetMethodID(env, cl, "<init>", "(Ljava/lang/Class;J)V");
+       if (!m) return NULL;
+       
+    ol = (*env)->NewObject(env, cl, m, par1, par2);
+       
+       return (struct gnu_classpath_jdwp_VMMethod*)ol;
 }
 
 
index 93de86514696eaced55ee20cfc6b80a1dc466dcf..f412f333aad6eaac7cbf3b26e429499add624967 100644 (file)
@@ -129,6 +129,11 @@ struct lock_record_pool_t {
        lock_record_t             lr[1];         /* variable array of records     */
 };
 
+#if defined(ENABLE_JVMTI)
+extern pthread_mutex_t lock_global_pool_lock;
+extern lock_record_pool_t *lock_global_pool;
+#endif
+
 
 /* functions ******************************************************************/
 
index 55aa25d8ba21e26ef2ab78b05bc47e66fd5d65e5..006c39413e3d1289a30378f113c6ea082218c97a 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Christian Thalinger
                        Edwin Steiner
 
-   $Id: threads.c 4938 2006-05-22 09:06:44Z twisti $
+   $Id: threads.c 4944 2006-05-23 15:31:19Z motse $
 
 */
 
@@ -624,7 +624,6 @@ int cacao_suspendhandler(ucontext_t *ctx)
 }
 #endif
 
-
 /* threads_set_current_threadobject ********************************************
 
    Set the current thread object.
@@ -634,11 +633,7 @@ int cacao_suspendhandler(ucontext_t *ctx)
 
 *******************************************************************************/
 
-#if !defined(ENABLE_JVMTI)
 static void threads_set_current_threadobject(threadobject *thread)
-#else
-void threads_set_current_threadobject(threadobject *thread)
-#endif
 {
 #if !defined(HAVE___THREAD)
        pthread_setspecific(threads_current_threadobject_key, thread);
@@ -1084,6 +1079,14 @@ static void *threads_startup_thread(void *t)
                thread->_global_sp = (void *) (intrp_thread_stack + opt_stacksize);
 #endif
 
+
+
+#if defined(ENABLE_JVMTI)
+       /* breakpoint for thread start event */
+       __asm__("threadstart:");
+#endif
+
+
        /* find and run the Thread.run()V method if no other function was passed */
 
        if (function == NULL) {
@@ -1105,6 +1108,12 @@ static void *threads_startup_thread(void *t)
                (function)();
        }
 
+#if defined(ENABLE_JVMTI)
+       /* breakpoint for thread end event */
+       __asm__("threadend:");
+#endif
+
+
        /* Allow lock record pools to be used by other threads. They
           cannot be deleted so we'd better not waste them. */
 
@@ -1664,6 +1673,20 @@ static void threads_table_dump(FILE *file)
 }
 #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
index a4f0eaf1a9e0c57c7a3f2e640661198cbcc41a3a..71b33e74c4f5e021a865728a01d47b8995889f07 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: threads.h 4921 2006-05-15 14:24:36Z twisti $
+   $Id: threads.h 4944 2006-05-23 15:31:19Z motse $
 
 */
 
@@ -205,10 +205,6 @@ void threads_interrupt_thread(java_lang_VMThread *);
 bool threads_check_if_interrupted_and_reset(void);
 bool threads_thread_has_been_interrupted(java_lang_VMThread *);
 
-#if defined(ENABLE_JVMTI)
-void threads_set_current_threadobject(threadobject *thread);
-#endif
-
 void threads_java_lang_Thread_set_priority(java_lang_Thread *t, s4 priority);
 
 void threads_cast_stopworld(void);
@@ -216,7 +212,9 @@ void threads_cast_startworld(void);
 
 void threads_dump(void);
 
-
+#if defined(ENABLE_JVMTI)
+void jvmti_get_threads_breakpoints(void **brks);
+#endif
 /******************************************************************************/
 /* Recursive Mutex Implementation for Darwin                                  */
 /******************************************************************************/
index 55f48b1b918ad4f743d73d05376cc1b167dc067d..dc5d2156cce6987a2480ec800a37f451a5776374 100644 (file)
@@ -1071,10 +1071,10 @@ bool vm_create(JavaVMInitArgs *vm_args)
 
 #if defined(ENABLE_JVMTI)
        if (jvmti) {
-               set_jvmti_phase(JVMTI_PHASE_ONLOAD);
-               agentload(agentarg, agentbypath, &handle, &libname);
+               jvmti_set_phase(JVMTI_PHASE_ONLOAD);
+               jvmti_agentload(agentarg, agentbypath, &handle, &libname);
        }
-       set_jvmti_phase(JVMTI_PHASE_PRIMORDIAL);
+       jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
 #endif
 
 
@@ -1277,8 +1277,8 @@ void vm_exit(s4 status)
        assert(class_java_lang_System->state & CLASS_LOADED);
 
 #if defined(ENABLE_JVMTI)
-       set_jvmti_phase(JVMTI_PHASE_DEAD);
-       if (jvmti) agentunload();
+       jvmti_set_phase(JVMTI_PHASE_DEAD);
+       if (jvmti) jvmti_agentunload();
 #endif
 
        if (!link_class(class_java_lang_System))