This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PVFMs don't need CvDEPTH, and PVCVs don't use SvIVX, so moving
[perl5.git] / dump.c
diff --git a/dump.c b/dump.c
index 904b3ba..3779d45 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -1,7 +1,7 @@
 /*    dump.c
  *
  *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- *    2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others
+ *    2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -41,6 +41,7 @@ Perl_dump_indent(pTHX_ I32 level, PerlIO *file, const char* pat, ...)
 void
 Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args)
 {
+    dVAR;
     PerlIO_printf(file, "%*s", (int)(level*PL_dumpindent), "");
     PerlIO_vprintf(file, pat, *args);
 }
@@ -48,6 +49,7 @@ Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args)
 void
 Perl_dump_all(pTHX)
 {
+    dVAR;
     PerlIO_setlinebuf(Perl_debug_log);
     if (PL_main_root)
        op_dump(PL_main_root);
@@ -57,6 +59,7 @@ Perl_dump_all(pTHX)
 void
 Perl_dump_packsubs(pTHX_ const HV *stash)
 {
+    dVAR;
     I32        i;
 
     if (!HvARRAY(stash))
@@ -84,9 +87,9 @@ Perl_dump_sub(pTHX_ const GV *gv)
 {
     SV * const sv = sv_newmortal();
 
-    gv_fullname3(sv, gv, Nullch);
+    gv_fullname3(sv, gv, NULL);
     Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nSUB %s = ", SvPVX_const(sv));
-    if (CvXSUB(GvCV(gv)))
+    if (CvISXSUB(GvCV(gv)))
        Perl_dump_indent(aTHX_ 0, Perl_debug_log, "(xsub 0x%"UVxf" %d)\n",
            PTR2UV(CvXSUB(GvCV(gv))),
            (int)CvXSUBANY(GvCV(gv)).any_i32);
@@ -101,7 +104,7 @@ Perl_dump_form(pTHX_ const GV *gv)
 {
     SV * const sv = sv_newmortal();
 
-    gv_fullname3(sv, gv, Nullch);
+    gv_fullname3(sv, gv, NULL);
     Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nFORMAT %s = ", SvPVX_const(sv));
     if (CvROOT(GvFORM(gv)))
        op_dump(CvROOT(GvFORM(gv)));
@@ -112,6 +115,7 @@ Perl_dump_form(pTHX_ const GV *gv)
 void
 Perl_dump_eval(pTHX)
 {
+    dVAR;
     op_dump(PL_eval_root);
 }
 
@@ -765,10 +769,10 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o)
 #else
        if ( ! PL_op->op_flags & OPf_SPECIAL) { /* not lexical */
            if (cSVOPo->op_sv) {
-               SV *tmpsv = NEWSV(0,0);
+               SV *tmpsv = newSV(0);
                ENTER;
                SAVEFREESV(tmpsv);
-               gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, Nullch);
+               gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, NULL);
                Perl_dump_indent(aTHX_ level, file, "GV = %s\n",
                                 SvPV_nolen_const(tmpsv));
                LEAVE;
@@ -871,10 +875,10 @@ Perl_gv_dump(pTHX_ GV *gv)
     }
     sv = sv_newmortal();
     PerlIO_printf(Perl_debug_log, "{\n");
-    gv_fullname3(sv, gv, Nullch);
+    gv_fullname3(sv, gv, NULL);
     Perl_dump_indent(aTHX_ 1, Perl_debug_log, "GV_NAME = %s", SvPVX_const(sv));
     if (gv != GvEGV(gv)) {
-       gv_efullname3(sv, GvEGV(gv), Nullch);
+       gv_efullname3(sv, GvEGV(gv), NULL);
        Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", SvPVX_const(sv));
     }
     PerlIO_putc(Perl_debug_log, '\n');
@@ -1097,6 +1101,7 @@ Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, const char *name, GV *sv)
 void
 Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
 {
+    dVAR;
     SV *d;
     const char *s;
     U32 flags;
@@ -1278,8 +1283,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
        SvREFCNT_dec(d);
        return;
     }
-    if ((type >= SVt_PVIV && type != SVt_PVAV && type != SVt_PVHV)
-       || type == SVt_IV) {
+    if (type == SVt_IV || (type >= SVt_PVIV && type != SVt_PVAV
+                          && type != SVt_PVHV && type != SVt_PVCV)) {
        if (SvIsUV(sv)
 #ifdef PERL_OLD_COPY_ON_WRITE
                       || SvIsCOW(sv)
@@ -1298,7 +1303,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
 #endif
        PerlIO_putc(file, '\n');
     }
-    if ((type >= SVt_PVNV && type != SVt_PVAV && type != SVt_PVHV)
+    if ((type >= SVt_PVNV && type != SVt_PVAV && type != SVt_PVHV
+        && type != SVt_PVFM)
        || type == SVt_NV) {
        STORE_NUMERIC_LOCAL_SET_STANDARD();
        /* %Vg doesn't work? --jhi */
@@ -1481,15 +1487,22 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
        /* FALL THROUGH */
     case SVt_PVFM:
        do_hv_dump(level, file, "  COMP_STASH", CvSTASH(sv));
-       if (CvSTART(sv))
-           Perl_dump_indent(aTHX_ level, file, "  START = 0x%"UVxf" ===> %"IVdf"\n", PTR2UV(CvSTART(sv)), (IV)sequence_num(CvSTART(sv)));
-       Perl_dump_indent(aTHX_ level, file, "  ROOT = 0x%"UVxf"\n", PTR2UV(CvROOT(sv)));
-        if (CvROOT(sv) && dumpops)
-           do_op_dump(level+1, file, CvROOT(sv));
-       Perl_dump_indent(aTHX_ level, file, "  XSUB = 0x%"UVxf"\n", PTR2UV(CvXSUB(sv)));
-       {
+       if (!CvISXSUB(sv)) {
+           if (CvSTART(sv)) {
+               Perl_dump_indent(aTHX_ level, file,
+                                "  START = 0x%"UVxf" ===> %"IVdf"\n",
+                                PTR2UV(CvSTART(sv)),
+                                (IV)sequence_num(CvSTART(sv)));
+           }
+           Perl_dump_indent(aTHX_ level, file, "  ROOT = 0x%"UVxf"\n",
+                            PTR2UV(CvROOT(sv)));
+           if (CvROOT(sv) && dumpops) {
+               do_op_dump(level+1, file, CvROOT(sv));
+           }
+       } else {
            SV *constant = cv_const_sv((CV *)sv);
 
+           Perl_dump_indent(aTHX_ level, file, "  XSUB = 0x%"UVxf"\n", PTR2UV(CvXSUB(sv)));
 
            if (constant) {
                Perl_dump_indent(aTHX_ level, file, "  XSUBANY = 0x%"UVxf
@@ -1586,12 +1599,14 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
 void
 Perl_sv_dump(pTHX_ SV *sv)
 {
+    dVAR;
     do_sv_dump(0, Perl_debug_log, sv, 0, 0, 0, 0);
 }
 
 int
 Perl_runops_debug(pTHX)
 {
+    dVAR;
     if (!PL_op) {
        if (ckWARN_d(WARN_DEBUGGING))
            Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "NULL OP IN RUN");
@@ -1630,6 +1645,7 @@ Perl_runops_debug(pTHX)
 I32
 Perl_debop(pTHX_ const OP *o)
 {
+    dVAR;
     if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
        return 0;
 
@@ -1641,8 +1657,8 @@ Perl_debop(pTHX_ const OP *o)
     case OP_GVSV:
     case OP_GV:
        if (cGVOPo_gv) {
-           SV *sv = NEWSV(0,0);
-           gv_fullname3(sv, cGVOPo_gv, Nullch);
+           SV *sv = newSV(0);
+           gv_fullname3(sv, cGVOPo_gv, NULL);
            PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen_const(sv));
            SvREFCNT_dec(sv);
        }
@@ -1661,7 +1677,7 @@ Perl_debop(pTHX_ const OP *o)
             AV * const comppad = (AV*)(*av_fetch(padlist, 0, FALSE));
             sv = *av_fetch(comppad, o->op_targ, FALSE);
         } else
-            sv = Nullsv;
+            sv = NULL;
         if (sv)
            PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen_const(sv));
         else
@@ -1678,6 +1694,7 @@ Perl_debop(pTHX_ const OP *o)
 STATIC CV*
 S_deb_curcv(pTHX_ I32 ix)
 {
+    dVAR;
     const PERL_CONTEXT *cx = &cxstack[ix];
     if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT)
         return cx->blk_sub.cv;
@@ -1686,7 +1703,7 @@ S_deb_curcv(pTHX_ I32 ix)
     else if (ix == 0 && PL_curstackinfo->si_type == PERLSI_MAIN)
         return PL_main_cv;
     else if (ix <= 0)
-        return Nullcv;
+        return NULL;
     else
         return deb_curcv(ix - 1);
 }
@@ -1694,6 +1711,7 @@ S_deb_curcv(pTHX_ I32 ix)
 void
 Perl_watch(pTHX_ char **addr)
 {
+    dVAR;
     PL_watchaddr = addr;
     PL_watchok = *addr;
     PerlIO_printf(Perl_debug_log, "WATCHING, %"UVxf" is currently %"UVxf"\n",
@@ -1703,6 +1721,7 @@ Perl_watch(pTHX_ char **addr)
 STATIC void
 S_debprof(pTHX_ const OP *o)
 {
+    dVAR;
     if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
        return;
     if (!PL_profiledata)
@@ -1713,6 +1732,7 @@ S_debprof(pTHX_ const OP *o)
 void
 Perl_debprofdump(pTHX)
 {
+    dVAR;
     unsigned i;
     if (!PL_profiledata)
        return;