X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fvm.c;h=a4c334dedc6abc65cf2a703eceebdb7b8abc8f05;hb=512e8d95ab6004592f83d8fcfb46f959944caa42;hp=3a132e03b9f79e3ef25a62bd077769a538c1c700;hpb=cee5f6d11ea4eec3dea702ba8b268fd90d3c66a8;p=cacao.git diff --git a/src/vm/vm.c b/src/vm/vm.c index 3a132e03b..a4c334ded 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -68,6 +68,9 @@ #include "vm/jit/asmpart.h" #include "vm/jit/profile/profile.h" +#if defined(ENABLE_JVMTI) +#include "native/jvmti/cacaodbg.h" +#endif /* Invocation API variables ***************************************************/ @@ -191,6 +194,8 @@ enum { #ifdef ENABLE_JVMTI OPT_DEBUG, + OPT_XRUNJDWP, + OPT_NOAGENT, OPT_AGENTLIB, OPT_AGENTPATH, #endif @@ -276,6 +281,8 @@ opt_struct opts[] = { { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P }, #ifdef ENABLE_JVMTI { "Xdebug", false, OPT_DEBUG }, + { "Xnoagent", false, OPT_NOAGENT }, + { "Xrunjdwp", true, OPT_XRUNJDWP }, #endif { "Xms", true, OPT_MS }, { "ms", true, OPT_MS }, @@ -401,7 +408,11 @@ static void Xusage(void) puts(" -Xss set the thread stack size (default: 128kB)"); puts(" -Xprof[:bb] collect and print profiling data"); #if defined(ENABLE_JVMTI) - puts(" -Xdebug enable remote debugging"); + /* -Xdebug option depend on gnu classpath JDWP options. options: + transport=dt_socket,address=,server=(y|n),suspend(y|n) */ + puts(" -Xdebug enable remote debugging\n"); + puts(" -Xrunjdwp transport=[dt_socket|...],address=,server=[y|n],suspend=[y|n]\n"); + puts(" enable remote debugging\n"); #endif /* exit with error code */ @@ -503,6 +514,7 @@ bool vm_create(JavaVMInitArgs *vm_args) nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE); #endif + /* set the bootclasspath */ cp = getenv("BOOTCLASSPATH"); @@ -547,6 +559,15 @@ bool vm_create(JavaVMInitArgs *vm_args) heapstartsize = HEAP_STARTSIZE; opt_stacksize = STACK_SIZE; + +#if defined(ENABLE_JVMTI) + /* initialize JVMTI related **********************************************/ + jvmtibrkpt.brk=NULL; + jvmtibrkpt.num=0; + jvmtibrkpt.size=0; + jdwp = jvmti = dbgprocess = false; +#endif + /* initialize properties before commandline handling */ if (!properties_init()) @@ -642,15 +663,39 @@ bool vm_create(JavaVMInitArgs *vm_args) #if defined(ENABLE_JVMTI) case OPT_DEBUG: - dbg = true; + jdwp=true; + break; + case OPT_NOAGENT: + /* I don't know yet what Xnoagent should do. This is only for + compatiblity with eclipse - motse */ + break; + case OPT_XRUNJDWP: transport = opt_arg; + j=0; + while (transport[j]!='=') j++; + j++; + while (jstate & CLASS_LOADED); #if defined(ENABLE_JVMTI) - set_jvmti_phase(JVMTI_PHASE_DEAD); - agentunload(); + if (dbgprocess) { + set_jvmti_phase(JVMTI_PHASE_DEAD); + if (jvmti) agentunload(); + } #endif if (!link_class(class_java_lang_System)) @@ -1222,9 +1284,12 @@ void vm_exit(s4 status) void vm_shutdown(s4 status) { #if defined(ENABLE_JVMTI) - agentunload(); + if (dbgprocess) { + set_jvmti_phase(JVMTI_PHASE_DEAD); + if (jvmti) agentunload(); + ipcrm(); + } #endif - if (opt_verbose || getcompilingtime || opt_stat) { log_text("CACAO terminated by shutdown"); dolog("Exit status: %d\n", (s4) status); @@ -1246,6 +1311,12 @@ void vm_shutdown(s4 status) void vm_exit_handler(void) { +#if defined(ENABLE_JVMTI) + if (jvmti && jdwp) set_jvmti_phase(JVMTI_PHASE_DEAD); + if (jvmti) agentunload(); + ipcrm(); +#endif + #if !defined(NDEBUG) if (showmethods) class_showmethods(mainclass);