Adding Debugging for setup.py

2,782 views
Skip to first unread message

Andy Frances

unread,
Dec 8, 2010, 1:56:53 PM12/8/10
to montrealpython
Hi Folks:

I am trying to set through a C-Extension with gdb. The extension (greenlets) has setup.py script.
How do I ensure the extension is built with a -g flag (debug)? Thanks in advance.

Cheers,
Andrew

Yannick Gingras

unread,
Dec 8, 2010, 2:26:38 PM12/8/10
to montrea...@googlegroups.com
On December 8, 2010, Andy Frances wrote:
> I am trying to set through a C-Extension with gdb. The extension (greenlets)
> has setup.py script.
> How do I ensure the extension is built with a -g flag (debug)? Thanks in
> advance.

Hey Andrew,
we're sprinting on the Packaging system tonight. Why don't you show
up so we can figure out:

1) how to do what you want;
2) improve the doc so it's going to be obvious for the next person who
need to do that.

Cheers,

--
Yannick Gingras
http://ygingras.net
http://montrealpython.org -- lead organizer
http://ajah.ca -- technical lead

signature.asc

Andy Frances

unread,
Dec 8, 2010, 2:57:05 PM12/8/10
to montrea...@googlegroups.com
Sounds good to me.

Thanks,
Andrew

Eric Parent

unread,
Dec 8, 2010, 3:23:37 PM12/8/10
to montrea...@googlegroups.com
Hey guys,

Can you make a little post with your findings on this discussion once
you've figure that out? I would have liked to attend to this sprint
but could not. :o(

I am, myself, trying to learn more about the distutils package and my
knowledge is quite elementary. Any additional info/tutorial would be
cool.

You know what? If the doc reflects that, could you just please point
out where to look for and I'll just grab it there; hope this would
avoid any redundancy and additional work for you. Be pragmatic and DRY
(don't repeat yourself) ! If this means I'll have to get into
BitBucket, then I'll do (and start leaving Git aside...).

Regards,

- Eric


2010/12/8 Andy Frances <af.sta...@gmail.com>:

> --
> Vous recevez ce message, car vous êtes abonné au groupe Google
> Groupes Montréal-Python.
> Pour envoyer un message à ce groupe, adressez un e-mail
> à montrea...@googlegroups.com.
> Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse
> montrealpytho...@googlegroups.com.
> Pour plus d'options, consultez la page de ce groupe :
> http://groups.google.com/group/montrealpython?hl=fr-CA
>

Alexandre Vassalotti

unread,
Dec 9, 2010, 12:03:58 AM12/9/10
to montrea...@googlegroups.com
2010/12/8 Andy Frances <af.sta...@gmail.com>:

You need to install a debug build of Python and run setup.py with it.
On a Debian or related distribution, just apt-get the "python-dbg"
package.

-- Alexandre

Alexandre Vassalotti

unread,
Dec 9, 2010, 12:08:56 AM12/9/10
to montrea...@googlegroups.com

Actually... if you just want the debugging symbol for gdb, you could
do "python setup.py build --debug" and that should pass the -g flag to
the compiler.

-- Alexandre

Andy Frances

unread,
Dec 9, 2010, 2:18:51 PM12/9/10
to montrea...@googlegroups.com
Hi Alexandre:

Thanks for your answer and you are right. I learnt that yesterday at the programming sprint. The real issue was learning how
to set break points in the extension. The extension involved was greenlet. Between today and tomorrow, I will write up a small
report.

Thanks
Andrew

On Thu, Dec 9, 2010 at 12:03 AM, Alexandre Vassalotti <alex...@peadrop.com> wrote:

--

Alexandre Vassalotti

unread,
Dec 9, 2010, 4:19:12 PM12/9/10
to montrea...@googlegroups.com
2010/12/9 Andy Frances <af.sta...@gmail.com>:

> Hi Alexandre:
> Thanks for your answer and you are right. I learnt that yesterday at the
> programming sprint. The real issue was learning how
> to set break points in the extension. The extension involved was greenlet.

My usual trick for this is to start a Python interpreter under gdb,
import the extension and then hit Ctrl-C to set the breakpoints in
gdb. If I can't debug from interpreter for some reason, then I specify
the breakpoints by filename:lineno before starting the interpreter and
let gdb insert the breakpoints when the extension is loaded at
runtime.

-- Alexandre

Andy Frances

unread,
Dec 10, 2010, 10:13:13 AM12/10/10
to montrea...@googlegroups.com
Hi Alexandre:

I have tried doing something to that effect but I had problems.

What we did was a bit more intrusive.

We altered greenlet.c and added a signal(getpid(), SIGUSR1)

recompiled.

in gdb set handle SIGUSR1 ignore

run

and that stops the code in the right spot and we can proceed from there

That said, the main thing I want to do is see how greenlets play with
the C stack and
if anything is done to PyEvalFrameEx() ?

Cheers,
Andrew

Reply all
Reply to author
Forward
0 new messages