I don't know the solution yet and I have posted a question on stackoverflow here. If anyone knows solution please either answer at stackoverflow or drop a comment here.
Basic story is there is C/C++ code which creates a JVM and loads and loads/executes some classes. I don't have any control over how the process is started. This process creates a JVM. It is this process to which I want to attach JDB or other java debuggers such as eclipse.
Long story. I am working on Java bindings for webkit. Specifically Webkit GTK V2. For version 2, webkit fires a web processes internally and communicates with it. To allow access to DOM, you can write extensions which are loaded by the web process dynamically.
I wrote the extension that creates instance of JVM and loads my classes. This works as expected. Now the problem is to debug the Java code I have to solely rely on println or log statements. If I run jps, web process is displayed as one the processes. So there is something in the world that knows its related to JVM even if everything is dynamic.
I would like to connect JDB to this process and debug my java code. If you know how to connect JDB to running process - which is not started with Java command, please let me know.
After some research,it turned out that solution was very simple. When you create VM, just pass the debugger option as follows. Connect debugger to port 9836 and you in the debugger.
JavaVMOption options[3];
options[0].optionString = ;
options[1].optionString = "-Xdebug";
options[2].optionString = "-agentlib:jdwp=transport=dt_socket,server=y,address=9836,
