0

I am trying to figure out how to debug a python program that uses OS.fork() using Eclipse/PyDev. The basic problem is if I set a breakpoint in code after the fork(), it isn't clear if that breakpoint is honored in both the parent and child process that results from the fork(). When Eclipse is used for C/C++ programs using gdb, there are options that tell the debugger what to do in case of process forks (see: forking in eclipse cdt). However, I could find no equivalent explanation for PyDev.

When I look at the command that PyDev executes for a test program TestPyDev.py, which is

/Users/dnessett/.pyenv/versions/3.10.15/bin/python -u /Users/dnessett/.p2/pool/plugins/org.python.pydev.core_12.2.0.202409031913/pysrc/pydevd.py --multiprocess --protocol-http --print-in-debugger-startup --vm_type python --client 127.0.0.1 --port 0 --file /Users/dnessett/eclipse-workspace2/TestPyDev/TestPyDev.py

there is a --multiprocess option included. However, the multiprocess module has its own way of managing forked processes. It uses the OS.fork() method to fork a child process, but this is wrapped in a multiprocess method. I need something that allows direct calls to the OS.fork() method. (Just in case someone suggests using the multiprocess methods rather than the OS methods, I am not writing an application from scratch. I am debugging an existing application and rewriting its code is not an option).

I would like the debugger to create a debugger entry for both the parent and child process. This is possible in gdb by setting the "detach-on-fork-mode" option. There does not seem to be such an option in PyDev. So, either the functionality provided for that option in gdb exists automatically in PyDev or there is no way to debug both parent and child processes in the PyDev debugger.

If someone could point me to the appropriate PyDev documentation (if it exists) that discusses this situation, I would be grateful.

After more investigation, --multiprocess is an option for pydevd. I am not asking how to use remote debugging when the python code has OS.fork() in it. I am asking how to debug such a program when running it directly within eclipse.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.