debuging in shared library (using gdb or ddd)

Travis Oliphant olipt at mayo.edu
Thu Nov 4 17:51:27 EST 1999


> Hi!
> 
> How can I debug a shared library module imported into python
> 
> with gdb or ddd debugger ?

I use gdb regularly to debug shared libraries imported into python:  One
way to do it is to start python, import your shared module and then in a
separate shell, run gdb and attach to the python process.  This freezes
the python processes as it is now under control of gdb.  You can then set
break points as you'd like and then enter "c" (continue) in gdb which will
start the python interpreter going again.  You can enter commands into the
interpreter and when the break point is hit it will stop and your gdb
session will be ready for commands.  This is a back-and-forth method, but
it works.

The other method that used to work for me (but doesn't anymore for some
unknown reason) is to start python from within gdb, import the module of
interest, quit python (so you are back at the gdb prompt), insert
breakpoints into the module of interest (which gdb is now aware of),
restart python and debug the shared module by running some commands in it.

As you can tell, I'm not a gdb expert, as I've typically learned just
enough to do what I want, and not learned the most elegant ways to do
things.  So, there may be better ways to do it, but the ways I've
described have worked well for me.

Travis






More information about the Python-list mailing list