Protocol::PerlDebugCLI - generate and process events for interacting with the Perl debug interface
version 0.002
use Protocol::PerlDebugCLI; my $deb = Protocol::PerlDebugCLI->new; # Attach handlers for the events that we're interested in, # anything else will be quietly ignored $deb->add_handler_for_event( breakpoint => sub { warn "Breakpoint reached\n"; }, ); # Set a breakpoint and continue execution $deb->request_breakpoint( file => 'script.pl', line => 17, ); $deb->request_continue;
This is an abstract implementation for interacting with the perl debugger. It parses the debugger output (provided via the "on_read" method) and and generates events, similar in concept to SAX.
It also provides abstract methods for generating commands to drive the debugger; by hooking the write event a companion class or subclass can drive the debugger without knowing the details of the protocol.
write
This class is not intended to be used directly - it deals with the abstract protocol and requires additional code to deal with the transport layer (this could be through sockets, via the RemotePort= PERLDBOPTS flag, or on STDIN/STDOUT/TTY for a forked perl -d process).
perl -d
See Net::Async::PerlDebugCLI for an implementation of a transport layer using RemotePort, and Tickit::Debugger::Async for a Tickit-based terminal debugging application.
Other similar classes for interacting with the debugger are listed in the "SEE ALSO" section.
Instantiate a new object.
Attempt to send the next queued request to the debugger.
Expects the caller to have checked whether there are any requests pending, and will raise an exception if this is not the case.
Returns true if there are queued requests.
Accessor for the current state.
Will raise an exception if attempting to set the state to the same value as it had previously.
Parse variable dump output, typically from v or x commands.
Parse code context, which consists of the current active line and a few surrounding lines.
At a breakpoint we start with the spec, then get line(s) of code
Should be called by the transport layer when data is available for parsing.
Expects the following parameters:
$buffref - a scalar reference to the current read buffer. Any parseable data will be extract from this buffer, modifying in-place. If there is insufficient data to parse a full line then there may be some data left in this buffer on return, and the transport layer should call us again after reading more data (and not before).
$eof - a flag indicating that no further data is forthcoming. When this is set we attempt to parse any trailing data and then go through any required cleanup before returning.
Returns true if we're ready to send the next request (i.e. we're at a prompt).
Request a full stack trace.
Request a dump of all vars in the current scope.
Request information about the current line (i.e. next line to be executed).
Step into the current line.
Step over the current line.
Continue execution.
Set a breakpoint on the requested line.
Clear the given breakpoint.
Expects the following named parameters:
line - (optional) line number to clear breakpoints from
If no line is provided, will clear all existing breakpoints.
Restart the current program.
Request a watch on the given variable.
Queue the given command.
Invokes a write event, requesting the given data be written to the underlying transport.
Debug::Client - provides a similar interface to the perl debugger, including code to handle the listening socket. Probably a good alternative if you want a synchronous rather than event-driven interface.
Pro Perl Debugging, by Andy Lester and Richard Foley (http://www.apress.com/9781590594544), provides a remoteport.pl script which again offers a synchronous interface to the remote debugger port.
Pro Perl Debugging
Tom Molesworth <cpan@entitymodel.com>
Copyright Tom Molesworth 2011-2012. Licensed under the same terms as Perl itself.
To install Protocol::PerlDebugCLI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::PerlDebugCLI
CPAN shell
perl -MCPAN -e shell install Protocol::PerlDebugCLI
For more information on module installation, please visit the detailed CPAN module installation guide.