3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 * 2000, 2001, 2002, 2003, by Larry Wall and others
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
12 * "For the fashion of Minas Tirith was such that it was built on seven
17 #define PERL_IN_SCOPE_C
20 #if defined(PERL_FLEXIBLE_EXCEPTIONS)
22 Perl_default_protect(pTHX_ volatile JMPENV *pcur_env, int *excpt,
23 protect_body_t body, ...)
28 ret = vdefault_protect(pcur_env, excpt, body, &args);
34 Perl_vdefault_protect(pTHX_ volatile JMPENV *pcur_env, int *excpt,
35 protect_body_t body, va_list *args)
44 ret = CALL_FPTR(body)(aTHX_ *args);
52 Perl_stack_grow(pTHX_ SV **sp, SV **p, int n)
55 #ifndef STRESS_REALLOC
56 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 128);
58 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 1);
63 #ifndef STRESS_REALLOC
64 #define GROW(old) ((old) * 3 / 2)
66 #define GROW(old) ((old) + 1)
70 Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
73 New(56, si, 1, PERL_SI);
74 si->si_stack = newAV();
75 AvREAL_off(si->si_stack);
76 av_extend(si->si_stack, stitems > 0 ? stitems-1 : 0);
77 AvALLOC(si->si_stack)[0] = &PL_sv_undef;
78 AvFILLp(si->si_stack) = 0;
81 si->si_cxmax = cxitems - 1;
83 si->si_type = PERLSI_UNDEF;
84 New(56, si->si_cxstack, cxitems, PERL_CONTEXT);
85 /* Without any kind of initialising PUSHSUBST()
86 * in pp_subst() will read uninitialised heap. */
87 Poison(si->si_cxstack, cxitems, PERL_CONTEXT);
94 IV old_max = cxstack_max;
95 cxstack_max = GROW(cxstack_max);
96 Renew(cxstack, cxstack_max + 1, PERL_CONTEXT); /* XXX should fix CXINC macro */
97 /* Without any kind of initialising deep enough recursion
98 * will end up reading uninitialised PERL_CONTEXTs. */
99 Poison(cxstack + old_max + 1, cxstack_max - old_max, PERL_CONTEXT);
100 return cxstack_ix + 1;
104 Perl_push_return(pTHX_ OP *retop)
106 if (PL_retstack_ix == PL_retstack_max) {
107 PL_retstack_max = GROW(PL_retstack_max);
108 Renew(PL_retstack, PL_retstack_max, OP*);
110 PL_retstack[PL_retstack_ix++] = retop;
114 Perl_pop_return(pTHX)
116 if (PL_retstack_ix > 0)
117 return PL_retstack[--PL_retstack_ix];
123 Perl_push_scope(pTHX)
125 if (PL_scopestack_ix == PL_scopestack_max) {
126 PL_scopestack_max = GROW(PL_scopestack_max);
127 Renew(PL_scopestack, PL_scopestack_max, I32);
129 PL_scopestack[PL_scopestack_ix++] = PL_savestack_ix;
136 I32 oldsave = PL_scopestack[--PL_scopestack_ix];
137 LEAVE_SCOPE(oldsave);
141 Perl_markstack_grow(pTHX)
143 I32 oldmax = PL_markstack_max - PL_markstack;
144 I32 newmax = GROW(oldmax);
146 Renew(PL_markstack, newmax, I32);
147 PL_markstack_ptr = PL_markstack + oldmax;
148 PL_markstack_max = PL_markstack + newmax;
152 Perl_savestack_grow(pTHX)
154 PL_savestack_max = GROW(PL_savestack_max) + 4;
155 Renew(PL_savestack, PL_savestack_max, ANY);
159 Perl_savestack_grow_cnt(pTHX_ I32 need)
161 PL_savestack_max = PL_savestack_ix + need;
162 Renew(PL_savestack, PL_savestack_max, ANY);
168 Perl_tmps_grow(pTHX_ I32 n)
170 #ifndef STRESS_REALLOC
172 n = (PL_tmps_max < 512) ? 128 : 512;
174 PL_tmps_max = PL_tmps_ix + n + 1;
175 Renew(PL_tmps_stack, PL_tmps_max, SV*);
182 /* XXX should tmps_floor live in cxstack? */
183 I32 myfloor = PL_tmps_floor;
184 while (PL_tmps_ix > myfloor) { /* clean up after last statement */
185 SV* sv = PL_tmps_stack[PL_tmps_ix];
186 PL_tmps_stack[PL_tmps_ix--] = Nullsv;
187 if (sv && sv != &PL_sv_undef) {
189 SvREFCNT_dec(sv); /* note, can modify tmps_ix!!! */
195 S_save_scalar_at(pTHX_ SV **sptr)
200 sv = *sptr = NEWSV(0,0);
201 if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) {
202 sv_upgrade(sv, SvTYPE(osv));
203 if (SvGMAGICAL(osv)) {
205 bool oldtainted = PL_tainted;
206 mg_get(osv); /* note, can croak! */
207 if (PL_tainting && PL_tainted &&
208 (mg = mg_find(osv, PERL_MAGIC_taint))) {
209 SAVESPTR(mg->mg_obj);
212 SvFLAGS(osv) |= (SvFLAGS(osv) &
213 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
214 PL_tainted = oldtainted;
216 SvMAGIC(sv) = SvMAGIC(osv);
217 SvFLAGS(sv) |= SvMAGICAL(osv) | SvREADONLY(osv);
218 /* XXX SvMAGIC() is *shared* between osv and sv. This can
219 * lead to coredumps when both SVs are destroyed without one
220 * of their SvMAGIC() slots being NULLed. */
229 Perl_save_scalar(pTHX_ GV *gv)
231 SV **sptr = &GvSV(gv);
233 SSPUSHPTR(SvREFCNT_inc(gv));
234 SSPUSHPTR(SvREFCNT_inc(*sptr));
236 return save_scalar_at(sptr);
240 Perl_save_svref(pTHX_ SV **sptr)
244 SSPUSHPTR(SvREFCNT_inc(*sptr));
245 SSPUSHINT(SAVEt_SVREF);
246 return save_scalar_at(sptr);
249 /* Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to
250 * restore a global SV to its prior contents, freeing new value. */
252 Perl_save_generic_svref(pTHX_ SV **sptr)
256 SSPUSHPTR(SvREFCNT_inc(*sptr));
257 SSPUSHINT(SAVEt_GENERIC_SVREF);
260 /* Like save_pptr(), but also Safefree()s the new value if it is different
261 * from the old one. Can be used to restore a global char* to its prior
262 * contents, freeing new value. */
264 Perl_save_generic_pvref(pTHX_ char **str)
269 SSPUSHINT(SAVEt_GENERIC_PVREF);
272 /* Like save_generic_pvref(), but uses PerlMemShared_free() rather than Safefree().
273 * Can be used to restore a shared global char* to its prior
274 * contents, freeing new value. */
276 Perl_save_shared_pvref(pTHX_ char **str)
281 SSPUSHINT(SAVEt_SHARED_PVREF);
284 /* set the SvFLAGS specified by mask to the values in val */
287 Perl_save_set_svflags(pTHX_ SV* sv, U32 mask, U32 val)
293 SSPUSHINT(SAVEt_SET_SVFLAGS);
297 Perl_save_gp(pTHX_ GV *gv, I32 empty)
300 SSPUSHIV((IV)SvLEN(gv));
301 SvLEN(gv) = 0; /* forget that anything was allocated here */
302 SSPUSHIV((IV)SvCUR(gv));
303 SSPUSHPTR(SvPVX(gv));
305 SSPUSHPTR(SvREFCNT_inc(gv));
312 Newz(602, gp, 1, GP);
315 PL_sub_generation++; /* taking a method out of circulation */
316 if (GvIOp(gv) && (IoFLAGS(GvIOp(gv)) & IOf_ARGV)) {
318 IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
320 GvGP(gv) = gp_ref(gp);
321 GvSV(gv) = NEWSV(72,0);
322 GvLINE(gv) = CopLINE(PL_curcop);
323 GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : "";
333 Perl_save_ary(pTHX_ GV *gv)
338 if (!AvREAL(oav) && AvREIFY(oav))
345 GvAV(gv) = Null(AV*);
348 SvMAGIC(av) = SvMAGIC(oav);
349 SvFLAGS((SV*)av) |= SvMAGICAL(oav);
360 Perl_save_hash(pTHX_ GV *gv)
366 SSPUSHPTR(ohv = GvHVn(gv));
369 GvHV(gv) = Null(HV*);
372 SvMAGIC(hv) = SvMAGIC(ohv);
373 SvFLAGS((SV*)hv) |= SvMAGICAL(ohv);
384 Perl_save_item(pTHX_ register SV *item)
386 register SV *sv = NEWSV(0,0);
390 SSPUSHPTR(item); /* remember the pointer */
391 SSPUSHPTR(sv); /* remember the value */
392 SSPUSHINT(SAVEt_ITEM);
396 Perl_save_int(pTHX_ int *intp)
401 SSPUSHINT(SAVEt_INT);
405 Perl_save_long(pTHX_ long int *longp)
410 SSPUSHINT(SAVEt_LONG);
414 Perl_save_bool(pTHX_ bool *boolp)
419 SSPUSHINT(SAVEt_BOOL);
423 Perl_save_I32(pTHX_ I32 *intp)
428 SSPUSHINT(SAVEt_I32);
432 Perl_save_I16(pTHX_ I16 *intp)
437 SSPUSHINT(SAVEt_I16);
441 Perl_save_I8(pTHX_ I8 *bytep)
450 Perl_save_iv(pTHX_ IV *ivp)
458 /* Cannot use save_sptr() to store a char* since the SV** cast will
459 * force word-alignment and we'll miss the pointer.
462 Perl_save_pptr(pTHX_ char **pptr)
467 SSPUSHINT(SAVEt_PPTR);
471 Perl_save_vptr(pTHX_ void *ptr)
474 SSPUSHPTR(*(char**)ptr);
476 SSPUSHINT(SAVEt_VPTR);
480 Perl_save_sptr(pTHX_ SV **sptr)
485 SSPUSHINT(SAVEt_SPTR);
489 Perl_save_padsv(pTHX_ PADOFFSET off)
492 ASSERT_CURPAD_ACTIVE("save_padsv");
493 SSPUSHPTR(PL_curpad[off]);
494 SSPUSHPTR(PL_comppad);
495 SSPUSHLONG((long)off);
496 SSPUSHINT(SAVEt_PADSV);
500 Perl_save_threadsv(pTHX_ PADOFFSET i)
502 Perl_croak(aTHX_ "panic: save_threadsv called in non-threaded perl");
507 Perl_save_nogv(pTHX_ GV *gv)
511 SSPUSHINT(SAVEt_NSTAB);
515 Perl_save_hptr(pTHX_ HV **hptr)
520 SSPUSHINT(SAVEt_HPTR);
524 Perl_save_aptr(pTHX_ AV **aptr)
529 SSPUSHINT(SAVEt_APTR);
533 Perl_save_freesv(pTHX_ SV *sv)
537 SSPUSHINT(SAVEt_FREESV);
541 Perl_save_mortalizesv(pTHX_ SV *sv)
545 SSPUSHINT(SAVEt_MORTALIZESV);
549 Perl_save_freeop(pTHX_ OP *o)
553 SSPUSHINT(SAVEt_FREEOP);
557 Perl_save_freepv(pTHX_ char *pv)
561 SSPUSHINT(SAVEt_FREEPV);
565 Perl_save_clearsv(pTHX_ SV **svp)
567 ASSERT_CURPAD_ACTIVE("save_clearsv");
569 SSPUSHLONG((long)(svp-PL_curpad));
570 SSPUSHINT(SAVEt_CLEARSV);
571 SvPADSTALE_off(*svp); /* mark lexical as active */
575 Perl_save_delete(pTHX_ HV *hv, char *key, I32 klen)
580 SSPUSHPTR(SvREFCNT_inc(hv));
581 SSPUSHINT(SAVEt_DELETE);
585 Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
590 for (i = 1; i <= maxsarg; i++) {
592 sv_setsv(sv,sarg[i]);
594 SSPUSHPTR(sarg[i]); /* remember the pointer */
595 SSPUSHPTR(sv); /* remember the value */
596 SSPUSHINT(SAVEt_ITEM);
601 Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p)
606 SSPUSHINT(SAVEt_DESTRUCTOR);
610 Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
615 SSPUSHINT(SAVEt_DESTRUCTOR_X);
619 Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
623 SSPUSHPTR(SvREFCNT_inc(av));
625 SSPUSHPTR(SvREFCNT_inc(*sptr));
626 SSPUSHINT(SAVEt_AELEM);
627 /* if it gets reified later, the restore will have the wrong refcnt */
628 if (!AvREAL(av) && AvREIFY(av))
630 save_scalar_at(sptr);
632 /* If we're localizing a tied array element, this new sv
633 * won't actually be stored in the array - so it won't get
634 * reaped when the localize ends. Ensure it gets reaped by
635 * mortifying it instead. DAPM */
636 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
641 Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
645 SSPUSHPTR(SvREFCNT_inc(hv));
646 SSPUSHPTR(SvREFCNT_inc(key));
647 SSPUSHPTR(SvREFCNT_inc(*sptr));
648 SSPUSHINT(SAVEt_HELEM);
649 save_scalar_at(sptr);
651 /* If we're localizing a tied hash element, this new sv
652 * won't actually be stored in the hash - so it won't get
653 * reaped when the localize ends. Ensure it gets reaped by
654 * mortifying it instead. DAPM */
655 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
668 Perl_save_alloc(pTHX_ I32 size, I32 pad)
670 register I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
671 - (char*)PL_savestack);
672 register I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
674 /* SSCHECK may not be good enough */
675 while (PL_savestack_ix + elems + 2 > PL_savestack_max)
678 PL_savestack_ix += elems;
680 SSPUSHINT(SAVEt_ALLOC);
685 Perl_leave_scope(pTHX_ I32 base)
697 Perl_croak(aTHX_ "panic: corrupt saved stack index");
698 while (PL_savestack_ix > base) {
700 case SAVEt_ITEM: /* normal string */
701 value = (SV*)SSPOPPTR;
703 sv_replace(sv,value);
708 case SAVEt_SV: /* scalar reference */
709 value = (SV*)SSPOPPTR;
712 av = (AV*)gv; /* what to refcnt_dec */
714 case SAVEt_GENERIC_PVREF: /* generic pv */
715 str = (char*)SSPOPPTR;
717 if (*(char**)ptr != str) {
718 Safefree(*(char**)ptr);
722 case SAVEt_SHARED_PVREF: /* shared pv */
723 str = (char*)SSPOPPTR;
725 if (*(char**)ptr != str) {
727 PerlMem_free(*(char**)ptr);
729 PerlMemShared_free(*(char**)ptr);
734 case SAVEt_GENERIC_SVREF: /* generic sv */
735 value = (SV*)SSPOPPTR;
742 case SAVEt_SVREF: /* scalar reference */
743 value = (SV*)SSPOPPTR;
745 av = Nullav; /* what to refcnt_dec */
748 DEBUG_S(PerlIO_printf(Perl_debug_log,
749 "restore svref: %p %p:%s -> %p:%s\n",
750 ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
751 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
752 SvTYPE(sv) != SVt_PVGV)
754 (void)SvUPGRADE(value, SvTYPE(sv));
755 SvMAGIC(value) = SvMAGIC(sv);
756 SvFLAGS(value) |= SvMAGICAL(sv);
760 /* XXX This branch is pretty bogus. This code irretrievably
761 * clears(!) the magic on the SV (either to avoid further
762 * croaking that might ensue when the SvSETMAGIC() below is
763 * called, or to avoid two different SVs pointing at the same
764 * SvMAGIC()). This needs a total rethink. --GSAR */
765 else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
766 SvTYPE(value) != SVt_PVGV)
768 SvFLAGS(value) |= (SvFLAGS(value) &
769 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
770 SvMAGICAL_off(value);
771 /* XXX this is a leak when we get here because the
772 * mg_get() in save_scalar_at() croaked */
781 if (av) /* actually an av, hv or gv */
784 case SAVEt_AV: /* array reference */
788 AV *goner = GvAV(gv);
789 SvMAGIC(av) = SvMAGIC(goner);
790 SvFLAGS((SV*)av) |= SvMAGICAL(goner);
791 SvMAGICAL_off(goner);
802 case SAVEt_HV: /* hash reference */
806 HV *goner = GvHV(gv);
807 SvMAGIC(hv) = SvMAGIC(goner);
808 SvFLAGS(hv) |= SvMAGICAL(goner);
809 SvMAGICAL_off(goner);
820 case SAVEt_INT: /* int reference */
822 *(int*)ptr = (int)SSPOPINT;
824 case SAVEt_LONG: /* long reference */
826 *(long*)ptr = (long)SSPOPLONG;
828 case SAVEt_BOOL: /* bool reference */
830 *(bool*)ptr = (bool)SSPOPBOOL;
832 case SAVEt_I32: /* I32 reference */
834 *(I32*)ptr = (I32)SSPOPINT;
836 case SAVEt_I16: /* I16 reference */
838 *(I16*)ptr = (I16)SSPOPINT;
840 case SAVEt_I8: /* I8 reference */
842 *(I8*)ptr = (I8)SSPOPINT;
844 case SAVEt_IV: /* IV reference */
846 *(IV*)ptr = (IV)SSPOPIV;
848 case SAVEt_SPTR: /* SV* reference */
850 *(SV**)ptr = (SV*)SSPOPPTR;
852 case SAVEt_VPTR: /* random* reference */
853 case SAVEt_PPTR: /* char* reference */
855 *(char**)ptr = (char*)SSPOPPTR;
857 case SAVEt_HPTR: /* HV* reference */
859 *(HV**)ptr = (HV*)SSPOPPTR;
861 case SAVEt_APTR: /* AV* reference */
863 *(AV**)ptr = (AV*)SSPOPPTR;
867 (void)sv_clear((SV*)gv);
869 case SAVEt_GP: /* scalar reference */
872 if (SvPVX(gv) && SvLEN(gv) > 0) {
875 SvPVX(gv) = (char *)SSPOPPTR;
876 SvCUR(gv) = (STRLEN)SSPOPIV;
877 SvLEN(gv) = (STRLEN)SSPOPIV;
881 PL_sub_generation++; /* putting a method back into circulation */
886 SvREFCNT_dec((SV*)ptr);
888 case SAVEt_MORTALIZESV:
890 sv_2mortal((SV*)ptr);
894 ASSERT_CURPAD_LEGAL("SAVEt_FREEOP"); /* XXX DAPM tmp */
899 Safefree((char*)ptr);
902 ptr = (void*)&PL_curpad[SSPOPLONG];
905 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
906 "Pad 0x%"UVxf"[0x%"UVxf"] clearsv: %ld sv=0x%"UVxf"<%"IVdf"> %s\n",
907 PTR2UV(PL_comppad), PTR2UV(PL_curpad),
908 (long)((SV **)ptr-PL_curpad), PTR2UV(sv), (IV)SvREFCNT(sv),
909 (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) ? "clear" : "abandon"
912 /* Can clear pad variable in place? */
913 if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
915 * if a my variable that was made readonly is going out of
916 * scope, we want to remove the readonlyness so that it can
917 * go out of scope quietly
919 if (SvPADMY(sv) && !SvFAKE(sv))
922 if (SvTHINKFIRST(sv))
923 sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
927 switch (SvTYPE(sv)) {
937 Perl_croak(aTHX_ "panic: leave_scope pad code");
948 SvPADSTALE_on(sv); /* mark as no longer live */
950 else { /* Someone has a claim on this, so abandon it. */
951 U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP);
952 switch (SvTYPE(sv)) { /* Console ourselves with a new value */
953 case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
954 case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
955 default: *(SV**)ptr = NEWSV(0,0); break;
957 SvREFCNT_dec(sv); /* Cast current value to the winds. */
958 /* preserve pad nature, but also mark as not live
959 * for any closure capturing */
960 SvFLAGS(*(SV**)ptr) |= padflags | SVs_PADSTALE;
967 (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
971 case SAVEt_DESTRUCTOR:
975 case SAVEt_DESTRUCTOR_X:
977 (*SSPOPDXPTR)(aTHX_ ptr);
979 case SAVEt_REGCONTEXT:
982 PL_savestack_ix -= i; /* regexp must have croaked */
984 case SAVEt_STACK_POS: /* Position on Perl stack */
986 PL_stack_sp = PL_stack_base + i;
988 case SAVEt_AELEM: /* array element */
989 value = (SV*)SSPOPPTR;
992 if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
994 ptr = av_fetch(av,i,1);
997 if (sv && sv != &PL_sv_undef) {
998 if (SvTIED_mg((SV*)av, PERL_MAGIC_tied))
999 (void)SvREFCNT_inc(sv);
1004 SvREFCNT_dec(value);
1006 case SAVEt_HELEM: /* hash element */
1007 value = (SV*)SSPOPPTR;
1010 ptr = hv_fetch_ent(hv, sv, 1, 0);
1012 SV *oval = HeVAL((HE*)ptr);
1013 if (oval && oval != &PL_sv_undef) {
1014 ptr = &HeVAL((HE*)ptr);
1015 if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
1016 (void)SvREFCNT_inc(*(SV**)ptr);
1018 av = (AV*)hv; /* what to refcnt_dec */
1024 SvREFCNT_dec(value);
1027 PL_op = (OP*)SSPOPPTR;
1030 if ((PL_hints & HINT_LOCALIZE_HH) && GvHV(PL_hintgv)) {
1031 SvREFCNT_dec((SV*)GvHV(PL_hintgv));
1032 GvHV(PL_hintgv) = NULL;
1034 *(I32*)&PL_hints = (I32)SSPOPINT;
1037 PL_comppad = (PAD*)SSPOPPTR;
1039 PL_curpad = AvARRAY(PL_comppad);
1041 PL_curpad = Null(SV**);
1045 PADOFFSET off = (PADOFFSET)SSPOPLONG;
1048 AvARRAY((PAD*)ptr)[off] = (SV*)SSPOPPTR;
1051 case SAVEt_SET_SVFLAGS:
1053 U32 val = (U32)SSPOPINT;
1054 U32 mask = (U32)SSPOPINT;
1056 SvFLAGS(sv) &= ~mask;
1061 Perl_croak(aTHX_ "panic: leave_scope inconsistency");
1067 Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
1070 PerlIO_printf(Perl_debug_log, "CX %ld = %s\n", (long)(cx - cxstack), PL_block_type[CxTYPE(cx)]);
1071 if (CxTYPE(cx) != CXt_SUBST) {
1072 PerlIO_printf(Perl_debug_log, "BLK_OLDSP = %ld\n", (long)cx->blk_oldsp);
1073 PerlIO_printf(Perl_debug_log, "BLK_OLDCOP = 0x%"UVxf"\n",
1074 PTR2UV(cx->blk_oldcop));
1075 PerlIO_printf(Perl_debug_log, "BLK_OLDMARKSP = %ld\n", (long)cx->blk_oldmarksp);
1076 PerlIO_printf(Perl_debug_log, "BLK_OLDSCOPESP = %ld\n", (long)cx->blk_oldscopesp);
1077 PerlIO_printf(Perl_debug_log, "BLK_OLDRETSP = %ld\n", (long)cx->blk_oldretsp);
1078 PerlIO_printf(Perl_debug_log, "BLK_OLDPM = 0x%"UVxf"\n",
1079 PTR2UV(cx->blk_oldpm));
1080 PerlIO_printf(Perl_debug_log, "BLK_GIMME = %s\n", cx->blk_gimme ? "LIST" : "SCALAR");
1082 switch (CxTYPE(cx)) {
1087 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1088 PTR2UV(cx->blk_sub.cv));
1089 PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%"UVxf"\n",
1090 PTR2UV(cx->blk_sub.gv));
1091 PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
1092 PTR2UV(cx->blk_sub.dfoutgv));
1093 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1094 (int)cx->blk_sub.hasargs);
1097 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1098 PTR2UV(cx->blk_sub.cv));
1099 PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n",
1100 (long)cx->blk_sub.olddepth);
1101 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1102 (int)cx->blk_sub.hasargs);
1103 PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
1104 (int)cx->blk_sub.lval);
1107 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_IN_EVAL = %ld\n",
1108 (long)cx->blk_eval.old_in_eval);
1109 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n",
1110 PL_op_name[cx->blk_eval.old_op_type],
1111 PL_op_desc[cx->blk_eval.old_op_type]);
1112 if (cx->blk_eval.old_namesv)
1113 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
1114 SvPVX(cx->blk_eval.old_namesv));
1115 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
1116 PTR2UV(cx->blk_eval.old_eval_root));
1120 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n",
1121 cx->blk_loop.label);
1122 PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n",
1123 (long)cx->blk_loop.resetsp);
1124 PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%"UVxf"\n",
1125 PTR2UV(cx->blk_loop.redo_op));
1126 PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%"UVxf"\n",
1127 PTR2UV(cx->blk_loop.next_op));
1128 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%"UVxf"\n",
1129 PTR2UV(cx->blk_loop.last_op));
1130 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
1131 (long)cx->blk_loop.iterix);
1132 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
1133 PTR2UV(cx->blk_loop.iterary));
1134 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
1135 PTR2UV(CxITERVAR(cx)));
1137 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
1138 PTR2UV(cx->blk_loop.itersave));
1139 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERLVAL = 0x%"UVxf"\n",
1140 PTR2UV(cx->blk_loop.iterlval));
1144 PerlIO_printf(Perl_debug_log, "SB_ITERS = %ld\n",
1145 (long)cx->sb_iters);
1146 PerlIO_printf(Perl_debug_log, "SB_MAXITERS = %ld\n",
1147 (long)cx->sb_maxiters);
1148 PerlIO_printf(Perl_debug_log, "SB_RFLAGS = %ld\n",
1149 (long)cx->sb_rflags);
1150 PerlIO_printf(Perl_debug_log, "SB_ONCE = %ld\n",
1152 PerlIO_printf(Perl_debug_log, "SB_ORIG = %s\n",
1154 PerlIO_printf(Perl_debug_log, "SB_DSTR = 0x%"UVxf"\n",
1155 PTR2UV(cx->sb_dstr));
1156 PerlIO_printf(Perl_debug_log, "SB_TARG = 0x%"UVxf"\n",
1157 PTR2UV(cx->sb_targ));
1158 PerlIO_printf(Perl_debug_log, "SB_S = 0x%"UVxf"\n",
1160 PerlIO_printf(Perl_debug_log, "SB_M = 0x%"UVxf"\n",
1162 PerlIO_printf(Perl_debug_log, "SB_STREND = 0x%"UVxf"\n",
1163 PTR2UV(cx->sb_strend));
1164 PerlIO_printf(Perl_debug_log, "SB_RXRES = 0x%"UVxf"\n",
1165 PTR2UV(cx->sb_rxres));
1168 #endif /* DEBUGGING */