In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/5a9a79a4cd93fcfb7398dd4e99030923446e8b08?hp=a5763045776ca8ceaf2c78fa074b0f8a1dbe6e9e>

- Log -----------------------------------------------------------------
commit 5a9a79a4cd93fcfb7398dd4e99030923446e8b08
Author: Father Chrysostomos <[email protected]>
Date:   Thu Sep 23 01:38:10 2010 -0700

    [perl #71806] perldb does not setup %dbline with the shebang option -d
    
    The first time gv_fetchfile is called for a particular file, it
    creates the glob and, if debugging is on, creates an AV. If the glob
    already exists (i.e., in subsequent calls), the AV is not created. The
    attached patch moves the check for debugging mode and the creation of
    the AV outside the if-block that checks whether the glob exists.
    
    This bug seems to have existed for a very long time and has been
    intermittent. It seems that many different things can change the order
    in which #!perl -d and gv_fetchfile occur. Whether compilation options
    affect it I do not know. I can reproduce it in 5.6.2, 5.8.[123456]
    (non-threaded) and 5.11.3 (both threaded and non-threaded), but not
    5.8.[789] or 5.10.[01] (threaded).
-----------------------------------------------------------------------

Summary of changes:
 gv.c              |    4 ++--
 pod/perldelta.pod |    7 +++++++
 t/run/switchd.t   |   15 ++++++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/gv.c b/gv.c
index e4bd394..65c2971 100644
--- a/gv.c
+++ b/gv.c
@@ -121,9 +121,9 @@ Perl_gv_fetchfile_flags(pTHX_ const char *const name, const 
STRLEN namelen,
 #else
        sv_setpvn(GvSV(gv), name, namelen);
 #endif
-       if (PERLDB_LINE || PERLDB_SAVESRC)
-           hv_magic(GvHVn(gv_AVadd(gv)), NULL, PERL_MAGIC_dbfile);
     }
+    if ((PERLDB_LINE || PERLDB_SAVESRC) && !GvAV(gv))
+           hv_magic(GvHVn(gv_AVadd(gv)), NULL, PERL_MAGIC_dbfile);
     if (tmpbuf != smallbuf)
        Safefree(tmpbuf);
     return gv;
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index aa23407..1d26095 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -387,6 +387,13 @@ Parsing Perl code (either with string C<eval> or by 
loading modules) from
 within a C<UNITCHECK> block no longer causes the interpreter to crash
 L<[perl #70614]|http://rt.perl.org/rt3//Public/Bug/Display.html?id=70614>.
 
+=item *
+
+When C<-d> is used on the shebang (C<#!>) line, the debugger now has access
+to the lines of the main program. In the past, this sometimes worked and
+sometimes did not, depending on what order things happened to be arranged
+in memory.
+
 =back
 
 =head1 Known Problems
diff --git a/t/run/switchd.t b/t/run/switchd.t
index 921b966..f937093 100644
--- a/t/run/switchd.t
+++ b/t/run/switchd.t
@@ -9,7 +9,7 @@ BEGIN { require "./test.pl"; }
 
 # This test depends on t/lib/Devel/switchd.pm.
 
-plan(tests => 2);
+plan(tests => 3);
 
 my $r;
 
@@ -44,3 +44,16 @@ __SWDTEST__
     like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd a 
42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;DB<Foo,$::tempfile_regex
 ... [138 chars truncated]
 }
 
+# [perl #71806]
+cmp_ok(
+  runperl(       # less is useful for something :-)
+   switches => [ '"-Mless ++INC->{q-Devel/_.pm-}"' ],
+   progs    => [
+    '#!perl -d:_',
+    'sub DB::DB{} print scalar @{q/_</.__FILE__}',
+   ],
+  ),
+ '>',
+  0,
+ 'The debugger can see the lines of the main program under #!perl -d',
+);

--
Perl5 Master Repository

Reply via email to