Is there a way to interface the Perl debugger API which perl is using to control its debugging programmatically?
The default Perl debugger was not designed with a clean API to interact with, so the easiest way is probably not to use it, but to use Devel::ebug, which offers an API to an alternative debugger. You can also trigger the debugger from inside your code, calling an interactive debugger session, with Enbugger.
It's all in the perldebug, perldebguts, and DB documentation.
In addition, I've written a Creating a Perl Debugger which should get you started. I have a section on custom Perl debuggers in Mastering Perl too.
You can read about the perl debugger at perldoc perldebug and perldoc perldebtut. You can invoke the debugger with the -d
option, i.e. perl -d myscript.pl
.
See "Programming Perl" 20.5.1 -> "Writing your own debugger", also see perldoc perlvar $PERLDB.
What you want to do is to implement the DB::DB() sub.