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

Re: Interactive scripting with DB

by mugwumpjism (Hermit)
on May 26, 2005 at 02:54 UTC ( [id://460492]=note: print w/replies, xml ) Need Help??


in reply to Interactive scripting with debugger

There's sure no better way to "become one" with a program, putting yourself "in its shoes" than running it inside an interactive debugger.

You might also like these tips and tricks;

  • Putting the line kill 2, $$ will cause the debugger to break at that point in the source (on Unix, anyway). This works by emulating pressing Ctrl+C (it's the interrupt signal). This is great for setting breakpoints deep down in your code.
  • If you ever turn strings into real functions via eval, then make sure to add a 'magic line number comment': eg,
    sub some_auto_generated_function { my $self = shift; # line 1 "some/preprocessedfile.foo" print $self->frop; # line 7 "originalfile.pm" }
    If you do this, the emacs debugger will correctly step through the right source files. Sadly, though, the old perl5db.pl interactive debugger doesn't actually display the source properly.
  • Devel::ebug is a brand new debugger that doesn't have a lot of the limitations of the old debugger, in particular the segfaults, but instead brings a whole lot more new Storable related ones! Joy! But, anyway, this debugger is client/server with a very lightweight in-program "server", so you can debug remote programs. If you could write an emacs-compatible communication layer for it, you could bring this debugging to the "next level" of perl debuggers, which might include the debugger for Perl 6.
$h=$ENV{HOME};my@q=split/\n\n/,`cat $h/.quotes`;$s="$h/." ."signature";$t=`cat $s`;print$t,"\n",$q[rand($#q)],"\n";

Replies are listed 'Best First'.
Re^2: Interactive scripting with DB
by tlm (Prior) on May 26, 2005 at 03:42 UTC

    Putting the line kill 2, $$ will cause the debugger to break at that point in the source (on Unix, anyway).

    I had never seen that trick before. Cool. I have been using this one instead:

    $DB::single = 1;
    That causes the debugger to enter "single-step" mode, which amounts to programmatically setting a breakpoint in the next executable line. This is particularly useful for causing the debugger to stop at places that happen before the first executable line, e.g.:
    BEGIN { $DB::single = 1; } use Foo;
    The code above will enable stepping through the loading of 'Foo', which otherwise would happen before the place at which DB normally starts (i.e. the first executable line). I see that kill 2, $$ works well for this too. One more trick for the bag.

    the lowliest monk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found