This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
-DsR : display unTEMPed temps with "t" not "T"
authorDavid Mitchell <davem@iabyn.com>
Wed, 26 Oct 2016 16:48:44 +0000 (17:48 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 26 Oct 2016 16:48:44 +0000 (17:48 +0100)
with the -R debugging flag, SVs are displayed with a reference count
(if > 1), and with a T if the SV is referenced from the temps stack.

E.g.
    $ perl -DstR -e'@a = map $_,"a", "b"'
    ...
    *  <T>PV("a"\0)  <T>PV("b"\0)

This commit enhances this to use both "t" and "T":

t:  SV is referenced from PL_tmps_stack, but SvTEMP() not set
T:  SV is referenced from PL_tmps_stack, and in addition, SvTEMP() is set

(The other permutation,  SvTEMP() set but not in PL_tmps_stack, is
illegal).

This commit changes

dump.c

diff --git a/dump.c b/dump.c
index d2d7f67..3e1b011 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -421,11 +421,14 @@ Perl_sv_peek(pTHX_ SV *sv)
                break;
            }
        }
-       if (SvREFCNT(sv) > 1)
-           Perl_sv_catpvf(aTHX_ t, "<%"UVuf"%s>", (UV)SvREFCNT(sv),
-                   is_tmp ? "T" : "");
-       else if (is_tmp)
-           sv_catpv(t, "<T>");
+       if (is_tmp || SvREFCNT(sv) > 1) {
+            Perl_sv_catpvf(aTHX_ t, "<");
+            if (SvREFCNT(sv) > 1)
+                Perl_sv_catpvf(aTHX_ t, "%"UVuf, (UV)SvREFCNT(sv));
+            if (is_tmp)
+                Perl_sv_catpvf(aTHX_ t, "%s", SvTEMP(t) ? "T" : "t");
+            Perl_sv_catpvf(aTHX_ t, ">");
+        }
     }
 
     if (SvROK(sv)) {