Zhang Bo wrote:
Hi, I have a question during debugging ruby c++ extension. For example,
I created a c++ class who is wrapped through swig. Now I’d like to
invoke the class via ruby. Meanwhile I’d like to debug it via gdb. How
to step through it?
Assuming (1) you have successfully compiled your SWIG-based extension to
a library lib/foo.so, and (2) you have a test ruby script that uses your
C+±based class called test_foo.rb, run gdb from a command
$> gdb ruby
(gdb) run -Ilib test_foo.rb
That will execute ruby with the arguments “-Ilib test_foo.rb”. You can
then set breakpoints, step through C/C++ statements etc as normal in
gdb. You can set breakpoints on the C++ method wrappers in your
extension this way.