# The following was supposedly scribed by # Nick Wehr # on Thursday 24 February 2005 02:20 am:
Sorry to leave you hanging on the inline-perl list.
I've been looking all over the man pages for some information on debugging C code from within Inline. I've been using if (DEBUG) lines all over tracking down my problem code... is there an easier way to do this?
To be portable: ------------------------ /*#define DEBUG_PRINT*/
#ifdef DEBUG_PRINT #define dbg_p(x) printf x #else #define dbg_p(x) #endif
... free(p); dbg_p(("p free... DESTROY complete\n")); ... ------------------------
Can I [cross fingers] somehow use a debugger? If not, what have you guys done to make this task less painful.
Hmm. How do you use a debugger on XS code? If you know that, you're halfway there. Then you just have to get Inline to not CLEAN_AFTER_BUILD. As far as automagic c-level debugging support from within Inline, I don't think there's anything (though perldoc Inline::C makes some reference to an OPTIMIZE => '-g' setting for use with gdb.)
To use gdb, I gather that perl, itself, needs to have been compiled with '-g'. There's a helpful discussion of debugging XS in "Extending and Embedding Perl" by Jenness and Cozens (published by Manning).
Also 'sv_dump()' and the Devel::Peek module's 'Dump()' function allow you to see what's inside your perl structures - which can be a useful debugging aid (depending on the nature of the problem).
Cheers, Rob