
# save this file as .debug and execute this as:
# gdb -command=.debug
# or if you prefer gui
# ddd -command=.debug
#
# NOTE: Adjust the path to the perl executable
# also this perl should be built with debug enabled
file /usr/bin/perl

# If you need to debug with gdb a live script and not a library, you
# are going to have a hard time to set any breakpoint in the C code.
# the workaround is force Inline to compile and load .so, by putting
# all the code in the BEGIN {} block and call Inline->init from there.
#
# you also need to prevent from Inline deleting autogenerated .xs so
# you can step through the C source code, and of course you need to
# add '-g' so .so won't be stripped of debug info
#
# here is a sample perl script that can be used with this gdb script
#
# test.pl
# #-----#
# use strict;
# use warnings;
#
# BEGIN {
#     use Inline Config =>
#         #FORCE_BUILD => 1,
#         CLEAN_AFTER_BUILD => 0;
# 
#     use Inline C => Config =>
#         OPTIMIZE => '-g';
# 
#     use Inline C => <<EOI;
#     void my_bp() {
#         dTHX;
#         Perl_warn(aTHX_ "starting debug\n");
#     }
# EOI
# 
#     Inline->init;
# 
# }
#
# my_bp();

tb main
# NOTE: adjust the name of the script that you run
run test.pl

# when Perl_runops_debug breakpoint is hit Inline will already load
# the autogenerated .so, so we can set the bp in it (that's only if
# you have run 'Inline->init' inside the BEGIN {} block

b S_run_body
continue
b Perl_runops_debug
continue

# here you set your breakpoints
b my_bp
continue
