Debug an external started process

17 views
Skip to first unread message

Henning Bredel

unread,
Nov 8, 2009, 11:22:50 AM11/8/09
to Winpdb
Hey there,

I'd like to debug a simulated application.

The script I've to start collects a lot of information before
launching the actual application (which I'd like to debug) in an extra
process. This is done via `os.execlp'. After the start script has
started the external command (also an application written in python)
the application starts up and the debugger finishes ..

I'm not sure if that is possible, but is there a way to attach the
debugger on a script already running under its own pid? However, I'd
be curious if there is a way to handle such issues at all.

Thanks for your advice

Henning

Michael McNeil Forbes

unread,
Jan 1, 2010, 4:07:31 PM1/1/10
to Winpdb
I have been experimenting with one possible solution based on
http://code.activestate.com/recipes/576515/. The idea is to register
a handler for one of the user signals signal.SIGUSR1 such as the
following:

def _rpdb2_handler(sig, frame):
<get password somehow, maybe store it when the original script is
started...>
rpdb2.start_embedded_debugger(password)

Then, all you need to know is the pid of the process that you want to
debug. When you want to debug it, send it the signal, either from the
shell (you may need to print out signal.SIGUSR1 so you know what it
is. It is 30 on my machine.)

$ kill -30 pid

or from another python process

os.kill(pid, signal.SIGUSR1)

Then you can attach to this as usual.

I am not sure how portable this approach is, but it should work fine
on all *nix and Mac OS X based systems.

Michael.
On Nov 8 2009, 9:22 am, Henning Bredel <henningbre...@googlemail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages