As part of my
top-secret project (more about it later), I needed to debug some Perl/XS
code I wrote as part of a Module::Build module. But I could not figure out
how to add the debugging flags to the
Well, after I read the source code, and perldocs, I figured it out:
./Build code extra_compiler_flags="-g"
extra_compiler_flags can contain any other flag you need depending on your compiler. The flags are passed to ExtUtils-CBuilder, which uses it to invoke the C compiler.
Now for the gdb part. Put this into a cmds.gdb file, and type gdb
--command=cmds.gdb
set breakpoint pending on
set args -Mblib t/07-assign-string-to-ref.t
b XS_XSTest_assign_string_to_ref
r
"set breakpoint pending on" makes gdb not ask for "Make breakpoint pending on future shared library load? (y or [n])", which is assumed to be "n" in the context of the --command script. -Mblib is for using the files installed under blib/. t/07... is the test file (You wrote one, right?), os substitute it to the correct location.
Finally, XS_XSTest_assign_string_to_ref is the XS function to
be debugged, whose name can be found at the lib/*.c that is generated
from the
I couldn't find this information anywhere else on the Intarwebs, so I hope you find it useful.
Tip: Debugging Perl XS Code with Module::Build 0 Comments More | Login | Reply /