develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #118185] perl debugger doesn't evaluate user input when itshould

Thread Previous | Thread Next
From:
Smylers
Date:
May 26, 2013 19:42
Subject:
Re: [perl #118185] perl debugger doesn't evaluate user input when itshould
Message ID:
20130526194223.GD2043@stripey.com
James E Keenan via RT writes:

> On Sun May 26 12:00:31 2013, LAWalsh wrote:
> 
> > I was trying to call a function in my program in the debugger.
> > 
> > I note that it is documented to evaluate user functions in user space
> > if they do not conflict with commands.
> > 
> > I tried to call 'P' to print out the value of a hash.
> > 
> > (Might not be a bad addition to the debugger).
> 
> It already exists: 'p' -- not 'P'.

The output of p %hash is far from ideal, but x \%hash works well.

> > Instead of executing my sub, P, I get
> > 
> > Undefined subroutine &DB::cmd_P called at
> >    /usr/lib/perl5/5.16.2/perl5db.pl line 3819.
> >         DB::cmd_wrapper(undef, undef, 4) called at
> >    /usr/lib/perl5/5.16.2/perl5db.pl line 2366
> >         DB::DB called at /home/law/bin/shaper.pl line 4
> > Debugged program terminated.  Use q to quit or R to restart,
> >   use o inhibit_exit to avoid stopping after program termination,
> >   h q, h R or h o to get additional info.
> > 
> > --- not only does it not call the user's routine, but it kills
> > the debugger.
> 
> Works as planned. 'P' is not, AFAIK, a valid command in the debugger.

That's the point: at the debugger prompt something which isn't a
debugger command is interpreted as Perl. So P there shouldn't have
crashed, but run the P defined the program.

> You didn't supply the program you were trying to debug, so I tried
> this:
> 
> #####
> $ cat 118185_debug.pl 
> use strict;
> use warnings;
> 
> my %hash = ( qw| alpha beta gamma delta | );
> 
> P();
> 
> sub P { print "Hello world\n" };
> #####
> $ perl -d 118185_debug.pl 
> 
> Loading DB routines from perl5db.pl version 1.39_09
> Editor support available.
> 
> Enter h or 'h h' for help, or 'man perldebug' for more help.
> 
> main::(118185_debug.pl:4):      my %hash = ( qw| alpha beta gamma delta | );
>   DB<1> n
> main::(118185_debug.pl:6):      P();
>   DB<1> p %hash
> gammadeltaalphabeta
>   DB<2> n
> Hello world
> Debugged program terminated.  Use q to quit or R to restart,
> use o inhibit_exit to avoid stopping after program termination,
> h q, h R or h o to get additional info.
>   DB<2> q

That run doesn't invoke P at all from the debugger prompt. If I do
(without any arguments, just P) then I get the reported error message.

> [p5p] 512 $ perl -d 118185_debug.pl 
> 
> Loading DB routines from perl5db.pl version 1.39_09
> Editor support available.
> 
> Enter h or 'h h' for help, or 'man perldebug' for more help.
> 
> main::(118185_debug.pl:4):      my %hash = ( qw| alpha beta gamma delta | );
>   DB<1> n
> main::(118185_debug.pl:6):      P();
>   DB<1> p %hash
> alphabetagammadelta
>   DB<2> P %hash
> Can't use an undefined value as a subroutine reference at
> /usr/local/lib/perl5/5.18.0/perl5db.pl line 4442.
>  at /usr/local/lib/perl5/5.18.0/perl5db.pl line 4442.
>         DB::cmd_wrapper('P', '%hash', 6) called at
> /usr/local/lib/perl5/5.18.0/perl5db.pl line 3949
>         DB::Obj::_handle_cmd_wrapper_commands('DB::Obj=HASH(0x1a51860)')
> called at /usr/local/lib/perl5/5.18.0/perl5db.pl line 2836
>         DB::DB called at 118185_debug.pl line 6
> Debugged program terminated.

That's a different error message, but it still crashes.

If instead of P I use Kapow as the function name, the function gets
called from the debugger prompt.

So this does seem to be specifically a problem with functions called P.

Smylers
-- 
Stop drug companies hiding negative research results.
Sign the AllTrials petition to get all clinical research results published.
Read more: http://www.alltrials.net/blog/the-alltrials-campaign/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About