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 * "'You have talked long in your sleep, Frodo,' said Gandalf gently, 'and
13 * it has not been hard for me to read your mind and memory.'"
17 #define PERL_IN_DUMP_C
22 Perl_dump_indent(pTHX_ I32 level, PerlIO *file, const char* pat, ...)
26 dump_vindent(level, file, pat, &args);
31 Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args)
33 PerlIO_printf(file, "%*s", (int)(level*PL_dumpindent), "");
34 PerlIO_vprintf(file, pat, *args);
40 PerlIO_setlinebuf(Perl_debug_log);
42 op_dump(PL_main_root);
43 dump_packsubs(PL_defstash);
47 Perl_dump_packsubs(pTHX_ HV *stash)
54 for (i = 0; i <= (I32) HvMAX(stash); i++) {
55 for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) {
56 GV *gv = (GV*)HeVAL(entry);
58 if (SvTYPE(gv) != SVt_PVGV || !GvGP(gv))
64 if (HeKEY(entry)[HeKLEN(entry)-1] == ':'
65 && (hv = GvHV(gv)) && hv != PL_defstash)
66 dump_packsubs(hv); /* nested package */
72 Perl_dump_sub(pTHX_ GV *gv)
74 SV *sv = sv_newmortal();
76 gv_fullname3(sv, gv, Nullch);
77 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nSUB %s = ", SvPVX(sv));
79 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "(xsub 0x%"UVxf" %d)\n",
80 PTR2UV(CvXSUB(GvCV(gv))),
81 (int)CvXSUBANY(GvCV(gv)).any_i32);
82 else if (CvROOT(GvCV(gv)))
83 op_dump(CvROOT(GvCV(gv)));
85 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "<undef>\n");
89 Perl_dump_form(pTHX_ GV *gv)
91 SV *sv = sv_newmortal();
93 gv_fullname3(sv, gv, Nullch);
94 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nFORMAT %s = ", SvPVX(sv));
95 if (CvROOT(GvFORM(gv)))
96 op_dump(CvROOT(GvFORM(gv)));
98 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "<undef>\n");
104 op_dump(PL_eval_root);
108 Perl_pv_display(pTHX_ SV *dsv, char *pv, STRLEN cur, STRLEN len, STRLEN pvlim)
111 int nul_terminated = len > cur && pv[cur] == '\0';
113 sv_setpvn(dsv, "\"", 1);
114 for (; cur--; pv++) {
115 if (pvlim && SvCUR(dsv) >= pvlim) {
121 case '\t': sv_catpvn(dsv, "\\t", 2); break;
122 case '\n': sv_catpvn(dsv, "\\n", 2); break;
123 case '\r': sv_catpvn(dsv, "\\r", 2); break;
124 case '\f': sv_catpvn(dsv, "\\f", 2); break;
125 case '"': sv_catpvn(dsv, "\\\"", 2); break;
126 case '\\': sv_catpvn(dsv, "\\\\", 2); break;
127 default: sv_catpvn(dsv, pv, 1); break;
131 if (cur && isDIGIT(*(pv+1)))
132 Perl_sv_catpvf(aTHX_ dsv, "\\%03o", (U8)*pv);
134 Perl_sv_catpvf(aTHX_ dsv, "\\%o", (U8)*pv);
137 sv_catpvn(dsv, "\"", 1);
139 sv_catpvn(dsv, "...", 3);
141 sv_catpvn(dsv, "\\0", 2);
147 Perl_sv_peek(pTHX_ SV *sv)
149 SV *t = sv_newmortal();
159 else if (sv == (SV*)0x55555555 || SvTYPE(sv) == 'U') {
163 else if (sv == &PL_sv_undef || sv == &PL_sv_no || sv == &PL_sv_yes || sv == &PL_sv_placeholder) {
164 if (sv == &PL_sv_undef) {
165 sv_catpv(t, "SV_UNDEF");
166 if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|
167 SVs_GMG|SVs_SMG|SVs_RMG)) &&
171 else if (sv == &PL_sv_no) {
172 sv_catpv(t, "SV_NO");
173 if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
174 SVs_GMG|SVs_SMG|SVs_RMG)) &&
175 !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
181 else if (sv == &PL_sv_yes) {
182 sv_catpv(t, "SV_YES");
183 if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
184 SVs_GMG|SVs_SMG|SVs_RMG)) &&
185 !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
188 SvPVX(sv) && *SvPVX(sv) == '1' &&
193 sv_catpv(t, "SV_PLACEHOLDER");
194 if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|
195 SVs_GMG|SVs_SMG|SVs_RMG)) &&
201 else if (SvREFCNT(sv) == 0) {
205 else if (DEBUG_R_TEST_) {
208 /* is this SV on the tmps stack? */
209 for (ix=PL_tmps_ix; ix>=0; ix--) {
210 if (PL_tmps_stack[ix] == sv) {
215 if (SvREFCNT(sv) > 1)
216 Perl_sv_catpvf(aTHX_ t, "<%"UVuf"%s>", (UV)SvREFCNT(sv),
224 if (SvCUR(t) + unref > 10) {
225 SvCUR(t) = unref + 3;
233 switch (SvTYPE(sv)) {
235 sv_catpv(t, "FREED");
239 sv_catpv(t, "UNDEF");
273 Perl_sv_catpvf(aTHX_ t, "CV(%s)", GvNAME(CvGV(sv)));
293 sv_catpv(t, "(null)");
295 SV *tmp = newSVpvn("", 0);
298 Perl_sv_catpvf(aTHX_ t, "[%s]", pv_display(tmp, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, 127));
299 Perl_sv_catpvf(aTHX_ t, "%s)", pv_display(tmp, SvPVX(sv), SvCUR(sv), SvLEN(sv), 127));
301 Perl_sv_catpvf(aTHX_ t, " [UTF8 \"%s\"]",
302 sv_uni_display(tmp, sv, 8 * sv_len_utf8(sv),
307 else if (SvNOKp(sv)) {
308 STORE_NUMERIC_LOCAL_SET_STANDARD();
309 Perl_sv_catpvf(aTHX_ t, "(%"NVgf")",SvNVX(sv));
310 RESTORE_NUMERIC_LOCAL();
312 else if (SvIOKp(sv)) {
314 Perl_sv_catpvf(aTHX_ t, "(%"UVuf")", (UV)SvUVX(sv));
316 Perl_sv_catpvf(aTHX_ t, "(%"IVdf")", (IV)SvIVX(sv));
330 Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm)
335 Perl_dump_indent(aTHX_ level, file, "{}\n");
338 Perl_dump_indent(aTHX_ level, file, "{\n");
340 if (pm->op_pmflags & PMf_ONCE)
345 Perl_dump_indent(aTHX_ level, file, "PMf_PRE %c%s%c%s\n",
346 ch, PM_GETRE(pm)->precomp, ch,
347 (pm->op_private & OPpRUNTIME) ? " (RUNTIME)" : "");
349 Perl_dump_indent(aTHX_ level, file, "PMf_PRE (RUNTIME)\n");
350 if (pm->op_type != OP_PUSHRE && pm->op_pmreplroot) {
351 Perl_dump_indent(aTHX_ level, file, "PMf_REPL = ");
352 op_dump(pm->op_pmreplroot);
354 if (pm->op_pmflags || (PM_GETRE(pm) && PM_GETRE(pm)->check_substr)) {
355 SV *tmpsv = newSVpvn("", 0);
356 if (pm->op_pmdynflags & PMdf_USED)
357 sv_catpv(tmpsv, ",USED");
358 if (pm->op_pmdynflags & PMdf_TAINTED)
359 sv_catpv(tmpsv, ",TAINTED");
360 if (pm->op_pmflags & PMf_ONCE)
361 sv_catpv(tmpsv, ",ONCE");
362 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
363 && !(PM_GETRE(pm)->reganch & ROPT_NOSCAN))
364 sv_catpv(tmpsv, ",SCANFIRST");
365 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
366 && PM_GETRE(pm)->reganch & ROPT_CHECK_ALL)
367 sv_catpv(tmpsv, ",ALL");
368 if (pm->op_pmflags & PMf_SKIPWHITE)
369 sv_catpv(tmpsv, ",SKIPWHITE");
370 if (pm->op_pmflags & PMf_CONST)
371 sv_catpv(tmpsv, ",CONST");
372 if (pm->op_pmflags & PMf_KEEP)
373 sv_catpv(tmpsv, ",KEEP");
374 if (pm->op_pmflags & PMf_GLOBAL)
375 sv_catpv(tmpsv, ",GLOBAL");
376 if (pm->op_pmflags & PMf_CONTINUE)
377 sv_catpv(tmpsv, ",CONTINUE");
378 if (pm->op_pmflags & PMf_RETAINT)
379 sv_catpv(tmpsv, ",RETAINT");
380 if (pm->op_pmflags & PMf_EVAL)
381 sv_catpv(tmpsv, ",EVAL");
382 Perl_dump_indent(aTHX_ level, file, "PMFLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
386 Perl_dump_indent(aTHX_ level-1, file, "}\n");
390 Perl_pmop_dump(pTHX_ PMOP *pm)
392 do_pmop_dump(0, Perl_debug_log, pm);
396 Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, OP *o)
398 Perl_dump_indent(aTHX_ level, file, "{\n");
401 PerlIO_printf(file, "%-4d", o->op_seq);
403 PerlIO_printf(file, " ");
405 "%*sTYPE = %s ===> ",
406 (int)(PL_dumpindent*level-4), "", OP_NAME(o));
409 PerlIO_printf(file, "%d\n", o->op_next->op_seq);
411 PerlIO_printf(file, "(%d)\n", o->op_next->op_seq);
414 PerlIO_printf(file, "DONE\n");
416 if (o->op_type == OP_NULL)
418 Perl_dump_indent(aTHX_ level, file, " (was %s)\n", PL_op_name[o->op_targ]);
419 if (o->op_targ == OP_NEXTSTATE)
422 Perl_dump_indent(aTHX_ level, file, "LINE = %"UVf"\n",
424 if (CopSTASHPV(cCOPo))
425 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
427 if (cCOPo->cop_label)
428 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
433 Perl_dump_indent(aTHX_ level, file, "TARG = %ld\n", (long)o->op_targ);
436 Perl_dump_indent(aTHX_ level, file, "ADDR = 0x%"UVxf" => 0x%"UVxf"\n", (UV)o, (UV)o->op_next);
439 SV *tmpsv = newSVpvn("", 0);
440 switch (o->op_flags & OPf_WANT) {
442 sv_catpv(tmpsv, ",VOID");
444 case OPf_WANT_SCALAR:
445 sv_catpv(tmpsv, ",SCALAR");
448 sv_catpv(tmpsv, ",LIST");
451 sv_catpv(tmpsv, ",UNKNOWN");
454 if (o->op_flags & OPf_KIDS)
455 sv_catpv(tmpsv, ",KIDS");
456 if (o->op_flags & OPf_PARENS)
457 sv_catpv(tmpsv, ",PARENS");
458 if (o->op_flags & OPf_STACKED)
459 sv_catpv(tmpsv, ",STACKED");
460 if (o->op_flags & OPf_REF)
461 sv_catpv(tmpsv, ",REF");
462 if (o->op_flags & OPf_MOD)
463 sv_catpv(tmpsv, ",MOD");
464 if (o->op_flags & OPf_SPECIAL)
465 sv_catpv(tmpsv, ",SPECIAL");
466 Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
470 SV *tmpsv = newSVpvn("", 0);
471 if (PL_opargs[o->op_type] & OA_TARGLEX) {
472 if (o->op_private & OPpTARGET_MY)
473 sv_catpv(tmpsv, ",TARGET_MY");
475 else if (o->op_type == OP_LEAVESUB ||
476 o->op_type == OP_LEAVE ||
477 o->op_type == OP_LEAVESUBLV ||
478 o->op_type == OP_LEAVEWRITE) {
479 if (o->op_private & OPpREFCOUNTED)
480 sv_catpv(tmpsv, ",REFCOUNTED");
482 else if (o->op_type == OP_AASSIGN) {
483 if (o->op_private & OPpASSIGN_COMMON)
484 sv_catpv(tmpsv, ",COMMON");
486 else if (o->op_type == OP_SASSIGN) {
487 if (o->op_private & OPpASSIGN_BACKWARDS)
488 sv_catpv(tmpsv, ",BACKWARDS");
490 else if (o->op_type == OP_TRANS) {
491 if (o->op_private & OPpTRANS_SQUASH)
492 sv_catpv(tmpsv, ",SQUASH");
493 if (o->op_private & OPpTRANS_DELETE)
494 sv_catpv(tmpsv, ",DELETE");
495 if (o->op_private & OPpTRANS_COMPLEMENT)
496 sv_catpv(tmpsv, ",COMPLEMENT");
497 if (o->op_private & OPpTRANS_IDENTICAL)
498 sv_catpv(tmpsv, ",IDENTICAL");
499 if (o->op_private & OPpTRANS_GROWS)
500 sv_catpv(tmpsv, ",GROWS");
502 else if (o->op_type == OP_REPEAT) {
503 if (o->op_private & OPpREPEAT_DOLIST)
504 sv_catpv(tmpsv, ",DOLIST");
506 else if (o->op_type == OP_ENTERSUB ||
507 o->op_type == OP_RV2SV ||
508 o->op_type == OP_GVSV ||
509 o->op_type == OP_RV2AV ||
510 o->op_type == OP_RV2HV ||
511 o->op_type == OP_RV2GV ||
512 o->op_type == OP_AELEM ||
513 o->op_type == OP_HELEM )
515 if (o->op_type == OP_ENTERSUB) {
516 if (o->op_private & OPpENTERSUB_AMPER)
517 sv_catpv(tmpsv, ",AMPER");
518 if (o->op_private & OPpENTERSUB_DB)
519 sv_catpv(tmpsv, ",DB");
520 if (o->op_private & OPpENTERSUB_HASTARG)
521 sv_catpv(tmpsv, ",HASTARG");
522 if (o->op_private & OPpENTERSUB_NOPAREN)
523 sv_catpv(tmpsv, ",NOPAREN");
524 if (o->op_private & OPpENTERSUB_INARGS)
525 sv_catpv(tmpsv, ",INARGS");
526 if (o->op_private & OPpENTERSUB_NOMOD)
527 sv_catpv(tmpsv, ",NOMOD");
530 switch (o->op_private & OPpDEREF) {
532 sv_catpv(tmpsv, ",SV");
535 sv_catpv(tmpsv, ",AV");
538 sv_catpv(tmpsv, ",HV");
541 if (o->op_private & OPpMAYBE_LVSUB)
542 sv_catpv(tmpsv, ",MAYBE_LVSUB");
544 if (o->op_type == OP_AELEM || o->op_type == OP_HELEM) {
545 if (o->op_private & OPpLVAL_DEFER)
546 sv_catpv(tmpsv, ",LVAL_DEFER");
549 if (o->op_private & HINT_STRICT_REFS)
550 sv_catpv(tmpsv, ",STRICT_REFS");
551 if (o->op_private & OPpOUR_INTRO)
552 sv_catpv(tmpsv, ",OUR_INTRO");
555 else if (o->op_type == OP_CONST) {
556 if (o->op_private & OPpCONST_BARE)
557 sv_catpv(tmpsv, ",BARE");
558 if (o->op_private & OPpCONST_STRICT)
559 sv_catpv(tmpsv, ",STRICT");
560 if (o->op_private & OPpCONST_ARYBASE)
561 sv_catpv(tmpsv, ",ARYBASE");
562 if (o->op_private & OPpCONST_WARNING)
563 sv_catpv(tmpsv, ",WARNING");
564 if (o->op_private & OPpCONST_ENTERED)
565 sv_catpv(tmpsv, ",ENTERED");
567 else if (o->op_type == OP_FLIP) {
568 if (o->op_private & OPpFLIP_LINENUM)
569 sv_catpv(tmpsv, ",LINENUM");
571 else if (o->op_type == OP_FLOP) {
572 if (o->op_private & OPpFLIP_LINENUM)
573 sv_catpv(tmpsv, ",LINENUM");
575 else if (o->op_type == OP_RV2CV) {
576 if (o->op_private & OPpLVAL_INTRO)
577 sv_catpv(tmpsv, ",INTRO");
579 else if (o->op_type == OP_GV) {
580 if (o->op_private & OPpEARLY_CV)
581 sv_catpv(tmpsv, ",EARLY_CV");
583 else if (o->op_type == OP_LIST) {
584 if (o->op_private & OPpLIST_GUESSED)
585 sv_catpv(tmpsv, ",GUESSED");
587 else if (o->op_type == OP_DELETE) {
588 if (o->op_private & OPpSLICE)
589 sv_catpv(tmpsv, ",SLICE");
591 else if (o->op_type == OP_EXISTS) {
592 if (o->op_private & OPpEXISTS_SUB)
593 sv_catpv(tmpsv, ",EXISTS_SUB");
595 else if (o->op_type == OP_SORT) {
596 if (o->op_private & OPpSORT_NUMERIC)
597 sv_catpv(tmpsv, ",NUMERIC");
598 if (o->op_private & OPpSORT_INTEGER)
599 sv_catpv(tmpsv, ",INTEGER");
600 if (o->op_private & OPpSORT_REVERSE)
601 sv_catpv(tmpsv, ",REVERSE");
603 else if (o->op_type == OP_THREADSV) {
604 if (o->op_private & OPpDONE_SVREF)
605 sv_catpv(tmpsv, ",SVREF");
607 else if (o->op_type == OP_OPEN || o->op_type == OP_BACKTICK) {
608 if (o->op_private & OPpOPEN_IN_RAW)
609 sv_catpv(tmpsv, ",IN_RAW");
610 if (o->op_private & OPpOPEN_IN_CRLF)
611 sv_catpv(tmpsv, ",IN_CRLF");
612 if (o->op_private & OPpOPEN_OUT_RAW)
613 sv_catpv(tmpsv, ",OUT_RAW");
614 if (o->op_private & OPpOPEN_OUT_CRLF)
615 sv_catpv(tmpsv, ",OUT_CRLF");
617 else if (o->op_type == OP_EXIT) {
618 if (o->op_private & OPpEXIT_VMSISH)
619 sv_catpv(tmpsv, ",EXIT_VMSISH");
620 if (o->op_private & OPpHUSH_VMSISH)
621 sv_catpv(tmpsv, ",HUSH_VMSISH");
623 else if (o->op_type == OP_DIE) {
624 if (o->op_private & OPpHUSH_VMSISH)
625 sv_catpv(tmpsv, ",HUSH_VMSISH");
627 else if (OP_IS_FILETEST_ACCESS(o)) {
628 if (o->op_private & OPpFT_ACCESS)
629 sv_catpv(tmpsv, ",FT_ACCESS");
631 if (o->op_flags & OPf_MOD && o->op_private & OPpLVAL_INTRO)
632 sv_catpv(tmpsv, ",INTRO");
634 Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX(tmpsv) + 1);
638 switch (o->op_type) {
643 Perl_dump_indent(aTHX_ level, file, "PADIX = %" IVdf "\n", (IV)cPADOPo->op_padix);
646 SV *tmpsv = NEWSV(0,0);
650 gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, Nullch);
651 Perl_dump_indent(aTHX_ level, file, "GV = %s\n", SvPV(tmpsv, n_a));
655 Perl_dump_indent(aTHX_ level, file, "GV = NULL\n");
659 case OP_METHOD_NAMED:
660 Perl_dump_indent(aTHX_ level, file, "SV = %s\n", SvPEEK(cSVOPo_sv));
666 Perl_dump_indent(aTHX_ level, file, "LINE = %"UVf"\n",
668 if (CopSTASHPV(cCOPo))
669 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
671 if (cCOPo->cop_label)
672 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
676 Perl_dump_indent(aTHX_ level, file, "REDO ===> ");
677 if (cLOOPo->op_redoop)
678 PerlIO_printf(file, "%d\n", cLOOPo->op_redoop->op_seq);
680 PerlIO_printf(file, "DONE\n");
681 Perl_dump_indent(aTHX_ level, file, "NEXT ===> ");
682 if (cLOOPo->op_nextop)
683 PerlIO_printf(file, "%d\n", cLOOPo->op_nextop->op_seq);
685 PerlIO_printf(file, "DONE\n");
686 Perl_dump_indent(aTHX_ level, file, "LAST ===> ");
687 if (cLOOPo->op_lastop)
688 PerlIO_printf(file, "%d\n", cLOOPo->op_lastop->op_seq);
690 PerlIO_printf(file, "DONE\n");
698 Perl_dump_indent(aTHX_ level, file, "OTHER ===> ");
699 if (cLOGOPo->op_other)
700 PerlIO_printf(file, "%d\n", cLOGOPo->op_other->op_seq);
702 PerlIO_printf(file, "DONE\n");
708 do_pmop_dump(level, file, cPMOPo);
716 if (o->op_private & OPpREFCOUNTED)
717 Perl_dump_indent(aTHX_ level, file, "REFCNT = %"UVuf"\n", (UV)o->op_targ);
722 if (o->op_flags & OPf_KIDS) {
724 for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling)
725 do_op_dump(level, file, kid);
727 Perl_dump_indent(aTHX_ level-1, file, "}\n");
731 Perl_op_dump(pTHX_ OP *o)
733 do_op_dump(0, Perl_debug_log, o);
737 Perl_gv_dump(pTHX_ GV *gv)
742 PerlIO_printf(Perl_debug_log, "{}\n");
746 PerlIO_printf(Perl_debug_log, "{\n");
747 gv_fullname3(sv, gv, Nullch);
748 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "GV_NAME = %s", SvPVX(sv));
749 if (gv != GvEGV(gv)) {
750 gv_efullname3(sv, GvEGV(gv), Nullch);
751 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", SvPVX(sv));
753 PerlIO_putc(Perl_debug_log, '\n');
754 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "}\n");
758 /* map magic types to the symbolic names
759 * (with the PERL_MAGIC_ prefixed stripped)
762 static struct { char type; char *name; } magic_names[] = {
763 { PERL_MAGIC_sv, "sv(\\0)" },
764 { PERL_MAGIC_arylen, "arylen(#)" },
765 { PERL_MAGIC_glob, "glob(*)" },
766 { PERL_MAGIC_pos, "pos(.)" },
767 { PERL_MAGIC_backref, "backref(<)" },
768 { PERL_MAGIC_overload, "overload(A)" },
769 { PERL_MAGIC_bm, "bm(B)" },
770 { PERL_MAGIC_regdata, "regdata(D)" },
771 { PERL_MAGIC_env, "env(E)" },
772 { PERL_MAGIC_isa, "isa(I)" },
773 { PERL_MAGIC_dbfile, "dbfile(L)" },
774 { PERL_MAGIC_shared, "shared(N)" },
775 { PERL_MAGIC_tied, "tied(P)" },
776 { PERL_MAGIC_sig, "sig(S)" },
777 { PERL_MAGIC_uvar, "uvar(U)" },
778 { PERL_MAGIC_overload_elem, "overload_elem(a)" },
779 { PERL_MAGIC_overload_table, "overload_table(c)" },
780 { PERL_MAGIC_regdatum, "regdatum(d)" },
781 { PERL_MAGIC_envelem, "envelem(e)" },
782 { PERL_MAGIC_fm, "fm(f)" },
783 { PERL_MAGIC_regex_global, "regex_global(g)" },
784 { PERL_MAGIC_isaelem, "isaelem(i)" },
785 { PERL_MAGIC_nkeys, "nkeys(k)" },
786 { PERL_MAGIC_dbline, "dbline(l)" },
787 { PERL_MAGIC_mutex, "mutex(m)" },
788 { PERL_MAGIC_shared_scalar, "shared_scalar(n)" },
789 { PERL_MAGIC_collxfrm, "collxfrm(o)" },
790 { PERL_MAGIC_tiedelem, "tiedelem(p)" },
791 { PERL_MAGIC_tiedscalar, "tiedscalar(q)" },
792 { PERL_MAGIC_qr, "qr(r)" },
793 { PERL_MAGIC_sigelem, "sigelem(s)" },
794 { PERL_MAGIC_taint, "taint(t)" },
795 { PERL_MAGIC_uvar_elem, "uvar_elem(v)" },
796 { PERL_MAGIC_vec, "vec(v)" },
797 { PERL_MAGIC_vstring, "vstring(V)" },
798 { PERL_MAGIC_utf8, "utf8(w)" },
799 { PERL_MAGIC_substr, "substr(x)" },
800 { PERL_MAGIC_defelem, "defelem(y)" },
801 { PERL_MAGIC_ext, "ext(~)" },
802 /* this null string terminates the list */
807 Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
809 for (; mg; mg = mg->mg_moremagic) {
810 Perl_dump_indent(aTHX_ level, file,
811 " MAGIC = 0x%"UVxf"\n", PTR2UV(mg));
812 if (mg->mg_virtual) {
813 MGVTBL *v = mg->mg_virtual;
815 if (v == &PL_vtbl_sv) s = "sv";
816 else if (v == &PL_vtbl_env) s = "env";
817 else if (v == &PL_vtbl_envelem) s = "envelem";
818 else if (v == &PL_vtbl_sig) s = "sig";
819 else if (v == &PL_vtbl_sigelem) s = "sigelem";
820 else if (v == &PL_vtbl_pack) s = "pack";
821 else if (v == &PL_vtbl_packelem) s = "packelem";
822 else if (v == &PL_vtbl_dbline) s = "dbline";
823 else if (v == &PL_vtbl_isa) s = "isa";
824 else if (v == &PL_vtbl_arylen) s = "arylen";
825 else if (v == &PL_vtbl_glob) s = "glob";
826 else if (v == &PL_vtbl_mglob) s = "mglob";
827 else if (v == &PL_vtbl_nkeys) s = "nkeys";
828 else if (v == &PL_vtbl_taint) s = "taint";
829 else if (v == &PL_vtbl_substr) s = "substr";
830 else if (v == &PL_vtbl_vec) s = "vec";
831 else if (v == &PL_vtbl_pos) s = "pos";
832 else if (v == &PL_vtbl_bm) s = "bm";
833 else if (v == &PL_vtbl_fm) s = "fm";
834 else if (v == &PL_vtbl_uvar) s = "uvar";
835 else if (v == &PL_vtbl_defelem) s = "defelem";
836 #ifdef USE_LOCALE_COLLATE
837 else if (v == &PL_vtbl_collxfrm) s = "collxfrm";
839 else if (v == &PL_vtbl_amagic) s = "amagic";
840 else if (v == &PL_vtbl_amagicelem) s = "amagicelem";
841 else if (v == &PL_vtbl_backref) s = "backref";
842 else if (v == &PL_vtbl_utf8) s = "utf8";
844 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = &PL_vtbl_%s\n", s);
846 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0x%"UVxf"\n", PTR2UV(v));
849 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0\n");
852 Perl_dump_indent(aTHX_ level, file, " MG_PRIVATE = %d\n", mg->mg_private);
857 for (n=0; magic_names[n].name; n++) {
858 if (mg->mg_type == magic_names[n].type) {
859 name = magic_names[n].name;
864 Perl_dump_indent(aTHX_ level, file,
865 " MG_TYPE = PERL_MAGIC_%s\n", name);
867 Perl_dump_indent(aTHX_ level, file,
868 " MG_TYPE = UNKNOWN(\\%o)\n", mg->mg_type);
872 Perl_dump_indent(aTHX_ level, file, " MG_FLAGS = 0x%02X\n", mg->mg_flags);
873 if (mg->mg_type == PERL_MAGIC_envelem &&
874 mg->mg_flags & MGf_TAINTEDDIR)
875 Perl_dump_indent(aTHX_ level, file, " TAINTEDDIR\n");
876 if (mg->mg_flags & MGf_REFCOUNTED)
877 Perl_dump_indent(aTHX_ level, file, " REFCOUNTED\n");
878 if (mg->mg_flags & MGf_GSKIP)
879 Perl_dump_indent(aTHX_ level, file, " GSKIP\n");
880 if (mg->mg_type == PERL_MAGIC_regex_global &&
881 mg->mg_flags & MGf_MINMATCH)
882 Perl_dump_indent(aTHX_ level, file, " MINMATCH\n");
885 Perl_dump_indent(aTHX_ level, file, " MG_OBJ = 0x%"UVxf"\n", PTR2UV(mg->mg_obj));
886 if (mg->mg_flags & MGf_REFCOUNTED)
887 do_sv_dump(level+2, file, mg->mg_obj, nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
890 Perl_dump_indent(aTHX_ level, file, " MG_LEN = %ld\n", (long)mg->mg_len);
892 Perl_dump_indent(aTHX_ level, file, " MG_PTR = 0x%"UVxf, PTR2UV(mg->mg_ptr));
893 if (mg->mg_len >= 0) {
894 if (mg->mg_type != PERL_MAGIC_utf8) {
895 SV *sv = newSVpvn("", 0);
896 PerlIO_printf(file, " %s", pv_display(sv, mg->mg_ptr, mg->mg_len, 0, pvlim));
900 else if (mg->mg_len == HEf_SVKEY) {
901 PerlIO_puts(file, " => HEf_SVKEY\n");
902 do_sv_dump(level+2, file, (SV*)((mg)->mg_ptr), nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
906 PerlIO_puts(file, " ???? - please notify IZ");
907 PerlIO_putc(file, '\n');
909 if (mg->mg_type == PERL_MAGIC_utf8) {
910 STRLEN *cache = (STRLEN *) mg->mg_ptr;
913 for (i = 0; i < PERL_MAGIC_UTF8_CACHESIZE; i++)
914 Perl_dump_indent(aTHX_ level, file,
915 " %2"IVdf": %"UVuf" -> %"UVuf"\n",
918 (UV)cache[i * 2 + 1]);
925 Perl_magic_dump(pTHX_ MAGIC *mg)
927 do_magic_dump(0, Perl_debug_log, mg, 0, 0, 0, 0);
931 Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, char *name, HV *sv)
933 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
934 if (sv && HvNAME(sv))
935 PerlIO_printf(file, "\t\"%s\"\n", HvNAME(sv));
937 PerlIO_putc(file, '\n');
941 Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
943 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
944 if (sv && GvNAME(sv))
945 PerlIO_printf(file, "\t\"%s\"\n", GvNAME(sv));
947 PerlIO_putc(file, '\n');
951 Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
953 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
954 if (sv && GvNAME(sv)) {
955 PerlIO_printf(file, "\t\"");
956 if (GvSTASH(sv) && HvNAME(GvSTASH(sv)))
957 PerlIO_printf(file, "%s\" :: \"", HvNAME(GvSTASH(sv)));
958 PerlIO_printf(file, "%s\"\n", GvNAME(sv));
961 PerlIO_putc(file, '\n');
965 Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
973 Perl_dump_indent(aTHX_ level, file, "SV = 0\n");
980 d = Perl_newSVpvf(aTHX_
981 "(0x%"UVxf") at 0x%"UVxf"\n%*s REFCNT = %"IVdf"\n%*s FLAGS = (",
982 PTR2UV(SvANY(sv)), PTR2UV(sv),
983 (int)(PL_dumpindent*level), "", (IV)SvREFCNT(sv),
984 (int)(PL_dumpindent*level), "");
986 if (flags & SVs_PADSTALE) sv_catpv(d, "PADSTALE,");
987 if (flags & SVs_PADTMP) sv_catpv(d, "PADTMP,");
988 if (flags & SVs_PADMY) sv_catpv(d, "PADMY,");
989 if (flags & SVs_TEMP) sv_catpv(d, "TEMP,");
990 if (flags & SVs_OBJECT) sv_catpv(d, "OBJECT,");
991 if (flags & SVs_GMG) sv_catpv(d, "GMG,");
992 if (flags & SVs_SMG) sv_catpv(d, "SMG,");
993 if (flags & SVs_RMG) sv_catpv(d, "RMG,");
995 if (flags & SVf_IOK) sv_catpv(d, "IOK,");
996 if (flags & SVf_NOK) sv_catpv(d, "NOK,");
997 if (flags & SVf_POK) sv_catpv(d, "POK,");
998 if (flags & SVf_ROK) {
1000 if (SvWEAKREF(sv)) sv_catpv(d, "WEAKREF,");
1002 if (flags & SVf_OOK) sv_catpv(d, "OOK,");
1003 if (flags & SVf_FAKE) sv_catpv(d, "FAKE,");
1004 if (flags & SVf_READONLY) sv_catpv(d, "READONLY,");
1006 if (flags & SVf_AMAGIC) sv_catpv(d, "OVERLOAD,");
1007 if (flags & SVp_IOK) sv_catpv(d, "pIOK,");
1008 if (flags & SVp_NOK) sv_catpv(d, "pNOK,");
1009 if (flags & SVp_POK) sv_catpv(d, "pPOK,");
1010 if (flags & SVp_SCREAM) sv_catpv(d, "SCREAM,");
1015 if (CvANON(sv)) sv_catpv(d, "ANON,");
1016 if (CvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
1017 if (CvCLONE(sv)) sv_catpv(d, "CLONE,");
1018 if (CvCLONED(sv)) sv_catpv(d, "CLONED,");
1019 if (CvCONST(sv)) sv_catpv(d, "CONST,");
1020 if (CvNODEBUG(sv)) sv_catpv(d, "NODEBUG,");
1021 if (SvCOMPILED(sv)) sv_catpv(d, "COMPILED,");
1022 if (CvLVALUE(sv)) sv_catpv(d, "LVALUE,");
1023 if (CvMETHOD(sv)) sv_catpv(d, "METHOD,");
1024 if (CvLOCKED(sv)) sv_catpv(d, "LOCKED,");
1025 if (CvWEAKOUTSIDE(sv)) sv_catpv(d, "WEAKOUTSIDE,");
1026 if (CvASSERTION(sv)) sv_catpv(d, "ASSERTION,");
1029 if (HvSHAREKEYS(sv)) sv_catpv(d, "SHAREKEYS,");
1030 if (HvLAZYDEL(sv)) sv_catpv(d, "LAZYDEL,");
1031 if (HvHASKFLAGS(sv)) sv_catpv(d, "HASKFLAGS,");
1034 if (GvINTRO(sv)) sv_catpv(d, "INTRO,");
1035 if (GvMULTI(sv)) sv_catpv(d, "MULTI,");
1036 if (GvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
1037 if (GvASSUMECV(sv)) sv_catpv(d, "ASSUMECV,");
1038 if (GvIN_PAD(sv)) sv_catpv(d, "IN_PAD,");
1039 if (flags & SVpad_OUR) sv_catpv(d, "OUR,");
1040 if (GvIMPORTED(sv)) {
1041 sv_catpv(d, "IMPORT");
1042 if (GvIMPORTED(sv) == GVf_IMPORTED)
1043 sv_catpv(d, "ALL,");
1046 if (GvIMPORTED_SV(sv)) sv_catpv(d, " SV");
1047 if (GvIMPORTED_AV(sv)) sv_catpv(d, " AV");
1048 if (GvIMPORTED_HV(sv)) sv_catpv(d, " HV");
1049 if (GvIMPORTED_CV(sv)) sv_catpv(d, " CV");
1055 if (SvEVALED(sv)) sv_catpv(d, "EVALED,");
1056 if (SvIsUV(sv)) sv_catpv(d, "IsUV,");
1059 if (SvTAIL(sv)) sv_catpv(d, "TAIL,");
1060 if (SvVALID(sv)) sv_catpv(d, "VALID,");
1063 if (flags & SVpad_TYPED)
1064 sv_catpv(d, "TYPED,");
1067 if ((SvPOK(sv) || SvPOKp(sv)) && SvUTF8(sv))
1068 sv_catpv(d, "UTF8");
1070 if (*(SvEND(d) - 1) == ',')
1071 SvPVX(d)[--SvCUR(d)] = '\0';
1075 Perl_dump_indent(aTHX_ level, file, "SV = ");
1078 PerlIO_printf(file, "NULL%s\n", s);
1082 PerlIO_printf(file, "IV%s\n", s);
1085 PerlIO_printf(file, "NV%s\n", s);
1088 PerlIO_printf(file, "RV%s\n", s);
1091 PerlIO_printf(file, "PV%s\n", s);
1094 PerlIO_printf(file, "PVIV%s\n", s);
1097 PerlIO_printf(file, "PVNV%s\n", s);
1100 PerlIO_printf(file, "PVBM%s\n", s);
1103 PerlIO_printf(file, "PVMG%s\n", s);
1106 PerlIO_printf(file, "PVLV%s\n", s);
1109 PerlIO_printf(file, "PVAV%s\n", s);
1112 PerlIO_printf(file, "PVHV%s\n", s);
1115 PerlIO_printf(file, "PVCV%s\n", s);
1118 PerlIO_printf(file, "PVGV%s\n", s);
1121 PerlIO_printf(file, "PVFM%s\n", s);
1124 PerlIO_printf(file, "PVIO%s\n", s);
1127 PerlIO_printf(file, "UNKNOWN(0x%"UVxf") %s\n", (UV)type, s);
1131 if (type >= SVt_PVIV || type == SVt_IV) {
1133 #ifdef PERL_COPY_ON_WRITE
1137 Perl_dump_indent(aTHX_ level, file, " UV = %"UVuf, (UV)SvUVX(sv));
1139 Perl_dump_indent(aTHX_ level, file, " IV = %"IVdf, (IV)SvIVX(sv));
1141 PerlIO_printf(file, " (OFFSET)");
1142 #ifdef PERL_COPY_ON_WRITE
1143 if (SvIsCOW_shared_hash(sv))
1144 PerlIO_printf(file, " (HASH)");
1145 else if (SvIsCOW_normal(sv))
1146 PerlIO_printf(file, " (COW from 0x%"UVxf")", (UV)SvUVX(sv));
1148 PerlIO_putc(file, '\n');
1150 if (type >= SVt_PVNV || type == SVt_NV) {
1151 STORE_NUMERIC_LOCAL_SET_STANDARD();
1152 /* %Vg doesn't work? --jhi */
1153 #ifdef USE_LONG_DOUBLE
1154 Perl_dump_indent(aTHX_ level, file, " NV = %.*" PERL_PRIgldbl "\n", LDBL_DIG, SvNVX(sv));
1156 Perl_dump_indent(aTHX_ level, file, " NV = %.*g\n", DBL_DIG, SvNVX(sv));
1158 RESTORE_NUMERIC_LOCAL();
1161 Perl_dump_indent(aTHX_ level, file, " RV = 0x%"UVxf"\n", PTR2UV(SvRV(sv)));
1163 do_sv_dump(level+1, file, SvRV(sv), nest+1, maxnest, dumpops, pvlim);
1165 if (type < SVt_PV) {
1169 if (type <= SVt_PVLV) {
1171 Perl_dump_indent(aTHX_ level, file," PV = 0x%"UVxf" ", PTR2UV(SvPVX(sv)));
1173 PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim));
1174 PerlIO_printf(file, "%s", pv_display(d, SvPVX(sv), SvCUR(sv), SvLEN(sv), pvlim));
1175 if (SvUTF8(sv)) /* the 8? \x{....} */
1176 PerlIO_printf(file, " [UTF8 \"%s\"]", sv_uni_display(d, sv, 8 * sv_len_utf8(sv), UNI_DISPLAY_QQ));
1177 PerlIO_printf(file, "\n");
1178 Perl_dump_indent(aTHX_ level, file, " CUR = %"IVdf"\n", (IV)SvCUR(sv));
1179 Perl_dump_indent(aTHX_ level, file, " LEN = %"IVdf"\n", (IV)SvLEN(sv));
1182 Perl_dump_indent(aTHX_ level, file, " PV = 0\n");
1184 if (type >= SVt_PVMG) {
1186 do_magic_dump(level, file, SvMAGIC(sv), nest, maxnest, dumpops, pvlim);
1188 do_hv_dump(level, file, " STASH", SvSTASH(sv));
1192 Perl_dump_indent(aTHX_ level, file, " TYPE = %c\n", LvTYPE(sv));
1193 Perl_dump_indent(aTHX_ level, file, " TARGOFF = %"IVdf"\n", (IV)LvTARGOFF(sv));
1194 Perl_dump_indent(aTHX_ level, file, " TARGLEN = %"IVdf"\n", (IV)LvTARGLEN(sv));
1195 Perl_dump_indent(aTHX_ level, file, " TARG = 0x%"UVxf"\n", PTR2UV(LvTARG(sv)));
1196 if (LvTYPE(sv) != 't' && LvTYPE(sv) != 'T')
1197 do_sv_dump(level+1, file, LvTARG(sv), nest+1, maxnest,
1201 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(AvARRAY(sv)));
1202 if (AvARRAY(sv) != AvALLOC(sv)) {
1203 PerlIO_printf(file, " (offset=%"IVdf")\n", (IV)(AvARRAY(sv) - AvALLOC(sv)));
1204 Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%"UVxf"\n", PTR2UV(AvALLOC(sv)));
1207 PerlIO_putc(file, '\n');
1208 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)AvFILLp(sv));
1209 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)AvMAX(sv));
1210 Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%"UVxf"\n", PTR2UV(AvARYLEN(sv)));
1211 flags = AvFLAGS(sv);
1213 if (flags & AVf_REAL) sv_catpv(d, ",REAL");
1214 if (flags & AVf_REIFY) sv_catpv(d, ",REIFY");
1215 if (flags & AVf_REUSED) sv_catpv(d, ",REUSED");
1216 Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n", SvCUR(d) ? SvPVX(d) + 1 : "");
1217 if (nest < maxnest && av_len((AV*)sv) >= 0) {
1219 for (count = 0; count <= av_len((AV*)sv) && count < maxnest; count++) {
1220 SV** elt = av_fetch((AV*)sv,count,0);
1222 Perl_dump_indent(aTHX_ level + 1, file, "Elt No. %"IVdf"\n", (IV)count);
1224 do_sv_dump(level+1, file, *elt, nest+1, maxnest, dumpops, pvlim);
1229 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(HvARRAY(sv)));
1230 if (HvARRAY(sv) && HvKEYS(sv)) {
1231 /* Show distribution of HEs in the ARRAY */
1233 #define FREQ_MAX (sizeof freq / sizeof freq[0] - 1)
1236 U32 pow2 = 2, keys = HvKEYS(sv);
1237 NV theoret, sum = 0;
1239 PerlIO_printf(file, " (");
1240 Zero(freq, FREQ_MAX + 1, int);
1241 for (i = 0; (STRLEN)i <= HvMAX(sv); i++) {
1242 HE* h; int count = 0;
1243 for (h = HvARRAY(sv)[i]; h; h = HeNEXT(h))
1245 if (count > FREQ_MAX)
1251 for (i = 0; i <= max; i++) {
1253 PerlIO_printf(file, "%d%s:%d", i,
1254 (i == FREQ_MAX) ? "+" : "",
1257 PerlIO_printf(file, ", ");
1260 PerlIO_putc(file, ')');
1261 /* The "quality" of a hash is defined as the total number of
1262 comparisons needed to access every element once, relative
1263 to the expected number needed for a random hash.
1265 The total number of comparisons is equal to the sum of
1266 the squares of the number of entries in each bucket.
1267 For a random hash of n keys into k buckets, the expected
1272 for (i = max; i > 0; i--) { /* Precision: count down. */
1273 sum += freq[i] * i * i;
1275 while ((keys = keys >> 1))
1277 theoret = HvKEYS(sv);
1278 theoret += theoret * (theoret-1)/pow2;
1279 PerlIO_putc(file, '\n');
1280 Perl_dump_indent(aTHX_ level, file, " hash quality = %.1"NVff"%%", theoret/sum*100);
1282 PerlIO_putc(file, '\n');
1283 Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)HvKEYS(sv));
1284 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)HvFILL(sv));
1285 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)HvMAX(sv));
1286 Perl_dump_indent(aTHX_ level, file, " RITER = %"IVdf"\n", (IV)HvRITER(sv));
1287 Perl_dump_indent(aTHX_ level, file, " EITER = 0x%"UVxf"\n", PTR2UV(HvEITER(sv)));
1289 Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%"UVxf"\n", PTR2UV(HvPMROOT(sv)));
1291 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", HvNAME(sv));
1292 if (nest < maxnest && !HvEITER(sv)) { /* Try to preserve iterator */
1295 int count = maxnest - nest;
1298 while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS))
1303 U32 hash = HeHASH(he);
1305 keysv = hv_iterkeysv(he);
1306 keypv = SvPV(keysv, len);
1307 elt = hv_iterval(hv, he);
1308 Perl_dump_indent(aTHX_ level+1, file, "Elt %s ", pv_display(d, keypv, len, 0, pvlim));
1310 PerlIO_printf(file, "[UTF8 \"%s\"] ", sv_uni_display(d, keysv, 8 * sv_len_utf8(keysv), UNI_DISPLAY_QQ));
1311 PerlIO_printf(file, "HASH = 0x%"UVxf"\n", (UV)hash);
1312 do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim);
1314 hv_iterinit(hv); /* Return to status quo */
1319 Perl_dump_indent(aTHX_ level, file, " PROTOTYPE = \"%s\"\n", SvPV_nolen(sv));
1322 do_hv_dump(level, file, " COMP_STASH", CvSTASH(sv));
1324 Perl_dump_indent(aTHX_ level, file, " START = 0x%"UVxf" ===> %"IVdf"\n", PTR2UV(CvSTART(sv)), (IV)CvSTART(sv)->op_seq);
1325 Perl_dump_indent(aTHX_ level, file, " ROOT = 0x%"UVxf"\n", PTR2UV(CvROOT(sv)));
1326 if (CvROOT(sv) && dumpops)
1327 do_op_dump(level+1, file, CvROOT(sv));
1328 Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%"UVxf"\n", PTR2UV(CvXSUB(sv)));
1329 Perl_dump_indent(aTHX_ level, file, " XSUBANY = %"IVdf"\n", (IV)CvXSUBANY(sv).any_i32);
1330 do_gvgv_dump(level, file, " GVGV::GV", CvGV(sv));
1331 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", CvFILE(sv));
1332 Perl_dump_indent(aTHX_ level, file, " DEPTH = %"IVdf"\n", (IV)CvDEPTH(sv));
1333 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)CvFLAGS(sv));
1334 Perl_dump_indent(aTHX_ level, file, " OUTSIDE_SEQ = %"UVuf"\n", (UV)CvOUTSIDE_SEQ(sv));
1335 if (type == SVt_PVFM)
1336 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)FmLINES(sv));
1337 Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%"UVxf"\n", PTR2UV(CvPADLIST(sv)));
1338 if (nest < maxnest) {
1339 do_dump_pad(level+1, file, CvPADLIST(sv), 0);
1342 CV *outside = CvOUTSIDE(sv);
1343 Perl_dump_indent(aTHX_ level, file, " OUTSIDE = 0x%"UVxf" (%s)\n",
1346 : CvANON(outside) ? "ANON"
1347 : (outside == PL_main_cv) ? "MAIN"
1348 : CvUNIQUE(outside) ? "UNIQUE"
1349 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
1351 if (nest < maxnest && (CvCLONE(sv) || CvCLONED(sv)))
1352 do_sv_dump(level+1, file, (SV*)CvOUTSIDE(sv), nest+1, maxnest, dumpops, pvlim);
1355 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", GvNAME(sv));
1356 Perl_dump_indent(aTHX_ level, file, " NAMELEN = %"IVdf"\n", (IV)GvNAMELEN(sv));
1357 do_hv_dump (level, file, " GvSTASH", GvSTASH(sv));
1358 Perl_dump_indent(aTHX_ level, file, " GP = 0x%"UVxf"\n", PTR2UV(GvGP(sv)));
1361 Perl_dump_indent(aTHX_ level, file, " SV = 0x%"UVxf"\n", PTR2UV(GvSV(sv)));
1362 Perl_dump_indent(aTHX_ level, file, " REFCNT = %"IVdf"\n", (IV)GvREFCNT(sv));
1363 Perl_dump_indent(aTHX_ level, file, " IO = 0x%"UVxf"\n", PTR2UV(GvIOp(sv)));
1364 Perl_dump_indent(aTHX_ level, file, " FORM = 0x%"UVxf" \n", PTR2UV(GvFORM(sv)));
1365 Perl_dump_indent(aTHX_ level, file, " AV = 0x%"UVxf"\n", PTR2UV(GvAV(sv)));
1366 Perl_dump_indent(aTHX_ level, file, " HV = 0x%"UVxf"\n", PTR2UV(GvHV(sv)));
1367 Perl_dump_indent(aTHX_ level, file, " CV = 0x%"UVxf"\n", PTR2UV(GvCV(sv)));
1368 Perl_dump_indent(aTHX_ level, file, " CVGEN = 0x%"UVxf"\n", (UV)GvCVGEN(sv));
1369 Perl_dump_indent(aTHX_ level, file, " GPFLAGS = 0x%"UVxf"\n", (UV)GvGPFLAGS(sv));
1370 Perl_dump_indent(aTHX_ level, file, " LINE = %"IVdf"\n", (IV)GvLINE(sv));
1371 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", GvFILE(sv));
1372 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)GvFLAGS(sv));
1373 do_gv_dump (level, file, " EGV", GvEGV(sv));
1376 Perl_dump_indent(aTHX_ level, file, " IFP = 0x%"UVxf"\n", PTR2UV(IoIFP(sv)));
1377 Perl_dump_indent(aTHX_ level, file, " OFP = 0x%"UVxf"\n", PTR2UV(IoOFP(sv)));
1378 Perl_dump_indent(aTHX_ level, file, " DIRP = 0x%"UVxf"\n", PTR2UV(IoDIRP(sv)));
1379 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)IoLINES(sv));
1380 Perl_dump_indent(aTHX_ level, file, " PAGE = %"IVdf"\n", (IV)IoPAGE(sv));
1381 Perl_dump_indent(aTHX_ level, file, " PAGE_LEN = %"IVdf"\n", (IV)IoPAGE_LEN(sv));
1382 Perl_dump_indent(aTHX_ level, file, " LINES_LEFT = %"IVdf"\n", (IV)IoLINES_LEFT(sv));
1384 Perl_dump_indent(aTHX_ level, file, " TOP_NAME = \"%s\"\n", IoTOP_NAME(sv));
1385 do_gv_dump (level, file, " TOP_GV", IoTOP_GV(sv));
1387 Perl_dump_indent(aTHX_ level, file, " FMT_NAME = \"%s\"\n", IoFMT_NAME(sv));
1388 do_gv_dump (level, file, " FMT_GV", IoFMT_GV(sv));
1389 if (IoBOTTOM_NAME(sv))
1390 Perl_dump_indent(aTHX_ level, file, " BOTTOM_NAME = \"%s\"\n", IoBOTTOM_NAME(sv));
1391 do_gv_dump (level, file, " BOTTOM_GV", IoBOTTOM_GV(sv));
1392 Perl_dump_indent(aTHX_ level, file, " SUBPROCESS = %"IVdf"\n", (IV)IoSUBPROCESS(sv));
1393 if (isPRINT(IoTYPE(sv)))
1394 Perl_dump_indent(aTHX_ level, file, " TYPE = '%c'\n", IoTYPE(sv));
1396 Perl_dump_indent(aTHX_ level, file, " TYPE = '\\%o'\n", IoTYPE(sv));
1397 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)IoFLAGS(sv));
1404 Perl_sv_dump(pTHX_ SV *sv)
1406 do_sv_dump(0, Perl_debug_log, sv, 0, 0, 0, 0);
1410 Perl_runops_debug(pTHX)
1413 if (ckWARN_d(WARN_DEBUGGING))
1414 Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "NULL OP IN RUN");
1421 if (PL_watchaddr != 0 && *PL_watchaddr != PL_watchok)
1422 PerlIO_printf(Perl_debug_log,
1423 "WARNING: %"UVxf" changed from %"UVxf" to %"UVxf"\n",
1424 PTR2UV(PL_watchaddr), PTR2UV(PL_watchok),
1425 PTR2UV(*PL_watchaddr));
1426 if (DEBUG_s_TEST_) {
1427 if (DEBUG_v_TEST_) {
1428 PerlIO_printf(Perl_debug_log, "\n");
1436 if (DEBUG_t_TEST_) debop(PL_op);
1437 if (DEBUG_P_TEST_) debprof(PL_op);
1439 } while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX)));
1446 Perl_debop(pTHX_ OP *o)
1448 AV *padlist, *comppad;
1452 if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
1455 Perl_deb(aTHX_ "%s", OP_NAME(o));
1456 switch (o->op_type) {
1458 PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOPo_sv));
1464 gv_fullname3(sv, cGVOPo_gv, Nullch);
1465 PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen(sv));
1469 PerlIO_printf(Perl_debug_log, "(NULL)");
1474 /* print the lexical's name */
1475 cv = deb_curcv(cxstack_ix);
1477 padlist = CvPADLIST(cv);
1478 comppad = (AV*)(*av_fetch(padlist, 0, FALSE));
1479 sv = *av_fetch(comppad, o->op_targ, FALSE);
1483 PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen(sv));
1485 PerlIO_printf(Perl_debug_log, "[%"UVuf"]", (UV)o->op_targ);
1490 PerlIO_printf(Perl_debug_log, "\n");
1495 S_deb_curcv(pTHX_ I32 ix)
1497 PERL_CONTEXT *cx = &cxstack[ix];
1498 if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT)
1499 return cx->blk_sub.cv;
1500 else if (CxTYPE(cx) == CXt_EVAL && !CxTRYBLOCK(cx))
1502 else if (ix == 0 && PL_curstackinfo->si_type == PERLSI_MAIN)
1507 return deb_curcv(ix - 1);
1511 Perl_watch(pTHX_ char **addr)
1513 PL_watchaddr = addr;
1515 PerlIO_printf(Perl_debug_log, "WATCHING, %"UVxf" is currently %"UVxf"\n",
1516 PTR2UV(PL_watchaddr), PTR2UV(PL_watchok));
1520 S_debprof(pTHX_ OP *o)
1522 if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
1524 if (!PL_profiledata)
1525 Newz(000, PL_profiledata, MAXO, U32);
1526 ++PL_profiledata[o->op_type];
1530 Perl_debprofdump(pTHX)
1533 if (!PL_profiledata)
1535 for (i = 0; i < MAXO; i++) {
1536 if (PL_profiledata[i])
1537 PerlIO_printf(Perl_debug_log,
1538 "%5lu %s\n", (unsigned long)PL_profiledata[i],