Change 34873 by [EMAIL PROTECTED] on 2008/11/17 22:04:56
Fix the bug introduced with MRO, whereby the internals were not saving
lines in subroutines defined inside eval ""s for the debugger.
Affected files ...
... //depot/perl/MANIFEST#1751 edit
... //depot/perl/embedvar.h#268 edit
... //depot/perl/intrpvar.h#238 edit
... //depot/perl/op.c#1021 edit
... //depot/perl/perlapi.h#190 edit
... //depot/perl/pp_ctl.c#711 edit
... //depot/perl/t/comp/retainedlines.t#1 add
Differences ...
==== //depot/perl/MANIFEST#1751 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#1750~34839~ 2008-11-16 00:31:37.000000000 -0800
+++ perl/MANIFEST 2008-11-17 14:04:56.000000000 -0800
@@ -3679,6 +3679,7 @@
t/comp/proto.t See if function prototypes work
t/comp/redef.t See if we get correct warnings on redefined subs
t/comp/require.t See if require works
+t/comp/retainedlines.t See if the debugger can retains eval's lines
t/comp/script.t See if script invocation works
t/comp/term.t See if more terms work
t/comp/uproto.t See if the _ prototype works
==== //depot/perl/embedvar.h#268 (text+w) ====
Index: perl/embedvar.h
--- perl/embedvar.h#267~34831~ 2008-11-14 04:37:01.000000000 -0800
+++ perl/embedvar.h 2008-11-17 14:04:56.000000000 -0800
@@ -75,6 +75,7 @@
#define PL_body_arenas (vTHX->Ibody_arenas)
#define PL_body_roots (vTHX->Ibody_roots)
#define PL_bodytarget (vTHX->Ibodytarget)
+#define PL_breakable_sub_generation (vTHX->Ibreakable_sub_generation)
#define PL_checkav (vTHX->Icheckav)
#define PL_checkav_save (vTHX->Icheckav_save)
#define PL_chopset (vTHX->Ichopset)
@@ -387,6 +388,7 @@
#define PL_Ibody_arenas PL_body_arenas
#define PL_Ibody_roots PL_body_roots
#define PL_Ibodytarget PL_bodytarget
+#define PL_Ibreakable_sub_generation PL_breakable_sub_generation
#define PL_Icheckav PL_checkav
#define PL_Icheckav_save PL_checkav_save
#define PL_Ichopset PL_chopset
==== //depot/perl/intrpvar.h#238 (text) ====
Index: perl/intrpvar.h
--- perl/intrpvar.h#237~34831~ 2008-11-14 04:37:01.000000000 -0800
+++ perl/intrpvar.h 2008-11-17 14:04:56.000000000 -0800
@@ -677,6 +677,8 @@
PERLVARI(Isv_serial, U32, 0) /* SV serial number, used in sv.c */
#endif
+PERLVARI(Ibreakable_sub_generation, U32, 0)
+
/* If you are adding a U8 or U16, check to see if there are 'Space' comments
* above on where there are gaps which currently will be structure padding. */
==== //depot/perl/op.c#1021 (text) ====
Index: perl/op.c
--- perl/op.c#1020~34770~ 2008-11-07 14:33:39.000000000 -0800
+++ perl/op.c 2008-11-17 14:04:56.000000000 -0800
@@ -5797,6 +5797,12 @@
if (!block)
goto done;
+ /* If we assign an optree to a PVCV, then we've defined a subroutine that
+ the debugger could be able to set a breakpoint in, so signal to
+ pp_entereval that it should not throw away any saved lines at scope
+ exit. */
+
+ PL_breakable_sub_generation++;
if (CvLVALUE(cv)) {
CvROOT(cv) = newUNOP(OP_LEAVESUBLV, 0,
mod(scalarseq(block), OP_LEAVESUBLV));
==== //depot/perl/perlapi.h#190 (text+w) ====
Index: perl/perlapi.h
--- perl/perlapi.h#189~34831~ 2008-11-14 04:37:01.000000000 -0800
+++ perl/perlapi.h 2008-11-17 14:04:56.000000000 -0800
@@ -186,6 +186,8 @@
#define PL_body_roots (*Perl_Ibody_roots_ptr(aTHX))
#undef PL_bodytarget
#define PL_bodytarget (*Perl_Ibodytarget_ptr(aTHX))
+#undef PL_breakable_sub_generation
+#define PL_breakable_sub_generation
(*Perl_Ibreakable_sub_generation_ptr(aTHX))
#undef PL_checkav
#define PL_checkav (*Perl_Icheckav_ptr(aTHX))
#undef PL_checkav_save
==== //depot/perl/pp_ctl.c#711 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#710~34857~ 2008-11-16 13:38:30.000000000 -0800
+++ perl/pp_ctl.c 2008-11-17 14:04:56.000000000 -0800
@@ -3653,7 +3653,7 @@
register PERL_CONTEXT *cx;
SV *sv;
const I32 gimme = GIMME_V;
- const I32 was = PL_sub_generation;
+ const I32 was = PL_breakable_sub_generation;
char tbuf[TYPE_DIGITS(long) + 12];
char *tmpbuf = tbuf;
char *safestr;
==== //depot/perl/t/comp/retainedlines.t#1 (text) ====
Index: perl/t/comp/retainedlines.t
--- /dev/null 2008-11-04 07:18:13.288883315 -0800
+++ perl/t/comp/retainedlines.t 2008-11-17 14:04:56.000000000 -0800
@@ -0,0 +1,43 @@
+#!./perl -w
+
+# Check that lines from eval are correctly retained by the debugger
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require "./test.pl";
+}
+
+use strict;
+
+plan( tests => 10 );
+
+my @before = grep { /eval/ } keys %::;
+
+is (@before, 0, "No evals");
+
+for my $sep (' ') {
+ $^P = 0xA;
+
+ my $prog = "sub foo {
+ 'Perl${sep}Rules'
+};
+1;
+";
+
+ eval $prog or die;
+ # Is there a more efficient way to write this?
+ my @expect_lines = (undef, map ({"$_\n"} split "\n", $prog), "\n", ';');
+
+ my @keys = grep { /eval/ } keys %::;
+
+ is (@keys, 1, "1 eval");
+
+ my @got_lines = @{$::{$keys[0]}};
+
+ is (@got_lines, @expect_lines, "Right number of lines for " . ord $sep);
+
+ for (0..$#expect_lines) {
+ is ($got_lines[$_], $expect_lines[$_], "Line $_ is correct");
+ }
+}
End of Patch.