Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA debugger follow child process

We have some Java code that starts a new process using the following code: Runtime.getRuntime().exec(command); I'd like to be able to tell the debugger that it should follow the child process like you can do with GDB as documented here by issuing the set follow-fork-mode child command.

Is there something equivalent in the IntelliJ IDEA Java debugger? If so how do I configure it?

Thanks

like image 828
Andrew Jessop Avatar asked Oct 23 '25 14:10

Andrew Jessop


1 Answers

Java doesn't provide an automated way to debug processes and their child processes. One needs to run the child process with the JVM options to enable debugging. IDEA Remote Debug configuration will suggest the proper options to use. Once the process is started with the appropriate options you can connect to it from IDEA with the Remote Debug configuration.

Sample options:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

You may want to start with suspend=y so that the execution is suspended until you connect with the debugger.

like image 97
CrazyCoder Avatar answered Oct 26 '25 03:10

CrazyCoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!