Flags to debug python C extensions.
I often find myself debugging python C extensions from gdb, but usually some variables are hidden because aggressive optimizations that distutils sets by default. What I did not know, is that you can prevent those optimizations by passing flags
config.add_extension('foo',
sources=['a.c'],
# add this for gdb debug
extra_compile_args=['-O0 -fno-inline'])
sources=['a.c'],
# add this for gdb debug
extra_compile_args=['-O0 -fno-inline'])
and your extension becomes much easier to debug from gdb.
August 18th, 2010 17:38
Nice tip!
August 19th, 2010 12:16
You may also want to add ‘-g’ even in testing release builds
August 19th, 2010 16:59
-O0 can cause some other issues. -O1 is typically a better choice if the code is moderately or more complex.
August 24th, 2010 13:34
What about fortran extensions, is there any way of sending these options (or -pg) to gfortran?
May 10th, 2011 14:20
You’re the gretaset! JMHO