Is it possible to invoke the debugger from within a program

Discussion in 'Perl Misc' started by Bruce Horrocks, Mar 6, 2006.

  1. If I run a program with -d and then use c to continue running, is there
    a way to have the program drop into the debugger at the appropriate line
    when a run-time warning is displayed?

    (This would help hugely because I'm effectively debugging the input data
    rather than the program and the warnings can arise at multiple points.
    Putting all these points into the necessary 'b <cond>' commands and
    editing them every time the line numbering changes as the program is
    modified is proving to be a chore.)

    Regards,
    --
    Bruce Horrocks
    Surrey
    England
    <firstname>@<surname>.plus.com -- fix the obvious for email
    Bruce Horrocks, Mar 6, 2006
    #1
    1. Advertising

  2. Bruce Horrocks

    Paul Lalli Guest

    Bruce Horrocks wrote:
    > If I run a program with -d and then use c to continue running, is there
    > a way to have the program drop into the debugger at the appropriate line
    > when a run-time warning is displayed?


    Set a warn handler in your code to execute the statement that tells the
    debugger to pause (read the perldebug page for more info).

    Basically, add this block to your code:
    $SIG{__WARN__} = sub {
    warn @_;
    $DB::single = 1;
    };

    You may wish to put that in a BEGIN block if you want to capture
    compile-time warnings as well.

    Paul Lalli
    Paul Lalli, Mar 6, 2006
    #2
    1. Advertising

  3. In message <>, Paul
    Lalli <> writes
    >Set a warn handler in your code to execute the statement that tells the
    >debugger to pause (read the perldebug page for more info).


    Thank-you very much Paul. It's obvious now I know what to look for.
    ;-)

    --
    Bruce Horrocks
    Surrey
    England
    <firstname>@<surname>.plus.com -- fix the obvious for email
    Bruce Horrocks, Mar 6, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jorge Luzarraga Castro
    Replies:
    1
    Views:
    364
    Kevin Spencer
    Nov 7, 2005
  2. shruds
    Replies:
    1
    Views:
    779
    John C. Bollinger
    Jan 27, 2006
  3. Moritz Reiter
    Replies:
    8
    Views:
    131
    Moritz Reiter
    Nov 24, 2006
  4. Robert Oschler
    Replies:
    1
    Views:
    221
    Mcginkel
    Sep 5, 2005
  5. aflat362
    Replies:
    7
    Views:
    219
    naixn
    Dec 7, 2006
Loading...

Share This Page