c++perlgdbswigscript-debugging

debugging a shared library wrapped by SWIG in perl


I have wrapped my C/C++ code using SWIG in Perl. I have few segmentation fault because of the wrapped code. I am trying to use ddd with the Perl script but unfortunately even if I set a breakpoint on a line of the script ( the one calling C/C++ code ), ddd is not able to step in down to the C/C++ code.

Is there any way to set breakpoint into my C lib when I am debugging Perl code or do you know a good way/tool to debug the C lib when I am running this Perl script?

I am using Linux/gcc.


Solution

  • I did a simple thing. I called the gdb directly on perl interpreter.

        gdb /usr/bin/perl
        (gdb) r myscript
        #block the script someway or rerun it
        (gdb) b whatever_my_function
    

    It seems that once the scipt is running shared memory is also loaded in memory. Once this happened I have available all information, functions and breakpoint for debugging.