Perl_deb_stack_all() - handle CXt_SUBST better
authorDavid Mitchell <davem@iabyn.com>
Wed, 24 Aug 2016 15:28:00 +0000 (16:28 +0100)
committerDavid Mitchell <davem@iabyn.com>
Thu, 25 Aug 2016 15:03:16 +0000 (16:03 +0100)
RT #129029

There's a loop which skips CXt_SUBST context entries - but it
wasn't checking that the *current* cx is that type, but instead
was always checking the base cx and was effectively a noop

Also fixup a few code comments in that function.

deb.c

diff --git a/deb.c b/deb.c
index 02a0a7d..e5b0384 100644 (file)
--- a/deb.c
+++ b/deb.c
@@ -234,7 +234,7 @@ Perl_deb_stack_all(pTHX)
                PerlIO_printf(Perl_debug_log, "\n");
            else {
 
-               /* Find the the current context's stack range by searching
+               /* Find the current context's stack range by searching
                 * forward for any higher contexts using this stack; failing
                 * that, it will be equal to the size of the stack for old
                 * stacks, or PL_stack_sp for the current stack
@@ -244,13 +244,14 @@ Perl_deb_stack_all(pTHX)
                const PERL_CONTEXT *cx_n = NULL;
                const PERL_SI *si_n;
 
-               /* there's a separate stack per SI, so only search
-                * this one */
+                /* there's a separate argument stack per SI, so only
+                 * search this one */
 
                for (i=ix+1; i<=si->si_cxix; i++) {
-                   if (CxTYPE(cx) == CXt_SUBST)
+                    const PERL_CONTEXT *this_cx = &(si->si_cxstack[i]);
+                    if (CxTYPE(this_cx) == CXt_SUBST)
                        continue;
-                   cx_n = &(si->si_cxstack[i]);
+                   cx_n = this_cx;
                    break;
                }
 
@@ -266,8 +267,8 @@ Perl_deb_stack_all(pTHX)
                    stack_max = AvFILLp(si->si_stack);
                }
 
-               /* for the other stack types, there's only one stack
-                * shared between all SIs */
+                /* for the markstack, there's only one stack shared
+                 * between all SIs */
 
                si_n = si;
                i = ix;