- SEE ALSO
- COPYRIGHT AND LICENSE
Vim::Debug - Perl wrapper around a command line debugger
package Vim::Debug; my $debugger = Vim::Debug->new( language => 'Perl', invoke => 'perl -Ilib -d t/perl.pl 42', ); $debugger->start; sleep(1) until $debugger->read; print "line: " . $debugger->line . "\n"; print "file: " . $debugger->file . "\n"; print "output: " . $debugger->output . "\n"; $debugger->step; sleep(1) until $debugger->read; $debugger->next; sleep(1) until $debugger->read; $debugger->write('help'); sleep(1) until $debugger->read; $debugger->quit;
If you are new to Vim::Debug please read the user manual, Vim::Debug::Manual, first.
Vim::Debug is an object oriented wrapper around the Perl command line debugger. In theory the debugger could be for any language -- not just Perl. But only Perl is supported currently.
The read() method is non blocking. This allows a user to send an interrupt when they get stuck in an infinite loop.
The language that the debugger is made to handle. Currently, only 'Perl' is supported.
The string used to invoke the debugger, for example 'perl -Ilib -d t/perl.pl 42',
Starts up the command line debugger in a separate process.
Write $command to the debugger's stdin. This method blocks until the debugger process reads. Be sure to include a newline.
Return value should be ignored.
Performs a non-blocking read on stdout from the debugger process. read() first looks for a debugger prompt.
If none is found, the debugger isn't finished thinking so read() returns 0.
If a debugger prompt is found, the output is parsed. The following information is parsed out and saved into attributes: line(), file(), value(), and out().
read() will also send an interrupt (CTL+C) to the debugger process if the stop() attribute is set to true.
If called with a parameter, out() removes ornaments (like <CTL-M> or irrelevant error messages or whatever) from text and saves the value.
If called without a parameter, out() returns the saved value.
Translate protocol command $in to a native debugger command, returned as an arrayref of strings.
Dies if no translation is found.
Returns a hash (a list actually) whose keys are qw<stop line file value status output>, and whose values are the corresponding values of the object.
In retrospect its possible there is a better solution to this. Perhaps directly hooking directly into the debugger rather than using regexps to parse stdout and stderr?
Eric Johnson <kablamo at iijo dot nospamthanks dot org>
This software is copyright (c) 2013 by Eric Johnson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.