java - Using Eclipse to debug a JNI / C++ library and processes -
i'm have trouble understanding how debug both c++ code , associated forked java process. i've got c++ code forks off .jar swing file. opens java window , waits user input...
i've created c++ eclipse project compiles both c++ , java sources. both compilations use -g compiler flag. when run in debug mode can step through initial c++ code. after fork statement (that launches java swing code) cannot step through java code. next step goes directly statement of fork. i'm using jni calls call c++ shared object lib created @ compile time.
i've read other posts folks starting java application calls c++ through jni calls. i'm doing opposite. start c++ code forks java process.
either way seems somehow need attach forked java process current c++ eclipse debug session. how go doing that? simple example appreciated.
you have create java vm in c++ command line options java debugging. run java listener debugging pass following options (if port 8000 not free, can choose address)
-xdebug -xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
then in eclipse debugging dialog create "remote java application". use address in options in "port" field in "connection properties" (8000 default). set breakpoints in java code , press "debug". if need debug code happens @ java startup can use suspend=y
in options, vm wait connection debugger before starting up.
if cannot change options java process you're out of luck.
edit: documentation http://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html tells me -xrun
-agentlib
. didn't know because i've been using above options years , haven't stopped working yet.
Comments
Post a Comment