Front page | perl.perl5.porters |
Postings from January 2013
Re: [perl #71678] Bug [5.11.3] debugger bug in evaluation of useractions ('a' command)
Thread Previous
From:
Rocky Bernstein
Date:
January 29, 2013 03:42
Subject:
Re: [perl #71678] Bug [5.11.3] debugger bug in evaluation of useractions ('a' command)
Message ID:
CANCp2gahPh3gOZhLe1dxBq1MxDazC+Y6FXmhur2gNorcjaLHhQ@mail.gmail.com
Here is my short assessment: ick.
Here is the longer story, as best as I can tell, of what might be going on.
But I don't consider myself and expert on perl5db.pl
The debugger action command stores the action code string to be eval'd in
@DB::dbline. The DB::DB() subroutine will at some point notice this and set
global $DB::action if there is a value. (And it will clear it if there is
no value).
But the code in DB:DB() is long, tortuous and there are a number of
if/elsif branches.
The branch taken when the program has terminated seems to get run before
$DB::action is reset in another branch. And in some situations where step
is involved, those branches may also avoid resetting $action under various
circumstances that I don't really understand (or care to).
hexcoder's one-line patch is in my opinion a valid in that it deals with
the one situation originally reported. I don't think I agree with the
comment about in the face of a R(estart) the action is somehow disabled,
because the original place this is stored is in $DB::dbline. In *all* cases
then $DB::action should be reset.
But I could be wrong here.
But as subsequently noted, there are other possibilities and the one-line
patch doesn't fix of those other possibilities. It is therefore possible
that there is a better fix to handle all of the cases some other way.
In Devel::Trepan <https://metacpan.org/module/Devel::Trepan>, I use a
lexical variable to save the values of action. So that might be another
approach. So as best as I can tell, Devel::Trepan doesn't exhibit any of
the problems noted here.
On Sun, Jan 27, 2013 at 8:11 PM, James E Keenan via RT <
perlbug-followup@perl.org> wrote:
> On Tue Mar 27 18:24:27 2012, jkeenan wrote:
> > On Tue Sep 28 01:07:49 2010, hexcoder wrote:
> > > Greetings,
> > >
> > >
> > > But it should be evaluated _once_ instead of thrice in your test
> script
> > > because control reaches line 11 only once.
> > > The definition of the 'a' command is according to the debugger book
> > > 'Pro Perl Debugging' from Richard Foley and Andy Lester
> > > like this (on page 241):
> > > "Create an action to run the supplied perl expression each time the
> code
> > > on the given line number is about to be executed."
> > >
> > > So the evaluation needs to take the line number into account, which it
> > > currently does not.
> > > Once the action is activated, it is performed on each line upto the end
> > > of the scope (at least).
> > >
> > > Note: this is not related to perlbug #71806 'perldb does not setup
> > > %dbline with shebang option -d',
> > > because the behaviour is present also without shebang option -d.
> > > > I don’ think it has to do with the end of the program. This script
> > > > displays the message three times. I’ve never used the debugger
> before,
> > > > so I don’t know whether this is correct. But it seems to me that
> $action
> > > > needs to be cleared elsewhere in the debugger.
> > > >
> > > > BEGIN {
> > > > push @DB::typeahead, 'a 11 print "thrext\n"', 'c 8', ('s')x3, 'q';
> > > > $DB::single = 0;
> > > > }
> > > > use strict; use warnings;
> > > >
> > > > greet('Hello');
> > > >
> > > > sub greet
> > > > {
> > > > my $arg = shift;
> > > > print "$arg\n";
> > > > return;
> > > > }
> > > > __END__
> > > >
> > > >
> > > >
> > > >
> > >
> > > I propose this example (see attachment), which uses a lexical variable
> > > from the inner scope:
> > > ==== quote ========
> > > BEGIN {
> > > push @DB::typeahead, 'a 12 print "${arg}__${arg}\n"', ('s')x4, 'q';
> > > $DB::single = 0;
> > > }
> > > use strict; use warnings;
> > >
> > > greet('Hello'); # first stop in debugger
> > >
> > > sub greet
> > > {
> > > my $arg = shift;
> > > $arg = ''; # line 12
> > > return;
> > > }
> > > ===== end quote =======
> > >
> > > Thanks, hexcoder
> > >
> >
> > Discussion of this issue petered out about a year-and-a-half ago. Is
> > there anyone familiar with debugger issues who could review this RT?
> >
> > Thank you very much.
> > Jim Keenan
>
> There have been many discussions about the Perl debugger on P5P during
> the past year. Can anyone who participated in those discussions take a
> look at this ticket?
>
> Thank you very much.
> Jim Keenan
>
>
> ---
> via perlbug: queue: perl5 status: open
> https://rt.perl.org:443/rt3/Ticket/Display.html?id=71678
>
Thread Previous