Philipp Tomsich
Christian Thalinger
- $Id: cacao.c 4874 2006-05-05 14:36:18Z edwin $
+ $Id: cacao.c 4944 2006-05-23 15:31:19Z motse $
*/
#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
void exit_handler(void);
+
/* main ************************************************************************
The main program.
int main(int argc, char **argv)
{
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
- void *dummy;
-#endif
s4 i;
/* local variables ********************************************************/
JavaVMInitArgs *vm_args;
JavaVM *jvm; /* denotes a Java VM */
-#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");
/* 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);
+ jvmti_set_phase(JVMTI_PHASE_START);
#endif
/* do we have a main class? */
/*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);
+ /* start the jdwp listening thread*/
+ if (jdwp) {
+ log_text("cacao vm - init VMjdwp");
+ if (!jvmti_VMjdwpInit()) exit(1);
+ setup_jdwp_thread(transport);
+ if (!suspend) {
+ fprintf(stderr,"suspend false -> continue debuggee\n");
+ } else {
+ fprintf(stderr,"suspend true -> do no continue debuggee(todo)\n");
+ /* XXX todo*/
+ }
}
- if (!dbgprocess) {
- fprintf(stderr,"debuggee: herewe go\n");
- fflush(stderr);
- }
- /* here we go... */
- herewego:
+ jvmti_set_phase(JVMTI_PHASE_LIVE);
#endif
+
(void) vm_call_method(m, NULL, oa);
/* exception occurred? */
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 */
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 */