Unfamiliarity makes things look harder than they are... (Debugging Python extensions on Linux easier than Win32)
Written by
on
in
Snaking,
Tuxedo.
I sat down intending to do an hour or so of playing with ctypes for OpenGL... 5 hours ago. I can't really begrudge the time, though, because beyond finding a number of minor problems with ctypes on amd64, I learned something I've been avoiding for a while now; learning how to debug C extensions on Linux. It's actually something I'm going to need for work over the next week or so (as I track down the last few annoying (and core-dumping) bugs in Cinemon 1.0).
Of course, I know how to debug C extensions on Windows, I've even got patches that let Python distutils compile with symbols for a non-debug extension. But on Linux and FreeBSD I've never bothered with the core files... to the point I hadn't even realised that they weren't produced on my dev machine! I figured it would be a PITA, as on Windows, to get the debug symbols built into my extensions, so I never bothered with them.
Turns out distutils on Linux has a handy-dandy -g flag, which adds the debug symbols to the extension you're building. Once you have that, a little reading tells you that from a bash prompt you do:
ulimit -c unlimitedto turn on core file production (likely want to put that in your .bash_profile if you are a developer).
After that,
gdb python coregets you into the debugger, where you can do post-mortem debugging of your crashing application. Unfortunately, the process for doing live debugging is rather annoying looking (to the point that I keep thinking "they must be joking" as I read the FAQ on it), but I'm okay with post-mortems for now, it's what I normally do anyway.
Comments
Comments are closed.
Pingbacks
Pingbacks are closed.
Eric on 04/18/2005 8:48 a.m. #
A friend of mine instilled words of wisdom in me when we were working on his car. After struggling with this one thing for an hour or so, my dad came into the garage and said, "What are you doing, use this to do that", and handed us some tool we'd never seen before. My friend said, "I guess it's true, if you're working too hard, you're using the wrong tool."