Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C<c ln> broken in blead's debugger #11779

Closed
p5pRT opened this issue Nov 29, 2011 · 24 comments
Closed

C<c ln> broken in blead's debugger #11779

p5pRT opened this issue Nov 29, 2011 · 24 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 29, 2011

Migrated from rt.perl.org#104820 (status was 'resolved')

Searchable as RT104820$

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2011

From @craigberry

In 5.14.2​:

% cat foo.pl
use strict;
my $x = 'hello world';
print "$x\n";
% 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​:2)​: my $x = 'hello world';
DB<1> c 3
main​::(foo.pl​:3)​: print "$x\n";
DB<2> q

Everything is peachy. But in blead it breezes past the breakpoint
without stopping​:

% ./perl -Ilib -d foo.pl

Loading DB routines from perl5db.pl version 1.34
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

DB<1> c 3
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

And if I do a C<b 3> followed by C<c>, which should be equivalent to C<c 3>, the breakpoint apparently fires but does not display the source line without the addition of an explicit list command​:

% ./perl -Ilib -d foo.pl

Loading DB routines from perl5db.pl version 1.34
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

  DB<1> b 3
  DB<2> c
  DB<2> l
3==>b print "$x\n";
4
  DB<2> s
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

which turns out to be just a subset of the fact that no line display happens at all when stepping through the code in the debugger that currently ships with blead.

And a manual bisect (because it was really easy to guess what broke it
by browsing the history) shows that this was caused by​:

commit e09195a
Author​: Shlomi Fish <shlomif@​shlomifish.org>
Date​: Sun Sep 4 12​:29​:59 2011 -0700

  Add enable/disable commands for breakpoints in perl -d

I think this needs to be reverted or fixed before 5.16. I've seen this on a couple of platforms, but the examples in this report are from​:

% ./perl -Ilib -V
Summary of my perl5 (revision 5 version 15 subversion 5) configuration​:
  Commit id​: 3c7be43
  Platform​:
  osname=darwin, osvers=11.2.0, archname=darwin-2level
  uname='darwin triamond.local 11.2.0 darwin kernel version 11.2.0​: tue aug 9 20​:54​:00 pdt 2011; root​:xnu-1699.24.8~1release_x86_64 x86_64 '
  config_args='-Dusedevel -DDEBUGGING -des'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-common -DPERL_DARWIN -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
  optimize='-O3 -g',
  cppflags='-fno-common -DPERL_DARWIN -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
  ccversion='', gccversion='4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
  libpth=/usr/local/lib /opt/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lutil -lc
  perllibs=-ldl -lm -lutil -lc
  libc=, so=dylib, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: DEBUGGING HAS_TIMES PERLIO_LAYERS
  PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
  PERL_PRESERVE_IVUV PERL_USE_DEVEL USE_64_BIT_ALL
  USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
  USE_LOCALE_COLLATE USE_LOCALE_CTYPE
  USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
  Built under darwin
  Compiled at Nov 28 2011 19​:14​:50
  @​INC​:
  lib
  /usr/local/lib/perl5/site_perl/5.15.5/darwin-2level
  /usr/local/lib/perl5/site_perl/5.15.5
  /usr/local/lib/perl5/5.15.5/darwin-2level
  /usr/local/lib/perl5/5.15.5
  /usr/local/lib/perl5/site_perl
  .

________________________________________
Craig A. Berry
mailto​:craigberry@​mac.com

"... getting out of a sonnet is much more
difficult than getting in."
  Brad Leithauser

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2011

From @cpansprout

On Mon Nov 28 17​:32​:00 2011, craigberry wrote​:

In 5.14.2​:

% cat foo.pl
use strict;
my $x = 'hello world';
print "$x\n";
% 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​:2)​: my $x = 'hello world';
DB<1> c 3
main​::(foo.pl​:3)​: print "$x\n";
DB<2> q

Everything is peachy. But in blead it breezes past the breakpoint
without stopping​:

% ./perl -Ilib -d foo.pl

Loading DB routines from perl5db.pl version 1.34
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

DB<1> c 3
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

And if I do a C<b 3> followed by C<c>, which should be equivalent to
C<c 3>, the breakpoint apparently fires but does not display the
source line without the addition of an explicit list command​:

% ./perl -Ilib -d foo.pl

Loading DB routines from perl5db.pl version 1.34
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

DB<1> b 3
DB<2> c
DB<2> l
3==>b print "$x\n";
4
DB<2> s
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

which turns out to be just a subset of the fact that no line display
happens at all when stepping through the code in the debugger that
currently ships with blead.

That latter bug has been fixed with commit bdba49a. ‘c 3’ is still
broken.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2011

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2011

From @craigberry

On Dec 3, 2011, at 11​:40 AM, Father Chrysostomos via RT wrote​:

On Mon Nov 28 17​:32​:00 2011, craigberry wrote​:

no line display
happens at all when stepping through the code in the debugger that
currently ships with blead.

That latter bug has been fixed with commit bdba49a.

True, it now displays the first line of code. But after 'n' or 's' it still doesn't display the *second* or any subsequent lines of code.

‘c 3’ is still broken.

Yes.

________________________________________
Craig A. Berry
mailto​:craigberry@​mac.com

"... getting out of a sonnet is much more
difficult than getting in."
  Brad Leithauser

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2011

From @shlomif

On Sun Dec 04 06​:26​:09 2011, craigberry wrote​:

On Dec 3, 2011, at 11​:40 AM, Father Chrysostomos via RT wrote​:

On Mon Nov 28 17​:32​:00 2011, craigberry wrote​:

no line display
happens at all when stepping through the code in the debugger that
currently ships with blead.

That latter bug has been fixed with commit bdba49a.

True, it now displays the first line of code. But after 'n' or 's' it
still doesn't display the *second* or any subsequent lines of code.

‘c 3’ is still broken.

It seems to be OK on bleadperl​:

[SHELL]
shlomif@​telaviv1​:~/Download/unpack/perl/p5/git/perl$ cat foo.pl
use strict;
my $x = 'hello world';
print "$x\n";
shlomif@​telaviv1​:~/Download/unpack/perl/p5/git/perl$ ./perl -Ilib -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​:2)​: my $x = 'hello world';
  DB<105> c 3
main​::(foo.pl​:3)​: print "$x\n";
  DB<106> x $x
0 'hello world'
  DB<107> q
shlomif@​telaviv1​:~/Download/unpack/perl/p5/git/perl$
[/SHELL]

Maybe we should still add a test.

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2011

From @craigberry

On Dec 06, 2011, at 12​:46 PM, Shlomi Fish via RT <perlbug-followup@​perl.org> wrote​:

On Sun Dec 04 06​:26​:09 2011, craigberry wrote​:

On Dec 3, 2011, at 11​:40 AM, Father Chrysostomos via RT wrote​:

On Mon Nov 28 17​:32​:00 2011, craigberry wrote​:

no line display
happens at all when stepping through the code in the debugger that
currently ships with blead.

That latter bug has been fixed with commit bdba49a.

True, it now displays the first line of code. But after 'n' or 's' it
still doesn't display the *second* or any subsequent lines of code.

‘c 3’ is still broken.

It seems to be OK on bleadperl​:

[SHELL]
shlomif@​telaviv1​:~/Download/unpack/perl/p5/git/perl$ cat foo.pl
use strict;
my $x = 'hello world';
print "$x\n";
shlomif@​telaviv1​:~/Download/unpack/perl/p5/git/perl$ ./perl -Ilib -d foopl

Loading DB routines from perl5db.pl version 1.33

Note that the version of the debugger that's in blead is 1.34​:

<http​://perl5.git.perl.org/perl.git/blob/HEAD​:/lib/perl5db.pl#l522>

Don't know how you got it, but the debugger you're running does not appear to be what is shipping with blead.

And the version number of the debugger is not really getting properly maintained as there have been a number of changes since it was last bumped in May.

Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main​::(foo.pl​:2)​: my $x = 'hello world';
DB<105> c 3
main​::(foo.pl​:3)​: print "$x\n";
DB<106> x $x
0 'hello world'
DB<107> q
shlomif@​telaviv1​:~/Download/unpack/perl/p5/git/perl$
[/SHELL]

Maybe we should still add a test.

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Dec 7, 2011

From @shlomif

Attached is a patch to the "c ln" problem that was reported here. All
existing tests and the new test pass with the patch, and the new test
fails without it.

@p5pRT
Copy link
Author

p5pRT commented Dec 7, 2011

From @shlomif

0001-Made-c-line_num-working-again.patch
From bf32ddea2b141fc03f42815d8c6076900a683ca9 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@iglu.org.il>
Date: Wed, 7 Dec 2011 19:36:39 +0200
Subject: [PATCH] Made "c [line_num]" working again.

This is a bug-fix to
https://rt.perl.org/rt3//Public/Bug/Display.html?id=104820 .

Both the fix and a regression tests were added.
---
 lib/perl5db.pl |   31 +++++++++++++++++++++++++++++--
 lib/perl5db.t  |   24 +++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index d8b6894..45e7615 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -1956,7 +1956,10 @@ sub DB {
         elsif ($stop) {
             $evalarg = "\$DB::signal |= 1 if do {$stop}";
             &eval;
-            $dbline{$line} =~ s/;9($|\0)/$1/;
+            # If the breakpoint is temporary, then delete its enabled status.
+            if ($dbline{$line} =~ s/;9($|\0)/$1/) {
+                _cancel_breakpoint_temp_enabled_status($filename, $line);
+            }
         }
     } ## end if ($dbline{$line} && ...
 
@@ -2812,6 +2815,7 @@ in this and all call levels above this one.
 
                         # Yes. Set up the one-time-break sigil.
                         $dbline{$i} =~ s/($|\0)/;9$1/;  # add one-time-only b.p.
+                        _enable_breakpoint_temp_enabled_status($filename, $i);
                     } ## end if ($i)
 
                     # Turn off stack tracing from here up.
@@ -4002,10 +4006,33 @@ sub _set_breakpoint_enabled_status {
     return;
 }
 
+sub _enable_breakpoint_temp_enabled_status {
+    my ($filename, $line) = @_;
+
+    _get_breakpoint_data_ref($filename, $line)->{'temp_enabled'} = 1;
+
+    return;
+}
+
+sub _cancel_breakpoint_temp_enabled_status {
+    my ($filename, $line) = @_;
+
+    my $ref = _get_breakpoint_data_ref($filename, $line);
+    
+    delete ($ref->{'temp_enabled'});
+
+    if (! %$ref) {
+        _delete_breakpoint_data_ref($filename, $line);
+    }
+
+    return;
+}
+
 sub _is_breakpoint_enabled {
     my ($filename, $line) = @_;
 
-    return _get_breakpoint_data_ref($filename, $line)->{'enabled'};
+    my $data_ref = _get_breakpoint_data_ref($filename, $line);
+    return ($data_ref->{'enabled'} || $data_ref->{'temp_enabled'});
 }
 
 =head2 C<cmd_wrapper()> (API)
diff --git a/lib/perl5db.t b/lib/perl5db.t
index 0adae25..ba5d585 100644
--- a/lib/perl5db.t
+++ b/lib/perl5db.t
@@ -28,7 +28,7 @@ BEGIN {
     }
 }
 
-plan(19);
+plan(20);
 
 my $rc_filename = '.perldb';
 
@@ -434,6 +434,28 @@ EOF
         "Restart and delete all breakpoints work properly.");
 }
 
+{
+    rc(<<'EOF');
+&parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
+
+sub afterinit {
+    push (@DB::typeahead,
+    'c 15',
+    q/print "X={$x}\n";/,
+    'c',
+    'q',
+    );
+
+}
+EOF
+
+    my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/disable-breakpoints-1'); +
+    like($output, qr/
+        X=\{ThirdVal\}
+        /msx,
+        "'c line_num' is working properly.");
+}
+
 END {
     1 while unlink ($rc_filename, $out_fn);
 }
-- 
1.7.8

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2011

From @tonycoz

On Wed Dec 07 13​:38​:22 2011, shlomif wrote​:

Attached is a patch to the "c ln" problem that was reported here. All
existing tests and the new test pass with the patch, and the new test
fails without it.

Thanks, applied.

The n/s not showing the code line appears to have been fixed in
bdba49a, since I can't reproduce the problem (the $trace_to_depth
initialization looks like the fix)

Tony

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2011

@tonycoz - Status changed from 'open' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2011

From @craigberry

On Fri, Dec 9, 2011 at 7​:15 AM, Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

On Wed Dec 07 13​:38​:22 2011, shlomif wrote​:

Attached is a patch to the "c ln" problem that was reported here. All
existing tests and the new test pass with the patch, and the new test
fails without it.

Thanks, applied.

The n/s not showing the code line appears to have been fixed in
bdba49a, since I can't reproduce the problem (the $trace_to_depth
initialization looks like the fix)

It does seem to be a modest improvement. I do appreciate folks'
working on this, and seeing more tests appearing for the debugger
sounds like a promising direction. But I find it distressing that
three minutes spent actually using the debugger on a trivial program
easily reveals defects that weren't there in 5.14.2. Maybe I'm the
only one who actually uses the debugger, but if that's true why are
people changing it? And if people are changing it, why aren't they
using it?

I suggest leaving the ticket open as a
the-debugger-is-hosed-lets-hope-we-can-fix-it-before-5.16 catch-all.
If we can't make it demonstrably better than what shipped with 5.14.2,
then we shouldn't, i.e., we should fall back to an earlier version if
the new features aren't working.

So here's another, but in the same vein. We can now see the line
displayed if we break on a line, but not if we break on a subroutine​:

% cat foo.pl
use strict;
my $x = 'hello world';
print "$x\n";
back();
exit;
sub back {
  print "hello back\n";
}

% ./perl -Ilib -d foo.pl

Loading DB routines from perl5db.pl version 1.35
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main​::(foo.pl​:2)​: my $x = 'hello world';
  DB<1> c back
hello world
  DB<2> s
hello back
main​::(foo.pl​:5)​: exit;
main​::(foo.pl​:6)​: sub back {
  DB<2> q

There should be a line that looks like​:

main​::back(foo.pl​:7)​: print "hello back\n";

and with 5.14.2 it's there​:

% 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​:2)​: my $x = 'hello world';
  DB<1> c back
hello world
main​::back(foo.pl​:7)​: print "hello back\n";
  DB<2> s
hello back
main​::(foo.pl​:5)​: exit;
main​::(foo.pl​:6)​: sub back {
  DB<2> q

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2011

@tonycoz - Status changed from 'resolved' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2011

From @shlomif

On Fri Dec 09 17​:19​:44 2011, craig.a.berry@​gmail.com wrote​:

On Fri, Dec 9, 2011 at 7​:15 AM, Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

On Wed Dec 07 13​:38​:22 2011, shlomif wrote​:

Attached is a patch to the "c ln" problem that was reported here. All
existing tests and the new test pass with the patch, and the new test
fails without it.

Thanks, applied.

The n/s not showing the code line appears to have been fixed in
bdba49a, since I can't reproduce the problem (the $trace_to_depth
initialization looks like the fix)

It does seem to be a modest improvement. I do appreciate folks'
working on this, and seeing more tests appearing for the debugger
sounds like a promising direction. But I find it distressing that
three minutes spent actually using the debugger on a trivial program
easily reveals defects that weren't there in 5.14.2. Maybe I'm the
only one who actually uses the debugger, but if that's true why are
people changing it? And if people are changing it, why aren't they
using it?

“The shoe-maker has no shoes”? Seriously now, I normally use the system
perl ( perl-5.14.2-5.mga2 in my case) which comes with the debugger
without my changes. I guess I can point the "PERLDB" environment
variable to blead's debugger, which will allow me to test my changes.

Moreover, lately I did not find a lot of need to use the perl debugger,
because I have not done a lot of serious perl programming (but I would
still like it to be improved for when I do).

I suggest leaving the ticket open as a
the-debugger-is-hosed-lets-hope-we-can-fix-it-before-5.16 catch-all.

Well, you've opened it by your reply. And I wouldn't go as far as saying
that the debugger is "hosed".

If we can't make it demonstrably better than what shipped with 5.14.2,
then we shouldn't, i.e., we should fall back to an earlier version if
the new features aren't working.

As much as I care about the changes that were incorporated into the
debugger in perl-5.15.x, I don't mind that they will be temporarily
reverted, and only incorporated later.

So here's another, but in the same vein. We can now see the line
displayed if we break on a line, but not if we break on a subroutine​:

% cat foo.pl
use strict;
my $x = 'hello world';
print "$x\n";
back();
exit;
sub back {
print "hello back\n";
}

% ./perl -Ilib -d foo.pl

Loading DB routines from perl5db.pl version 1.35
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main​::(foo.pl​:2)​: my $x = 'hello world';
DB<1> c back
hello world
DB<2> s
hello back
main​::(foo.pl​:5)​: exit;
main​::(foo.pl​:6)​: sub back {
DB<2> q

There should be a line that looks like​:

main​::back(foo.pl​:7)​: print "hello back\n";

and with 5.14.2 it's there​:

% 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​:2)​: my $x = 'hello world';
DB<1> c back
hello world
main​::back(foo.pl​:7)​: print "hello back\n";
DB<2> s
hello back
main​::(foo.pl​:5)​: exit;
main​::(foo.pl​:6)​: sub back {
DB<2> q

Thanks! I'll investigate and submit another patch.

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2011

From @shlomif

Here is a patch to the recent bug reported by Craig here.

It can also be found here​:

https://github.com/shlomif/perl/tree/perl-d-add-tests-3

Regards,

— Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2011

From @shlomif

0001-perl-d-display-lines-inside-subroutines.patch
From 60115e18c528d4292689bb7fe78678c461d83758 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
Date: Sat, 10 Dec 2011 13:35:41 +0200
Subject: [PATCH] perl -d: display lines inside subroutines.

This is another fix to the perl debugger while making sure that lines
inside subroutines will be printed in the run-time display of the perl
debugger: https://rt.perl.org/rt3/Ticket/Display.html?id=104820 .
---
 MANIFEST                      |    1 +
 lib/perl5db.pl                |   15 +++++++++++----
 lib/perl5db.t                 |   27 ++++++++++++++++++++++++++-
 lib/perl5db/t/with-subroutine |   17 +++++++++++++++++
 4 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 lib/perl5db/t/with-subroutine

diff --git a/MANIFEST b/MANIFEST
index c6eb168..0cdb712 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4250,6 +4250,7 @@ lib/perl5db/t/rt-61222		Tests for the Perl debugger
 lib/perl5db/t/rt-66110		Tests for the Perl debugger
 lib/perl5db/t/symbol-table-bug	Tests for the Perl debugger
 lib/perl5db/t/taint		Tests for the Perl debugger
+lib/perl5db/t/with-subroutine		Tests for the Perl debugger
 lib/PerlIO.pm			PerlIO support module
 lib/Pod/Functions.pm		used by pod/splitpod
 lib/Pod/t/eol.t			end of line agnosticism
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index f62f2ab..e1c5f9b 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -2057,9 +2057,13 @@ won't cause trouble, and we say that the program is over.
 
 =cut
 
+    # Make sure that we always print if asked for explicitly regardless
+    # of $trace_to_depth .
+    my $explicit_stop = ($single || $was_signal);
+
     # Check to see if we should grab control ($single true,
     # trace set appropriately, or we got a signal).
-    if ( $single || ( $trace & 1 ) || $was_signal ) {
+    if ( $explicit_stop || ( $trace & 1 ) ) {
 
         # Yes, grab control.
         if ($slave_editor) {
@@ -2104,6 +2108,7 @@ number information, and print that.
 
         else {
 
+
             # Still somewhere in the midst of execution. Set up the
             #  debugger prompt.
             $sub =~ s/\'/::/;    # Swap Perl 4 package separators (') to
@@ -2131,7 +2136,7 @@ number information, and print that.
                     "$line:\t$dbline[$line]$after" );
             }
             else {
-                depth_print_lineinfo($position);
+                depth_print_lineinfo($explicit_stop, $position);
             }
 
             # Scan forward, stopping at either the end or the next
@@ -2159,7 +2164,7 @@ number information, and print that.
                         "$i:\t$dbline[$i]$after" );
                 }
                 else {
-                    depth_print_lineinfo($incr_pos);
+                    depth_print_lineinfo($explicit_stop, $incr_pos);
                 }
             } ## end for ($i = $line + 1 ; $i...
         } ## end else [ if ($slave_editor)
@@ -3906,7 +3911,9 @@ sub lsub : lvalue {
 
 # Abstracting common code from multiple places elsewhere:
 sub depth_print_lineinfo {
-    print_lineinfo( @_ ) if $stack_depth < $trace_to_depth;
+    my $always_print = shift;
+
+    print_lineinfo( @_ ) if ($always_print or $stack_depth < $trace_to_depth);
 }
 
 =head1 EXTENDED COMMAND HANDLING AND THE COMMAND API
diff --git a/lib/perl5db.t b/lib/perl5db.t
index ba5d585..73a68b8 100644
--- a/lib/perl5db.t
+++ b/lib/perl5db.t
@@ -28,7 +28,7 @@ BEGIN {
     }
 }
 
-plan(20);
+plan(21);
 
 my $rc_filename = '.perldb';
 
@@ -456,6 +456,31 @@ EOF
         "'c line_num' is working properly.");
 }
 
+# Testing that the prompt with the information appears inside a subroutine call.
+# See https://rt.perl.org/rt3/Ticket/Display.html?id=104820
+{
+    rc(<<'EOF');
+&parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
+
+sub afterinit {
+    push (@DB::typeahead,
+    'c back',
+    'q',
+    );
+
+}
+EOF
+
+    my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/with-subroutine');
+
+    like(_out_contents(), 
+        qr/
+        ^main::back\([^\)\n]*\bwith-subroutine:15\):[\ \t]*\n
+        ^15:\s*print\ "hello\ back\\n";
+        /msx,
+        "Prompt should display the line of code inside a subroutine.");
+}
+
 END {
     1 while unlink ($rc_filename, $out_fn);
 }
diff --git a/lib/perl5db/t/with-subroutine b/lib/perl5db/t/with-subroutine
new file mode 100644
index 0000000..b1d70fe
--- /dev/null
+++ b/lib/perl5db/t/with-subroutine
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $x = 'hello world';
+
+print "$x\n";
+
+back();
+
+exit;
+
+sub back {
+    print "hello back\n";
+}
+
-- 
1.7.8

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2011

From @tonycoz

Another one​:

5.14.1​:

  DB<1> b . $_ > 3
  DB<2> L
/home/tony/play/debug/loop.pl​:
6​: say;
  break if ($_ > 3)
  DB<2> c
1
2
3
main​::(/home/tony/play/debug/loop.pl​:6)​:
6​: say;
  DB<2>

blead​:

  DB<1> b . $_ > 3
  DB<2> L
/home/tony/play/debug/loop.pl​:
6​: say;
  break if (. $_ > 3)
  DB<2> c
1
syntax error at (eval 7)[/home/tony/perl/blead-branch/lib/5.15.5/perl5db.pl​:646] line 1, near "{."
2
...

Found by inspection, see the first hunk of​:

http​://perl5.git.perl.org/perl.git/blobdiff/2211a10b..076b743​:/lib/perl5db.pl

but I don't see why that change was made.

Tony

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2011

From vadim.konovalov@alcatel-lucent.com

From​: Tony Cook

http​://perl5.git.perl.org/perl.git/blobdiff/2211a10b..076b743​:/lib/perl5db.pl

but I don't see why that change was made.

after you've pointed to it, indeed, this change looks like accidental change
- who wants \w after '.' ?

  # Make . the current line number if it's there..
- $line =~ s/^\./$dbline/;
+ $line =~ s/^\.\b/$dbline/;

From​: Craig A. Berry [mailto​:craig.a.berry@​gmail.com]

But I find it distressing that
three minutes spent actually using the debugger on a trivial program
easily reveals defects that weren't there in 5.14.2. Maybe I'm the
only one who actually uses the debugger, but if that's true why are
people changing it?

I, for one, use Tk-enabled debugger which appears to be highly convenient

Regards,
Vadim.

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2011

From @shlomif

On Mon Dec 12 03​:34​:31 2011, tonyc wrote​:

Another one​:

5.14.1​:

DB<1> b . $_ > 3
DB<2> L
/home/tony/play/debug/loop.pl​:
6​: say;
break if ($_ > 3)
DB<2> c
1
2
3
main​::(/home/tony/play/debug/loop.pl​:6)​:
6​: say;
DB<2>

blead​:

DB<1> b . $_ > 3
DB<2> L
/home/tony/play/debug/loop.pl​:
6​: say;
break if (. $_ > 3)
DB<2> c
1
syntax error at (eval 7)[/home/tony/perl/blead-
branch/lib/5.15.5/perl5db.pl​:646] line 1, near "{."
2
...

Found by inspection, see the first hunk of​:

http​://perl5.git.perl.org/perl.git/blobdiff/2211a10b..076b743​:/lib/perl5db.pl

but I don't see why that change was made.

Tony

You can find the fix to this here​:

https://github.com/shlomif/perl/tree/perl-d-bug-fixes-2

Apparently, I've mistaken \b for something it wasn't in order to make
sure only a single standalone dot will be converted.

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2011

From @shlomif

Hi all,

the remaining patch is attached to this message. Please apply it.

Regards,

-- Shlomi Fish

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2011

From @shlomif

0001-perl-d-fixes-b-.-COND.patch
From 2facfd857cd702d92cf6b625c96a27e5b84d171e Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
Date: Mon, 12 Dec 2011 16:51:00 +0200
Subject: [PATCH] perl -d: fixes "b . COND()".

break-dot for filename was broken due to previous commits. It was fixed
now. Also documented it in pod/perldebug.pod, because it was
undocumented.
---
 MANIFEST                   |    1 +
 lib/perl5db.pl             |    2 +-
 lib/perl5db.t              |   26 +++++++++++++++++++++++++-
 lib/perl5db/t/break-on-dot |   10 ++++++++++
 pod/perldebug.pod          |    4 ++++
 5 files changed, 41 insertions(+), 2 deletions(-)
 create mode 100644 lib/perl5db/t/break-on-dot

diff --git a/MANIFEST b/MANIFEST
index c6eb168..b5a0d7b 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4235,6 +4235,7 @@ lib/overload.pm			Module for overloading perl operators
 lib/overload.t			See if operator overloading works
 lib/perl5db.pl			Perl debugging routines
 lib/perl5db.t			Tests for the Perl debugger
+lib/perl5db/t/break-on-dot	Test script used by perl5db.t
 lib/perl5db/t/breakpoint-bug	Test script used by perl5db.t
 lib/perl5db/t/disable-breakpoints-1	Test script used by perl5db.t
 lib/perl5db/t/disable-breakpoints-2	Test script used by perl5db.t
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index f62f2ab..4c26e4b 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -4207,7 +4207,7 @@ sub cmd_b {
     my $dbline = shift;
 
     # Make . the current line number if it's there..
-    $line =~ s/^\.\b/$dbline/;
+    $line =~ s/^\.(\s|\z)/$dbline$1/;
 
     # No line number, no condition. Simple break on current line.
     if ( $line =~ /^\s*$/ ) {
diff --git a/lib/perl5db.t b/lib/perl5db.t
index ba5d585..c583a85 100644
--- a/lib/perl5db.t
+++ b/lib/perl5db.t
@@ -28,7 +28,7 @@ BEGIN {
     }
 }
 
-plan(20);
+plan(21);
 
 my $rc_filename = '.perldb';
 
@@ -456,6 +456,30 @@ EOF
         "'c line_num' is working properly.");
 }
 
+{
+    rc(<<'EOF');
+&parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
+
+sub afterinit {
+    push (@DB::typeahead,
+    'n',
+    'n',
+    'b . $exp > 200',
+    'c',
+    q/print "Exp={$exp}\n";/,
+    'q',
+    );
+
+}
+EOF
+
+    my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/break-on-dot'); +
+    like($output, qr/
+        Exp=\{256\}
+        /msx,
+        "'b .' is working correctly.");
+}
+
 END {
     1 while unlink ($rc_filename, $out_fn);
 }
diff --git a/lib/perl5db/t/break-on-dot b/lib/perl5db/t/break-on-dot
new file mode 100644
index 0000000..a9ee1a3
--- /dev/null
+++ b/lib/perl5db/t/break-on-dot
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $exp = 1;
+for my $i (1 .. 20)
+{
+    $exp *= 2;
+}
diff --git a/pod/perldebug.pod b/pod/perldebug.pod
index fcdb29c..4a2f07e 100644
--- a/pod/perldebug.pod
+++ b/pod/perldebug.pod
@@ -304,6 +304,10 @@ don't use C<if>:
     b 237 ++$count237 < 11
     b 33 /pattern/i
 
+If the line number is C<.>, sets a breakpoint on the current line:
+
+    b . $n > 100
+
 =item b [file]:[line] [condition]
 X<breakpoint>
 X<debugger command, b>
-- 
1.7.8

@p5pRT
Copy link
Author

p5pRT commented Dec 28, 2011

From @rjbs

that last patch has been applied as 5343a61

Please note that it altered perl5db.pl without upping the version number, which caused
t/porting/cmp_version.t to fail.

Please always run "make test_porting" before sending in patches. (It is possible that due to
some concatenation of circumstances you did do this and it passed before the release of 5.15.6.
If so, thank you!)

@p5pRT
Copy link
Author

p5pRT commented Dec 28, 2011

From [Unknown Contact. See original ticket]

that last patch has been applied as 5343a61

Please note that it altered perl5db.pl without upping the version number, which caused
t/porting/cmp_version.t to fail.

Please always run "make test_porting" before sending in patches. (It is possible that due to
some concatenation of circumstances you did do this and it passed before the release of 5.15.6.
If so, thank you!)

@p5pRT
Copy link
Author

p5pRT commented Dec 28, 2011

@rjbs - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Dec 28, 2011
@p5pRT
Copy link
Author

p5pRT commented Dec 29, 2011

From @richardfoley

You're not the only one using the debugger. There are many, but it's like
being an atheist politician in the USA, no-one will admit to it. We're on the
non-PC side of the tracks...

--
Ciao

Richard Foley

http​://www.rfi.net/books.html

But I find it distressing that
three minutes spent actually using the debugger on a trivial program
easily reveals defects that weren't there in 5.14.2. Maybe I'm the
only one who actually uses the debugger, but if that's true why are
people changing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant