develooper Front page | perl.perl5.porters | Postings from June 2012

[perl #113918] [PATCH] 0829f80 Fix perl -d’s "l" command.

Thread Previous
From:
Shlomi Fish
Date:
June 30, 2012 07:08
Subject:
[perl #113918] [PATCH] 0829f80 Fix perl -d’s "l" command.
Message ID:
rt-3.6.HEAD-28836-1341065314-1833.113918-75-0@perl.org
# New Ticket Created by  Shlomi Fish 
# Please include the string:  [perl #113918]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=113918 >



This is a bug report for perl from shlomif@iglu.org.il,
generated with the help of perlbug 1.39 running under perl 5.16.0.

>From 0829f8043e6af08b70bf43296ff2a57b2b762bd1 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
Date: Sat, 30 Jun 2012 16:40:43 +0300
Subject: [PATCH] =?UTF-8?q?Fix=20perl=20-d=E2=80=99s=20"l"=20command.?=
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------1.7.11"

This is a multi-part message in MIME format.
--------------1.7.11
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


The "l" command (without any arguments) got broken in blead, due to the
"use strict" patch because "$max = ..." was changed into "my $max = ..."
while $max should always be a global.
---
 MANIFEST                         |  2 ++
 lib/perl5db.pl                   | 14 +++++------
 lib/perl5db.t                    | 54 +++++++++++++++++++++++++++++++++++++++-
 lib/perl5db/t/test-l-statement-1 |  8 ++++++
 lib/perl5db/t/test-r-statement   | 27 ++++++++++++++++++++
 5 files changed, 97 insertions(+), 8 deletions(-)
 create mode 100644 lib/perl5db/t/test-l-statement-1
 create mode 100644 lib/perl5db/t/test-r-statement


--------------1.7.11
Content-Type: text/x-patch; name="0001-Fix-perl-d-s-l-command.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Fix-perl-d-s-l-command.patch"

diff --git a/MANIFEST b/MANIFEST
index 6f0e95e..079f5bb 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4292,6 +4292,8 @@ 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/test-l-statement-1	Tests for the Perl debugger
+lib/perl5db/t/test-r-statement	Tests for the Perl debugger
 lib/perl5db/t/uncalled-subroutine	Tests for the Perl debugger
 lib/perl5db/t/with-subroutine		Tests for the Perl debugger
 lib/PerlIO.pm			PerlIO support module
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 4b4ab36..f07467f 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -523,7 +523,7 @@ BEGIN {
 # Debugger for Perl 5.00x; perl5db.pl patch level:
 use vars qw($VERSION $header);
 
-$VERSION = '1.39_01';
+$VERSION = '1.39_02';
 
 $header = "perl5db.pl version $VERSION";
 
@@ -1801,7 +1801,7 @@ sub DB {
     local (*dbline) = $main::{ '_<' . $filename };
 
     # Last line in the program.
-    my $max = $#dbline;
+    $max = $#dbline;
 
     # if we have something here, see if we should break.
     if ( $dbline{$line}
@@ -4057,7 +4057,7 @@ sub delete_action {
         print $OUT "Deleting all actions...\n";
         for my $file ( keys %had_breakpoints ) {
             local *dbline = $main::{ '_<' . $file };
-            my $max = $#dbline;
+            $max = $#dbline;
             my $was;
             for ( $i = 1 ; $i <= $max ; $i++ ) {
                 if ( defined $dbline{$i} ) {
@@ -4688,7 +4688,7 @@ sub delete_breakpoint {
             # Switch to the desired file temporarily.
             local *dbline = $main::{ '_<' . $file };
 
-            my $max = $#dbline;
+            $max = $#dbline;
             my $was;
 
             # For all lines in this file ...
@@ -5127,7 +5127,7 @@ sub cmd_L {
             local *dbline = $main::{ '_<' . $file };
 
             # Set up to look through the whole file.
-            my $max = $#dbline;
+            $max = $#dbline;
             my $was;    # Flag: did we print something
                         # in this file?
 
@@ -5500,7 +5500,7 @@ sub postponed_sub {
             $had_breakpoints{$file} |= 1;
 
             # Last line in file.
-            my $max = $#dbline;
+            $max = $#dbline;
 
             # Search forward until we hit a breakable line or get to
             # the end of the file.
@@ -9373,7 +9373,7 @@ sub cmd_pre580_D {
             # Switch to the desired file temporarily.
             local *dbline = $main::{ '_<' . $file };
 
-            my $max = $#dbline;
+            $max = $#dbline;
             my $was;
 
             # For all lines in this file ...
diff --git a/lib/perl5db.t b/lib/perl5db.t
index 7cca75c..b6936b2 100644
--- a/lib/perl5db.t
+++ b/lib/perl5db.t
@@ -28,7 +28,7 @@ BEGIN {
     }
 }
 
-plan(32);
+plan(34);
 
 my $rc_filename = '.perldb';
 
@@ -850,6 +850,58 @@ package main;
     );
 }
 
+{
+    my $wrapper = DebugWrap->new(
+        {
+            cmds =>
+            [
+                'b 14',
+                'c',
+                '$flag = 1;',
+                'r',
+                'print "Var=$var\n";',
+                'q',
+            ],
+            prog => '../lib/perl5db/t/test-r-statement',
+        }
+    );
+
+    $wrapper->output_like(
+        qr/
+            ^Foo$
+                .*?
+            ^Bar$
+                .*?
+            ^Var=Test$
+        /msx,
+        'r statement is working properly.',
+    );
+}
+
+{
+    my $wrapper = DebugWrap->new(
+        {
+            cmds =>
+            [
+                'l',
+                'q',
+            ],
+            prog => '../lib/perl5db/t/test-l-statement-1',
+        }
+    );
+
+    $wrapper->contents_like(
+        qr/
+            ^1==>\s+\$x\ =\ 1;\n
+            2:\s+print\ "1\\n";\n
+            3\s*\n
+            4:\s+\$x\ =\ 2;\n
+            5:\s+print\ "2\\n";\n
+        /msx,
+        'l statement is working properly (test No. 1).',
+    );
+}
+
 END {
     1 while unlink ($rc_filename, $out_fn);
 }
diff --git a/lib/perl5db/t/test-l-statement-1 b/lib/perl5db/t/test-l-statement-1
new file mode 100644
index 0000000..c3cf5b0
--- /dev/null
+++ b/lib/perl5db/t/test-l-statement-1
@@ -0,0 +1,8 @@
+$x = 1;
+print "1\n";
+
+$x = 2;
+print "2\n";
+
+$x = 3;
+print "3\n";
diff --git a/lib/perl5db/t/test-r-statement b/lib/perl5db/t/test-r-statement
new file mode 100644
index 0000000..f8c7bf5
--- /dev/null
+++ b/lib/perl5db/t/test-r-statement
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $var = "Test";
+
+sub mysub
+{
+    my $flag = 1;
+
+    $flag = 0;
+
+    print "Foo\n";
+
+    if ($flag)
+    {
+        print "Bar\n";
+    }
+
+    return;
+}
+
+mysub();
+
+$var .= "More";
+

--------------1.7.11--


---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl 5.16.0:

Configured by Mageia at Fri Jun  1 10:35:11 UTC 2012.

Summary of my perl5 (revision 5 version 16 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=2.6.38.8-server-10.mga, archname=x86_64-linux-thread-multi
    uname='linux jonund.mageia.org 2.6.38.8-server-10.mga #1 smp wed jan 25 10:58:50 utc 2012 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dinc_version_list=5.16.0 5.16.0/x86_64-linux-thread-multi 5.14.2 5.14.1 5.14.0 5.12.3 5.12.2 5.12.1 5.12.0 -Darchname=x86_64-linux -Dcc=gcc -Doptimize=-O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wl,--as-needed  -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags -pthread -DDEBUGGING=-g -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dsitebin=/usr/local/bin -Dsiteman1dir=/usr/local/share/man/man1 -Dsiteman3dir=/usr/local/share/man/man3 -Dman3dir=/usr/share/man/man3pm -Dvendorman3dir=/usr/share/man/man3 -Dman3ext=3pm -Dcf_by=Mageia -Dmyhostname=localhost -Dperladmin=root@localhost -Dcf_email=root@localhost -Ud_csh -Duseshrplib -Duseithreads -Di_db -Di_ndbm -Di_gdbm'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wl,--as-needed -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags -pthread',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.3', 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='gcc', ldflags =' -fstack-protector -L/usr/local/lib64'
    libpth=/usr/local/lib64 /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.14.1.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.14.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.16.0/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wl,--as-needed -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags -pthread -L/usr/local/lib64'

Locally applied patches:
    Mageia patches

---
@INC for perl 5.16.0:
    /home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.12.2
    /home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.14.2/x86_64-linux-thread-multi
    /home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.14.2
    /home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.16.0/x86_64-linux-thread-multi
    /home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.16.0
    /home/shlomif/apps/perl/modules/lib/site_perl/5.12.2
    /home/shlomif/apps/perl/modules/lib/site_perl/5.14.2
    /home/shlomif/apps/perl/modules/lib/site_perl/5.16.0
    /home/shlomif/apps/perl/modules/lib/perl5/5.12.2
    /home/shlomif/apps/perl/modules/lib/perl5/5.14.2
    /home/shlomif/apps/perl/modules/lib/perl5/5.16.0/x86_64-linux-thread-multi
    /home/shlomif/apps/perl/modules/lib/perl5/5.16.0
    /usr/lib/perl5/site_perl/5.16.0/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.16.0
    /usr/lib/perl5/vendor_perl/5.16.0/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.16.0
    /usr/lib/perl5/5.16.0/x86_64-linux-thread-multi
    /usr/lib/perl5/5.16.0
    /usr/lib/perl5/site_perl/5.16.0
    /usr/lib/perl5/site_perl/5.16.0/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.14.2
    /usr/lib/perl5/site_perl/5.14.1
    /usr/lib/perl5/site_perl/5.12.3
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.16.0
    /usr/lib/perl5/vendor_perl/5.16.0/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.14.2
    /usr/lib/perl5/vendor_perl/5.14.1
    /usr/lib/perl5/vendor_perl/5.14.0
    /usr/lib/perl5/vendor_perl/5.12.3
    /usr/lib/perl5/vendor_perl/5.12.2
    /usr/lib/perl5/vendor_perl
    .

---
Environment for perl 5.16.0:
    HOME=/home/shlomif
    LANG=en_GB.UTF-8
    LANGUAGE=en_GB:en
    LC_ADDRESS=en_US.UTF-8
    LC_COLLATE=en_US.UTF-8
    LC_CTYPE=en_US.UTF-8
    LC_IDENTIFICATION=en_GB.UTF-8
    LC_MEASUREMENT=en_GB.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LC_MONETARY=en_US.UTF-8
    LC_NAME=en_GB.UTF-8
    LC_NUMERIC=en_GB.UTF-8
    LC_PAPER=en_US.UTF-8
    LC_SOURCED=1
    LC_TELEPHONE=en_US.UTF-8
    LC_TIME=en_GB.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/shlomif/apps/perl/perlbrew/bin:/home/shlomif/apps/apache-maven/apache-maven-2.1.0//bin:/home/shlomif/Download/unpack/graphics/fop/fop-0.93:/home/shlomif/apps/perl/modules/local/bin:/home/shlomif/apps/perl/modules/bin:/home/shlomif/apps/latemp/bin:/home/shlomif/apps/test/quadpres/bin:/home/shlomif/bin:/home/shlomif/apps/apache-maven/apache-maven-2.1.0//bin:/bin:/usr/bin:/usr/games:/usr/lib64/qt4/bin
    PERL5LIB=/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.12.2:/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.14.2:/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.16.0:/home/shlomif/apps/perl/modules/lib/site_perl/5.12.2:/home/shlomif/apps/perl/modules/lib/site_perl/5.14.2:/home/shlomif/apps/perl/modules/lib/site_perl/5.16.0:/home/shlomif/apps/perl/modules/lib/perl5/5.12.2:/home/shlomif/apps/perl/modules/lib/perl5/5.14.2:/home/shlomif/apps/perl/modules/lib/perl5/5.16.0
    PERLBREW_MANPATH=
    PERLBREW_PATH=/home/shlomif/apps/perl/perlbrew/bin
    PERLBREW_PERL=
    PERLBREW_ROOT=/home/shlomif/apps/perl/perlbrew
    PERLBREW_VERSION=0.42
    PERL_AUTOINSTALL=--skipdeps --alldeps
    PERL_BADLANG (unset)
    PERL_MM_USE_DEFAULT=1
    SHELL=/bin/bash


Thread Previous


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