andye has asked for the wisdom of the Perl Monks concerning the following question:
I'm using Inline::pdlpp to write some C routines, embedded in my Perl code.
My problem: I'm getting a segfault that I can't track down. I've looked through my code with particular attention to what the pointers are doing, and it looks ok. But of course it might not be. Pdlpp generates quite a bit of C that wraps round my functions, the problem could be there, too.
My question: how best to track down this segfault?
It's been a few years (like, about 15 years) since I did any C programming, but I've been doing some revision and it seems like the standard technique is to load the core file into gdb (the debugger) and go from there, or to run it under something like Valgrind which will tell me where I'm going wrong.
But: I don't know how to do those things, given that the code is itself embedded in a Perl script. Right now I'm not even getting a core file that I could load into gdb.
So, any suggestions greatly appreciated. As you can probably tell I'm fairly new to this area so apologies if I'm missing something obvious...
I'm using Mac OS X on Intel BTW, if that makes a difference to choice of tools.
Best wishes, andye
Update: I've read this node: Debugging Inline C programs but I'm still some way from being enlightened... I need to recompile perl itself with '-g'? Sounds like a pain... Currently I'm passing Config => OPTIMIZE => '-g' to Inline::Pldpp, but I'm not sure what my next step is meant to be...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Debugging segfault in inline C (actually inline pdlpp, but probably the same principle)
by syphilis (Archbishop) on Apr 20, 2007 at 14:51 UTC | |
by andye (Curate) on Apr 20, 2007 at 15:00 UTC |