src/vm/vm.c(usage): added information for jvmti agent for jdwp
[cacao.git] / src / cacao / cacao.c
index 154d1a9994944947ba0c69bb255a13751d69a32c..19bfeccdfdc7f7d8016cadb0ad5e3f9aededb20d 100644 (file)
@@ -31,7 +31,7 @@
             Philipp Tomsich
             Christian Thalinger
 
-   $Id: cacao.c 4661 2006-03-21 00:04:59Z motse $
+   $Id: cacao.c 4954 2006-05-25 21:59:49Z motse $
 
 */
 
@@ -50,7 +50,8 @@
 #if defined(ENABLE_JVMTI)
 #include "native/jvmti/jvmti.h"
 #include "native/jvmti/cacaodbg.h"
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+
+#if defined(ENABLE_THREADS)
 #include <pthread.h>
 #endif
 #endif
@@ -111,7 +112,7 @@ static char *getmainclassnamefromjar(char *mainstring)
        if (!m)
                throw_main_exception_exit();
 
-       s = javastring_new_char(mainstring);
+       s = javastring_new_from_ascii(mainstring);
 
        (void) vm_call_method(m, o, s);
 
@@ -167,7 +168,7 @@ static char *getmainclassnamefromjar(char *mainstring)
        if (!m)
                throw_main_exception_exit();
 
-       s = javastring_new_char("Main-Class");
+       s = javastring_new_from_ascii("Main-Class");
 
        o = vm_call_method(m, o, s);
 
@@ -180,6 +181,7 @@ static char *getmainclassnamefromjar(char *mainstring)
 void exit_handler(void);
 
 
+
 /* main ************************************************************************
 
    The main program.
@@ -188,9 +190,6 @@ void exit_handler(void);
 
 int main(int argc, char **argv)
 {
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
-       void *dummy;
-#endif
        s4 i;
        
        /* local variables ********************************************************/
@@ -198,17 +197,6 @@ int main(int argc, char **argv)
        JavaVMInitArgs *vm_args;
        JavaVM         *jvm;                /* denotes a Java VM                  */
 
-
-#if defined(NDEBUG)
-       /* motse: for jdwp/jvmti debugging*/
-       for (i=0; i<argc; i++)
-               fprintf(stderr,"argument string[%d]: %s\n",i,argv[i]);
-#endif
-
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
-       stackbottom = &dummy;
-#endif
-       
        if (atexit(vm_exit_handler))
                throw_cacao_exception_exit(string_java_lang_InternalError,
                                                                   "Unable to register exit_handler");
@@ -225,11 +213,11 @@ int main(int argc, char **argv)
        
        /* load and initialize a Java VM, return a JNI interface pointer in env */
 
-       JNI_CreateJavaVM(&jvm, (void **) &_Jv_env, vm_args);
+       JNI_CreateJavaVM(&jvm, (void *) &_Jv_env, vm_args);
 
 #if defined(ENABLE_JVMTI)
-       if (dbgprocess && jvmti && jdwp) /* is this the parent/debugger process ? */
-               set_jvmti_phase(JVMTI_PHASE_START);
+       pthread_mutex_init(&dbgcomlock,NULL);
+       if (jvmti) jvmti_set_phase(JVMTI_PHASE_START);
 #endif
 
        /* do we have a main class? */
@@ -319,24 +307,10 @@ int main(int argc, char **argv)
 #endif
                /*class_showmethods(currentThread->group->header.vftbl->class); */
 
-
-
 #if defined(ENABLE_JVMTI)
-               /* if this is the parent process than start the jdwp listening */
-               if (jvmti || jdwp) {
-                       fprintf(stderr, "jdwp/debugger set herewego brkpt %p\n",&&herewego);
-                       setsysbrkpt(HEREWEGOBRK,&&herewego);
-                       if (dbgprocess && jdwp) cacaodbglisten(transport); 
-               }
-
-               
-               if (!dbgprocess) {
-                       fprintf(stderr,"debuggee: herewe go\n");
-                       fflush(stderr);
-               }
+               jvmti_set_phase(JVMTI_PHASE_LIVE);
 #endif
-               /* here we go... */
-       herewego:
+
                (void) vm_call_method(m, NULL, oa);
 
                /* exception occurred? */
@@ -355,8 +329,10 @@ int main(int argc, char **argv)
                vm_exit(status);
        }
 
-       /************* If requested, compile all methods ********************/
 
+       /* If requested, compile all methods. *************************************/
+
+#if !defined(NDEBUG)
        if (compileall) {
                classinfo *c;
                methodinfo *m;
@@ -387,7 +363,7 @@ int main(int argc, char **argv)
                                        if (!(c->state & CLASS_LINKED)) {
                                                if (!link_class(c)) {
                                                        fprintf(stderr, "Error linking: ");
-                                                       utf_fprint_classname(stderr, c->name);
+                                                       utf_fprint_printable_ascii_classname(stderr, c->name);
                                                        fprintf(stderr, "\n");
 
                                                        /* print out exception and cause */
@@ -408,10 +384,10 @@ int main(int argc, char **argv)
                                                if (m->jcode) {
                                                        if (!jit_compile(m)) {
                                                                fprintf(stderr, "Error compiling: ");
-                                                               utf_fprint_classname(stderr, c->name);
+                                                               utf_fprint_printable_ascii_classname(stderr, c->name);
                                                                fprintf(stderr, ".");
-                                                               utf_fprint(stderr, m->name);
-                                                               utf_fprint(stderr, m->descriptor);
+                                                               utf_fprint_printable_ascii(stderr, m->name);
+                                                               utf_fprint_printable_ascii(stderr, m->descriptor);
                                                                fprintf(stderr, "\n");
 
                                                                /* print out exception and cause */
@@ -424,10 +400,12 @@ int main(int argc, char **argv)
                        }
                }
        }
+#endif /* !defined(NDEBUG) */
 
 
-       /******** If requested, compile a specific method ***************/
+       /* If requested, compile a specific method. *******************************/
 
+#if !defined(NDEBUG)
        if (opt_method != NULL) {
                methodinfo *m;
 
@@ -469,6 +447,7 @@ int main(int argc, char **argv)
        }
 
        vm_shutdown(0);
+#endif /* !defined(NDEBUG) */
 
        /* keep compiler happy */