Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

action in debugger - how to turn off

by lcuff (Novice)
on May 20, 2011 at 23:57 UTC ( #906000=perlquestion: print w/ replies, xml ) Need Help??
lcuff has asked for the wisdom of the Perl Monks concerning the following question:

I'm reading through perldoc perldebug and it describes at length the ability to specify an action before a given line is executed. For example with

 a <line-number> print "hello world"

Once I've encountered the line specified on my 'a' command, it prints hello world every time I do 'n' (next). This seems wrong. Even when I do  A * and it announces that it turns off all actions. It keeps printing hello world every time I do an 'n'. I'm using perl v 5.12.1 on Linux.

Thoughts?

Comment on action in debugger - how to turn off
Select or Download Code
Replies are listed 'Best First'.
Re: action in debugger - how to turn off
by Khen1950fx (Canon) on May 21, 2011 at 04:44 UTC
    The debugger is doing what it was told to do:). What you need to do now is to delete the action.
    a 68 print "hello world'
    It'll print "hello world" every time it passes line 68 and will keep printing out until
    A 68
    That deletes the action.

      I can't get it to work. I should have been more explicit in my original post. Here is my test code:

      #!/vcm/home/bin/perl -w use strict; use warnings; print "Hello world line 7\n"; print "Hello world line 8\n"; print "Hello world line 9\n"; print "Hello world line 10\n"; print "Hello world line 11\n"; print "Hello world line 12\n"; print "Hello world line 13\n"; print "Hello world line 14\n"; print "Hello world line 15\n"; print "Hello world line 16\n"; print "Hello world line 17\n"; print "Hello world line 18\n"; print "Hello world line 19\n"; print "Hello world line 20\n"; $ perl -v This is perl 5, version 12, subversion 1 (v5.12.1) built for x86_64-li +nux

      And here is the debugger interaction. The action gets set on line 10 with a  10 print "action print" . Neither using  A 10, which I try when after executing line 12, nor  A * , which I try after executing line 14, turns off the action printing. It keeps printing, once per line.

      $ perl -d foo.pl Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(foo.pl:7): print "Hello world line 7\n"; DB<1> a 9 print "action print\n"; + DB<2> n + Hello world line 7 main::(foo.pl:8): print "Hello world line 8\n"; DB<2> n + Hello world line 8 main::(foo.pl:9): print "Hello world line 9\n"; action print DB<2> n + Hello world line 9 main::(foo.pl:10): print "Hello world line 10\n"; action print DB<2> n + Hello world line 10 main::(foo.pl:11): print "Hello world line 11\n"; action print DB<2> n + Hello world line 11 main::(foo.pl:12): print "Hello world line 12\n"; action print DB<2> n + Hello world line 12 main::(foo.pl:13): print "Hello world line 13\n"; action print DB<2> A 10 + DB<3> n + Hello world line 13 main::(foo.pl:14): print "Hello world line 14\n"; action print DB<3> n + Hello world line 14 main::(foo.pl:15): print "Hello world line 15\n"; action print DB<3> A * + Deleting all actions... DB<4> n + Hello world line 15 main::(foo.pl:16): print "Hello world line 16\n"; action print DB<4> n + Hello world line 16 main::(foo.pl:17): print "Hello world line 17\n"; action print DB<4> n + Hello world line 17 main::(foo.pl:18): print "Hello world line 18\n"; action print

        Looks like a problem 'use strict' would have caught. It can be fixed by just inserting one line into "sub DB" of perl5db.pl:

        my $action;

        Update (late): Broken by:

        commit 04e43a21088e2c6b07ebde9e57007350cfd7310b Author: Daniel S. Lewart <lewart@uiuc.edu> Date: Tue May 22 21:18:03 2001 -0500

        specifically:

        - if (($stop,$action) = split(/\0/,$dbline{$line})) { + if ($dbline{$line} && (($stop,$action) = split(/\0/,$dbline{$line +}))) {

        But I'd still fix it by just putting a line before that:

        my( $stop, $action );

        There's nothing like fixing a decade-old bug.

        - tye        

        I can replicate the problem in blead. perlbug?
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        Hello. I am experiencing the exact same thing, with the addition that when the variable I am printing out goes out of scope, the debugger complains mightily. Is there a resolution to this?

        I am running Strawberry Perl V5.14.2.1-64bit on Windows 7. Thanks for any help, RTFM links, etc.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2015-07-30 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls