5

I have a project written in Perl with XS components written in C++. I am debugging with command like

perl -d perl_file.pl

How I can use the debugger to jump from Perl into those C++ files?

Borodin
  • 126,100
  • 9
  • 70
  • 144
s_m
  • 129
  • 8
  • Do you mean you are making calls from the Perl code into the C++ code? How? – reinierpost Sep 10 '15 at 09:03
  • I mean the Perl scripts call C++ files. But I don't know how to keep debugging and get access to those C++ files. – s_m Sep 10 '15 at 09:22
  • You can call an executable, but how do you call (run/invoke) a source file? – legends2k Sep 10 '15 at 09:22
  • @legends2k from a source file. – s_m Sep 10 '15 at 09:25
  • Please answer the question and explain how you are calling the C++ code from within Perl. Example code is always helpful – Borodin Sep 10 '15 at 09:34
  • @borodin I am sorry to say that I got this project from someone else, unable to contact the guy. This project contains Perl and C++ files (c++ is stored in XS folder). As far as I know now, I run debugging start from perl_file.pl, and keep jumping into other Perl files. I am looking for how to call C++ file from the debugging process. There is an important calculation in C++ file which I want to know, but I am unable to call those C++ file. – s_m Sep 10 '15 at 09:48
  • Ah so it's XS code. That makes a lot more sense. The Perl debugger won't let you step through the C code, and the best way to diagnose problems there is to add `printf` statements to trace the values during the execution – Borodin Sep 10 '15 at 09:52
  • To debug C++ code, you need a C++ debugger, e.g. `gdb`. – ikegami Sep 10 '15 at 15:11

1 Answers1

2

You could use GNU Project Debugger.

gdb /usr/bin/perl
    r perl_file.pl

See perlhacktips:

Also see:

Community
  • 1
  • 1
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133