Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

vim perl debugger integration

by toiletmonster (Novice)
on Oct 28, 2002 at 21:47 UTC ( [id://208619]=perlquestion: print w/replies, xml ) Need Help??

toiletmonster has asked for the wisdom of the Perl Monks concerning the following question:

ok. i'm trying to write a vim plugin that will allow me to visually step through and debug my code.

i discovered this DB.pm module and that seems pretty cool. (maybe it is what activestate uses for their windows gui perl debugger since it was written by a guy who works there?) it seems to be a debugger api type thing that is exactly what i would like to make my life easier. but its not working.

i can't get the debugger to load the file. i try to load the file with:
$self->loadfile( $file, $linenumber )
but that doesn't seem to work. if you actually look at the code for loadfile() in DB.pm, it should return the filename if it succeeds. its not succeeding.

i think i'm doing something fundamentally wrong. any ideas? here is my code:
#!/usr/bin/perl -w package PerlDebugger; use DB; @ISA = qw( DB ); sub new { my $type = shift; my $self = {}; bless $self, $type; } sub startDebugger { my $self = shift; my $sourceCode = shift; print "\n>>$sourceCode<<\n"; $self->register(); print ">>" . $self->loadfile( $sourceCode, -1 ) . "<<\n"; print ">>" . $self->ready() . "<<\n"; print "\n>>"; print $DB::filename; print "<<\n"; } sub quit { my $self = shift; $self->done(); } package main; use strict; my $code = "/home/eric/code/tmp/foo.pl"; my $dbgr = PerlDebugger->new(); $dbgr->startDebugger( $code );
my other option is to not use DB.pm at all and to use open2() on perl -d. which is not as pretty. and the annoying thing with that is the debugger writes to /dev/tty instead using STDOUT and STDIN, and that was giving me fits too because i want vim to display to /dev/tty and the debugger always takes over.

Replies are listed 'Best First'.
Re: vim perl debugger integration
by toiletmonster (Novice) on Oct 29, 2002 at 01:38 UTC
    hmm.. thanks for the interest atcroft. i think i made some progress. the key is i have to require the script i am trying to debug. and also i had to add a sub called showfile().

    this stuff is not documented which is sad because it means i have to read the DB.pm source (ack gasp) and understand perl internals and i don't know perl internals and i am afraid of perl internals.

    anyway this is still very pre beta beginning new, but this seems to work (yeah!):
    #!/usr/bin/perl -w package PerlDebugger; use DB; @ISA = qw( DB ); sub new { my $type = shift; my $self = {}; bless $self, $type; } sub startDebugger { my $self = shift; my $sourceCode = shift; eval( "require \"$sourceCode\";" ); $self->register(); print ">>" . $self->loadfile( $sourceCode, 3 ) . "<<\n"; print ">>" . $self->ready() . "<<\n"; print "\n>>"; print $DB::filename; print "<<\n"; } sub showfile { print "showfile\n"; } sub quit { my $self = shift; $self->done(); } package main; use strict; my $code = "perlbot.pl"; my $dbgr = PerlDebugger->new(); $dbgr->startDebugger( $code );
    i take it you use vim, atcroft? if i ever actually finish this i'll post it up on vim.sf.net and probably some other places too.

    thanks.
Re: vim perl debugger integration
by atcroft (Abbot) on Oct 29, 2002 at 00:03 UTC

    I'm definitely not an expert (in either vim or debugging, although one day I hope to be better at both), but if I may suggest (since I don't know if this will help or not), you may wish to look for ideas in Devel::ptkdb, and in the utility scripts found on the vim site entitled perl.vim : Perl compiler script and ExecPerl : Utilities for executing perl scripts, among other resources.

    I hope that helps, and I look forward to hearing your results, and the suggestions of others.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://208619]
Approved by fireartist
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found