Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: debugging perl module written in C

by rg0now (Chaplain)
on Nov 19, 2008 at 13:36 UTC ( [id://724578]=note: print w/replies, xml ) Need Help??


in reply to Re^2: debugging perl module written in C
in thread debugging perl module written in C

I am not sure I understand what you ask. When I say "recompile with -g -O0, I mean that you must set the compiler flags so that the compiler emits code with debugging symbols included and optimization turned off.

To clarify a bit: you call C code from Perl in the following way. Since C code can not be directly called from Perl, first you must compile the C code into a shared library, which then will be dynamically linked to your Perl executable when running your script. This makes it possible to switch the execution thread from Perl to C and vice versa. This means that you first must compile the C code to a shared library, only after this you can call into it from Perl. If you turn optimization on, certain code segments, lines or functions will be optimized away from the resultant library, and this makes stepping through the code by the debugger clumsy.

So here is what you need to do: find the flags passed to the compiler when building the code (on UNIX, this is the Makefile, on Windows, I'm not sure, there must be some project file somewhere), change the compiler flags to "-g -O0", rebuild the code from scratch and use the debugger.

If you clarify your problem and environment a bit more deeply, maybe I could be of some more help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://724578]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found