Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

vim perl debugger integration

by toiletmonster (Novice)
on Oct 28, 2002 at 21:47 UTC ( #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.

Comment on vim perl debugger integration
Select or Download Code
Re: vim perl debugger integration
by atcroft (Monsignor) 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.

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.

Log In?
Username:
Password:

What's my password?
Create A New User
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? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-09-22 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (189 votes), past polls