summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-09-30 23:48:56 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-09-30 23:48:56 -0700
commitbe1cc4519b5ba35ec8c5b8a2b4a62c72cff05a2e (patch)
tree30181d1d0ca0fd5011f945fc501790f5cd866bb4
parentc059848dda15ddd2e5e825b0731428fe2ac3e644 (diff)
downloadperl-be1cc4519b5ba35ec8c5b8a2b4a62c72cff05a2e.tar.gz
[perl #48332] Debugger corrupts symbol table munging
This reverts commit 92adfbd49af0758bcc9a198cf2df2bd78c4176b9, which removed a necessary assignment for the sake of consting. In doing so, it allows subroutine redefinition to work properly again in the debugger.
-rw-r--r--MANIFEST1
-rw-r--r--pod/perldelta.pod5
-rw-r--r--t/lib/Devel/switchd_empty.pm2
-rw-r--r--t/run/switchd.t19
-rw-r--r--util.c8
5 files changed, 31 insertions, 4 deletions
diff --git a/MANIFEST b/MANIFEST
index 746e0c9bfa..63d04b2844 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4413,6 +4413,7 @@ t/lib/cygwin.t Builtin cygwin function tests
t/lib/deprecate/Deprecated.pm Deprecated module to test deprecate.pm
t/lib/deprecate/Optionally.pm Optionally deprecated module to test deprecate.pm
t/lib/deprecate.t Test deprecate.pm
+t/lib/Devel/switchd_empty.pm Module for t/run/switchd.t
t/lib/Devel/switchd.pm Module for t/run/switchd.t
t/lib/feature/bundle Tests for feature bundles
t/lib/feature/implicit Tests for implicit loading of feature.pm
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 4f5c5e2848..e3018dab98 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -645,6 +645,11 @@ This bug was introduced in version 5.13.5 and did not affect earlier
versions
L<[perl #78058]|http://rt.perl.org/rt3/Public/Bug/Display.html?id=78058>.
+=item *
+
+Subroutine redefinition works once more in the debugger
+L<[perl #48332]|http://rt.perl.org/rt3/Public/Bug/Display.html?id=48332>.
+
=back
=head1 Known Problems
diff --git a/t/lib/Devel/switchd_empty.pm b/t/lib/Devel/switchd_empty.pm
new file mode 100644
index 0000000000..bf9c1cde6e
--- /dev/null
+++ b/t/lib/Devel/switchd_empty.pm
@@ -0,0 +1,2 @@
+sub DB::DB {}
+1
diff --git a/t/run/switchd.t b/t/run/switchd.t
index f937093809..36cbb381bb 100644
--- a/t/run/switchd.t
+++ b/t/run/switchd.t
@@ -7,9 +7,9 @@ BEGIN {
BEGIN { require "./test.pl"; }
-# This test depends on t/lib/Devel/switchd.pm.
+# This test depends on t/lib/Devel/switchd*.pm.
-plan(tests => 3);
+plan(tests => 4);
my $r;
@@ -57,3 +57,18 @@ cmp_ok(
0,
'The debugger can see the lines of the main program under #!perl -d',
);
+
+# [perl #48332]
+like(
+ runperl(
+ switches => [ '-Ilib', '-d:switchd_empty' ],
+ progs => [
+ 'sub foo { print qq _1\n_ }',
+ '*old_foo = \&foo;',
+ '*foo = sub { print qq _2\n_ };',
+ 'old_foo(); foo();',
+ ],
+ ),
+ qr "1\r?\n2\r?\n",
+ 'Subroutine redefinition works in the debugger [perl #48332]',
+);
diff --git a/util.c b/util.c
index bed4c64629..75dbc1bf65 100644
--- a/util.c
+++ b/util.c
@@ -6526,13 +6526,17 @@ Perl_get_db_sub(pTHX_ SV **svp, CV *cv)
PL_tainted = FALSE;
save_item(dbsv);
if (!PERLDB_SUB_NN) {
- GV * const gv = CvGV(cv);
+ GV *gv = CvGV(cv);
if ( svp && ((CvFLAGS(cv) & (CVf_ANON | CVf_CLONED))
|| strEQ(GvNAME(gv), "END")
|| ((GvCV(gv) != cv) && /* Could be imported, and old sub redefined. */
!( (SvTYPE(*svp) == SVt_PVGV)
- && (GvCV((const GV *)*svp) == cv) )))) {
+ && (GvCV((const GV *)*svp) == cv)
+ && (gv = (GV *)*svp)
+ )
+ )
+ )) {
/* Use GV from the stack as a fallback. */
/* GV is potentially non-unique, or contain different CV. */
SV * const tmp = newRV(MUTABLE_SV(cv));