Ever used JDWP to debug a JNI invocation based app?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrew_Biggs
Posted On:   Wednesday, March 31, 2004 08:35 PM

I am attempting to use JDWP to debug some java code that gets invoked via the JNI invocation interface. The following is the code I use to instantiate the JVM: // create JVM and get vtable pointer (mEnv) JavaVMInitArgs vm_args; JavaVMOption options[5]; options[0].optionString = "-Djava.class.path=" USER_CLASSPATH; options[1].optionString = "-Xdebug"; options[2].optionString = "-Xms32m"; options[3].optionString = "-Xmx48m"; options[4].optionString = "-Xrunjdwp:transport=dt_shmem,server=y,address=foobar,suspend=y"; vm_args.version = JNI_VERSION_1_4; vm_args.options = options; vm_args.nOptions = 5; vm_args.   More>>

I am attempting to use JDWP to debug some java code that gets invoked via the JNI invocation interface. The following is the code I use to instantiate the JVM:

			
// create JVM and get vtable pointer (mEnv)
JavaVMInitArgs vm_args;
JavaVMOption options[5];
options[0].optionString = "-Djava.class.path=" USER_CLASSPATH;
options[1].optionString = "-Xdebug";
options[2].optionString = "-Xms32m";
options[3].optionString = "-Xmx48m";
options[4].optionString = "-Xrunjdwp:transport=dt_shmem,server=y,address=foobar,suspend=y";
vm_args.version = JNI_VERSION_1_4;
vm_args.options = options;
vm_args.nOptions = 5;
vm_args.ignoreUnrecognized = JNI_TRUE;
jint res = JNI_CreateJavaVM(&sJvm, (void**)&sEnv, &vm_args);


The problem is that the -Xrunjdwp is causing the JNI_CreateJavaVM() method to fail with an "Access Violation" exception (as per the VC++ debugger). I know this only because if I remove the -Xrunjdwp option from the options list, leaving all the others, everything works great. But of course, then I can't debug my app remotely. Anyone else have this problem, or see any glaring flaws in my code here?


BTW - I'm using VC++ 6.0, and Sun's Java 2 SDK 1.4.1_03.


Thanks!

   <<Less

Re: Ever used JDWP to debug a JNI invocation based app?

Posted By:   Marc_Deveaux  
Posted On:   Sunday, April 4, 2004 09:29 PM

Having same problem except i'm using JNI_VERSION_1_2 and the following Jbuilder settings, but the runjdwp link is the problem.


options[++p].optionString = "-Xdebug";

options[++p].optionString = "-Xnoagent";

options[++p].optionString = "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3999";

Also tried doing LoadLibraries on jdwp.dll and dt_socket.dll from the JDK/bin folder, to no avail.

jdwp has an JVM_OnLoad entry point which we may need to envoke somehow from JNI, still looking.

About | Sitemap | Contact