开发者

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.

开发者_JAVA百科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.


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.


I've only used SWIG for calling C++ from TCL, and debugged it using Visual Studio, but the same ideas should apply for your case as well. I'll describe what I've done to debug, hopefully you can figure out how to apply it to your situation.

  • Build a debug version of the C++ module
  • Make sure the TCL script is including the debug version (the path in the TCL load command points to the debug version of the module)
  • Place breakpoints in the C++ code
  • Invoke the TCL script through the Visual Studio debugger; for instance the command used is tclsh85.exe MyScript.tcl

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜