Vim::Debug - Perl wrapper around a command line debugger
package Vim::Debug; my $debugger = Vim::Debug->new( language => 'Perl', # required invoke => 'perl -Ilib -d t/perl.pl', # required ); $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.
Starts up the command line debugger in a seperate process.
start() always returns undef.
Write $command to the debugger's stdin. This method blocks until the debugger process reads. Be sure to include a newline.
write() always returns undef;
Performs a nonblocking read on stdout from the debugger process. read() first looks for a debugger prompt.
If one is not 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 a protocol command ($in) to a native debugger command. The native debugger command is returned as an arrayref of strings.
Dies if no translation is found.
Vim::Debug::Manual, Vim::Debug::Perl, Devel::ebug, perldebguts
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.
To install Vim::Debug, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Vim::Debug
CPAN shell
perl -MCPAN -e shell install Vim::Debug
For more information on module installation, please visit the detailed CPAN module installation guide.