3 * Copyright (c) 1991-2003, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "'You have talked long in your sleep, Frodo,' said Gandalf gently, 'and
12 * it has not been hard for me to read your mind and memory.'"
16 #define PERL_IN_DUMP_C
21 Perl_dump_indent(pTHX_ I32 level, PerlIO *file, const char* pat, ...)
25 dump_vindent(level, file, pat, &args);
30 Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args)
32 PerlIO_printf(file, "%*s", (int)(level*PL_dumpindent), "");
33 PerlIO_vprintf(file, pat, *args);
39 PerlIO_setlinebuf(Perl_debug_log);
41 op_dump(PL_main_root);
42 dump_packsubs(PL_defstash);
46 Perl_dump_packsubs(pTHX_ HV *stash)
53 for (i = 0; i <= (I32) HvMAX(stash); i++) {
54 for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) {
55 GV *gv = (GV*)HeVAL(entry);
57 if (SvTYPE(gv) != SVt_PVGV || !GvGP(gv))
63 if (HeKEY(entry)[HeKLEN(entry)-1] == ':'
64 && (hv = GvHV(gv)) && hv != PL_defstash)
65 dump_packsubs(hv); /* nested package */
71 Perl_dump_sub(pTHX_ GV *gv)
73 SV *sv = sv_newmortal();
75 gv_fullname3(sv, gv, Nullch);
76 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nSUB %s = ", SvPVX(sv));
78 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "(xsub 0x%"UVxf" %d)\n",
79 PTR2UV(CvXSUB(GvCV(gv))),
80 (int)CvXSUBANY(GvCV(gv)).any_i32);
81 else if (CvROOT(GvCV(gv)))
82 op_dump(CvROOT(GvCV(gv)));
84 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "<undef>\n");
88 Perl_dump_form(pTHX_ GV *gv)
90 SV *sv = sv_newmortal();
92 gv_fullname3(sv, gv, Nullch);
93 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nFORMAT %s = ", SvPVX(sv));
94 if (CvROOT(GvFORM(gv)))
95 op_dump(CvROOT(GvFORM(gv)));
97 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "<undef>\n");
103 op_dump(PL_eval_root);
107 Perl_pv_display(pTHX_ SV *dsv, char *pv, STRLEN cur, STRLEN len, STRLEN pvlim)
110 int nul_terminated = len > cur && pv[cur] == '\0';
112 sv_setpvn(dsv, "\"", 1);
113 for (; cur--; pv++) {
114 if (pvlim && SvCUR(dsv) >= pvlim) {
120 case '\t': sv_catpvn(dsv, "\\t", 2); break;
121 case '\n': sv_catpvn(dsv, "\\n", 2); break;
122 case '\r': sv_catpvn(dsv, "\\r", 2); break;
123 case '\f': sv_catpvn(dsv, "\\f", 2); break;
124 case '"': sv_catpvn(dsv, "\\\"", 2); break;
125 case '\\': sv_catpvn(dsv, "\\\\", 2); break;
126 default: sv_catpvn(dsv, pv, 1); break;
130 if (cur && isDIGIT(*(pv+1)))
131 Perl_sv_catpvf(aTHX_ dsv, "\\%03o", (U8)*pv);
133 Perl_sv_catpvf(aTHX_ dsv, "\\%o", (U8)*pv);
136 sv_catpvn(dsv, "\"", 1);
138 sv_catpvn(dsv, "...", 3);
140 sv_catpvn(dsv, "\\0", 2);
146 Perl_sv_peek(pTHX_ SV *sv)
148 SV *t = sv_newmortal();
158 else if (sv == (SV*)0x55555555 || SvTYPE(sv) == 'U') {
162 else if (sv == &PL_sv_undef || sv == &PL_sv_no || sv == &PL_sv_yes) {
163 if (sv == &PL_sv_undef) {
164 sv_catpv(t, "SV_UNDEF");
165 if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|
166 SVs_GMG|SVs_SMG|SVs_RMG)) &&
170 else if (sv == &PL_sv_no) {
171 sv_catpv(t, "SV_NO");
172 if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
173 SVs_GMG|SVs_SMG|SVs_RMG)) &&
174 !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
181 sv_catpv(t, "SV_YES");
182 if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
183 SVs_GMG|SVs_SMG|SVs_RMG)) &&
184 !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
187 SvPVX(sv) && *SvPVX(sv) == '1' &&
193 else if (SvREFCNT(sv) == 0) {
197 else if (DEBUG_R_TEST_) {
200 /* is this SV on the tmps stack? */
201 for (ix=PL_tmps_ix; ix>=0; ix--) {
202 if (PL_tmps_stack[ix] == sv) {
207 if (SvREFCNT(sv) > 1)
208 Perl_sv_catpvf(aTHX_ t, "<%"UVuf"%s>", (UV)SvREFCNT(sv),
216 if (SvCUR(t) + unref > 10) {
217 SvCUR(t) = unref + 3;
225 switch (SvTYPE(sv)) {
227 sv_catpv(t, "FREED");
231 sv_catpv(t, "UNDEF");
265 Perl_sv_catpvf(aTHX_ t, "CV(%s)", GvNAME(CvGV(sv)));
285 sv_catpv(t, "(null)");
287 SV *tmp = newSVpvn("", 0);
290 Perl_sv_catpvf(aTHX_ t, "[%s]", pv_display(tmp, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, 127));
291 Perl_sv_catpvf(aTHX_ t, "%s)", pv_display(tmp, SvPVX(sv), SvCUR(sv), SvLEN(sv), 127));
293 Perl_sv_catpvf(aTHX_ t, " [UTF8 \"%s\"]",
294 sv_uni_display(tmp, sv, 8 * sv_len_utf8(sv),
299 else if (SvNOKp(sv)) {
300 STORE_NUMERIC_LOCAL_SET_STANDARD();
301 Perl_sv_catpvf(aTHX_ t, "(%"NVgf")",SvNVX(sv));
302 RESTORE_NUMERIC_LOCAL();
304 else if (SvIOKp(sv)) {
306 Perl_sv_catpvf(aTHX_ t, "(%"UVuf")", (UV)SvUVX(sv));
308 Perl_sv_catpvf(aTHX_ t, "(%"IVdf")", (IV)SvIVX(sv));
322 Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm)
327 Perl_dump_indent(aTHX_ level, file, "{}\n");
330 Perl_dump_indent(aTHX_ level, file, "{\n");
332 if (pm->op_pmflags & PMf_ONCE)
337 Perl_dump_indent(aTHX_ level, file, "PMf_PRE %c%s%c%s\n",
338 ch, PM_GETRE(pm)->precomp, ch,
339 (pm->op_private & OPpRUNTIME) ? " (RUNTIME)" : "");
341 Perl_dump_indent(aTHX_ level, file, "PMf_PRE (RUNTIME)\n");
342 if (pm->op_type != OP_PUSHRE && pm->op_pmreplroot) {
343 Perl_dump_indent(aTHX_ level, file, "PMf_REPL = ");
344 op_dump(pm->op_pmreplroot);
346 if (pm->op_pmflags || (PM_GETRE(pm) && PM_GETRE(pm)->check_substr)) {
347 SV *tmpsv = newSVpvn("", 0);
348 if (pm->op_pmdynflags & PMdf_USED)
349 sv_catpv(tmpsv, ",USED");
350 if (pm->op_pmdynflags & PMdf_TAINTED)
351 sv_catpv(tmpsv, ",TAINTED");
352 if (pm->op_pmflags & PMf_ONCE)
353 sv_catpv(tmpsv, ",ONCE");
354 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
355 && !(PM_GETRE(pm)->reganch & ROPT_NOSCAN))
356 sv_catpv(tmpsv, ",SCANFIRST");
357 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
358 && PM_GETRE(pm)->reganch & ROPT_CHECK_ALL)
359 sv_catpv(tmpsv, ",ALL");
360 if (pm->op_pmflags & PMf_SKIPWHITE)
361 sv_catpv(tmpsv, ",SKIPWHITE");
362 if (pm->op_pmflags & PMf_CONST)
363 sv_catpv(tmpsv, ",CONST");
364 if (pm->op_pmflags & PMf_KEEP)
365 sv_catpv(tmpsv, ",KEEP");
366 if (pm->op_pmflags & PMf_GLOBAL)
367 sv_catpv(tmpsv, ",GLOBAL");
368 if (pm->op_pmflags & PMf_CONTINUE)
369 sv_catpv(tmpsv, ",CONTINUE");
370 if (pm->op_pmflags & PMf_RETAINT)
371 sv_catpv(tmpsv, ",RETAINT");
372 if (pm->op_pmflags & PMf_EVAL)
373 sv_catpv(tmpsv, ",EVAL");
374 Perl_dump_indent(aTHX_ level, file, "PMFLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
378 Perl_dump_indent(aTHX_ level-1, file, "}\n");
382 Perl_pmop_dump(pTHX_ PMOP *pm)
384 do_pmop_dump(0, Perl_debug_log, pm);
388 Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, OP *o)
390 Perl_dump_indent(aTHX_ level, file, "{\n");
393 PerlIO_printf(file, "%-4d", o->op_seq);
395 PerlIO_printf(file, " ");
397 "%*sTYPE = %s ===> ",
398 (int)(PL_dumpindent*level-4), "", OP_NAME(o));
401 PerlIO_printf(file, "%d\n", o->op_next->op_seq);
403 PerlIO_printf(file, "(%d)\n", o->op_next->op_seq);
406 PerlIO_printf(file, "DONE\n");
408 if (o->op_type == OP_NULL)
410 Perl_dump_indent(aTHX_ level, file, " (was %s)\n", PL_op_name[o->op_targ]);
411 if (o->op_targ == OP_NEXTSTATE)
414 Perl_dump_indent(aTHX_ level, file, "LINE = %d\n",CopLINE(cCOPo));
415 if (CopSTASHPV(cCOPo))
416 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
418 if (cCOPo->cop_label)
419 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
424 Perl_dump_indent(aTHX_ level, file, "TARG = %ld\n", (long)o->op_targ);
427 Perl_dump_indent(aTHX_ level, file, "ADDR = 0x%"UVxf" => 0x%"UVxf"\n", (UV)o, (UV)o->op_next);
430 SV *tmpsv = newSVpvn("", 0);
431 switch (o->op_flags & OPf_WANT) {
433 sv_catpv(tmpsv, ",VOID");
435 case OPf_WANT_SCALAR:
436 sv_catpv(tmpsv, ",SCALAR");
439 sv_catpv(tmpsv, ",LIST");
442 sv_catpv(tmpsv, ",UNKNOWN");
445 if (o->op_flags & OPf_KIDS)
446 sv_catpv(tmpsv, ",KIDS");
447 if (o->op_flags & OPf_PARENS)
448 sv_catpv(tmpsv, ",PARENS");
449 if (o->op_flags & OPf_STACKED)
450 sv_catpv(tmpsv, ",STACKED");
451 if (o->op_flags & OPf_REF)
452 sv_catpv(tmpsv, ",REF");
453 if (o->op_flags & OPf_MOD)
454 sv_catpv(tmpsv, ",MOD");
455 if (o->op_flags & OPf_SPECIAL)
456 sv_catpv(tmpsv, ",SPECIAL");
457 Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
461 SV *tmpsv = newSVpvn("", 0);
462 if (PL_opargs[o->op_type] & OA_TARGLEX) {
463 if (o->op_private & OPpTARGET_MY)
464 sv_catpv(tmpsv, ",TARGET_MY");
466 else if (o->op_type == OP_LEAVESUB ||
467 o->op_type == OP_LEAVE ||
468 o->op_type == OP_LEAVESUBLV ||
469 o->op_type == OP_LEAVEWRITE) {
470 if (o->op_private & OPpREFCOUNTED)
471 sv_catpv(tmpsv, ",REFCOUNTED");
473 else if (o->op_type == OP_AASSIGN) {
474 if (o->op_private & OPpASSIGN_COMMON)
475 sv_catpv(tmpsv, ",COMMON");
477 else if (o->op_type == OP_SASSIGN) {
478 if (o->op_private & OPpASSIGN_BACKWARDS)
479 sv_catpv(tmpsv, ",BACKWARDS");
481 else if (o->op_type == OP_TRANS) {
482 if (o->op_private & OPpTRANS_SQUASH)
483 sv_catpv(tmpsv, ",SQUASH");
484 if (o->op_private & OPpTRANS_DELETE)
485 sv_catpv(tmpsv, ",DELETE");
486 if (o->op_private & OPpTRANS_COMPLEMENT)
487 sv_catpv(tmpsv, ",COMPLEMENT");
488 if (o->op_private & OPpTRANS_IDENTICAL)
489 sv_catpv(tmpsv, ",IDENTICAL");
490 if (o->op_private & OPpTRANS_GROWS)
491 sv_catpv(tmpsv, ",GROWS");
493 else if (o->op_type == OP_REPEAT) {
494 if (o->op_private & OPpREPEAT_DOLIST)
495 sv_catpv(tmpsv, ",DOLIST");
497 else if (o->op_type == OP_ENTERSUB ||
498 o->op_type == OP_RV2SV ||
499 o->op_type == OP_GVSV ||
500 o->op_type == OP_RV2AV ||
501 o->op_type == OP_RV2HV ||
502 o->op_type == OP_RV2GV ||
503 o->op_type == OP_AELEM ||
504 o->op_type == OP_HELEM )
506 if (o->op_type == OP_ENTERSUB) {
507 if (o->op_private & OPpENTERSUB_AMPER)
508 sv_catpv(tmpsv, ",AMPER");
509 if (o->op_private & OPpENTERSUB_DB)
510 sv_catpv(tmpsv, ",DB");
511 if (o->op_private & OPpENTERSUB_HASTARG)
512 sv_catpv(tmpsv, ",HASTARG");
513 if (o->op_private & OPpENTERSUB_NOPAREN)
514 sv_catpv(tmpsv, ",NOPAREN");
515 if (o->op_private & OPpENTERSUB_INARGS)
516 sv_catpv(tmpsv, ",INARGS");
517 if (o->op_private & OPpENTERSUB_NOMOD)
518 sv_catpv(tmpsv, ",NOMOD");
521 switch (o->op_private & OPpDEREF) {
523 sv_catpv(tmpsv, ",SV");
526 sv_catpv(tmpsv, ",AV");
529 sv_catpv(tmpsv, ",HV");
532 if (o->op_private & OPpMAYBE_LVSUB)
533 sv_catpv(tmpsv, ",MAYBE_LVSUB");
535 if (o->op_type == OP_AELEM || o->op_type == OP_HELEM) {
536 if (o->op_private & OPpLVAL_DEFER)
537 sv_catpv(tmpsv, ",LVAL_DEFER");
540 if (o->op_private & HINT_STRICT_REFS)
541 sv_catpv(tmpsv, ",STRICT_REFS");
542 if (o->op_private & OPpOUR_INTRO)
543 sv_catpv(tmpsv, ",OUR_INTRO");
546 else if (o->op_type == OP_CONST) {
547 if (o->op_private & OPpCONST_BARE)
548 sv_catpv(tmpsv, ",BARE");
549 if (o->op_private & OPpCONST_STRICT)
550 sv_catpv(tmpsv, ",STRICT");
551 if (o->op_private & OPpCONST_ARYBASE)
552 sv_catpv(tmpsv, ",ARYBASE");
553 if (o->op_private & OPpCONST_WARNING)
554 sv_catpv(tmpsv, ",WARNING");
555 if (o->op_private & OPpCONST_ENTERED)
556 sv_catpv(tmpsv, ",ENTERED");
558 else if (o->op_type == OP_FLIP) {
559 if (o->op_private & OPpFLIP_LINENUM)
560 sv_catpv(tmpsv, ",LINENUM");
562 else if (o->op_type == OP_FLOP) {
563 if (o->op_private & OPpFLIP_LINENUM)
564 sv_catpv(tmpsv, ",LINENUM");
566 else if (o->op_type == OP_RV2CV) {
567 if (o->op_private & OPpLVAL_INTRO)
568 sv_catpv(tmpsv, ",INTRO");
570 else if (o->op_type == OP_GV) {
571 if (o->op_private & OPpEARLY_CV)
572 sv_catpv(tmpsv, ",EARLY_CV");
574 else if (o->op_type == OP_LIST) {
575 if (o->op_private & OPpLIST_GUESSED)
576 sv_catpv(tmpsv, ",GUESSED");
578 else if (o->op_type == OP_DELETE) {
579 if (o->op_private & OPpSLICE)
580 sv_catpv(tmpsv, ",SLICE");
582 else if (o->op_type == OP_EXISTS) {
583 if (o->op_private & OPpEXISTS_SUB)
584 sv_catpv(tmpsv, ",EXISTS_SUB");
586 else if (o->op_type == OP_SORT) {
587 if (o->op_private & OPpSORT_NUMERIC)
588 sv_catpv(tmpsv, ",NUMERIC");
589 if (o->op_private & OPpSORT_INTEGER)
590 sv_catpv(tmpsv, ",INTEGER");
591 if (o->op_private & OPpSORT_REVERSE)
592 sv_catpv(tmpsv, ",REVERSE");
594 else if (o->op_type == OP_THREADSV) {
595 if (o->op_private & OPpDONE_SVREF)
596 sv_catpv(tmpsv, ",SVREF");
598 else if (o->op_type == OP_OPEN || o->op_type == OP_BACKTICK) {
599 if (o->op_private & OPpOPEN_IN_RAW)
600 sv_catpv(tmpsv, ",IN_RAW");
601 if (o->op_private & OPpOPEN_IN_CRLF)
602 sv_catpv(tmpsv, ",IN_CRLF");
603 if (o->op_private & OPpOPEN_OUT_RAW)
604 sv_catpv(tmpsv, ",OUT_RAW");
605 if (o->op_private & OPpOPEN_OUT_CRLF)
606 sv_catpv(tmpsv, ",OUT_CRLF");
608 else if (o->op_type == OP_EXIT) {
609 if (o->op_private & OPpEXIT_VMSISH)
610 sv_catpv(tmpsv, ",EXIT_VMSISH");
611 if (o->op_private & OPpHUSH_VMSISH)
612 sv_catpv(tmpsv, ",HUSH_VMSISH");
614 else if (o->op_type == OP_DIE) {
615 if (o->op_private & OPpHUSH_VMSISH)
616 sv_catpv(tmpsv, ",HUSH_VMSISH");
618 if (o->op_flags & OPf_MOD && o->op_private & OPpLVAL_INTRO)
619 sv_catpv(tmpsv, ",INTRO");
621 Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX(tmpsv) + 1);
625 switch (o->op_type) {
630 Perl_dump_indent(aTHX_ level, file, "PADIX = %" IVdf "\n", (IV)cPADOPo->op_padix);
633 SV *tmpsv = NEWSV(0,0);
637 gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, Nullch);
638 Perl_dump_indent(aTHX_ level, file, "GV = %s\n", SvPV(tmpsv, n_a));
642 Perl_dump_indent(aTHX_ level, file, "GV = NULL\n");
646 case OP_METHOD_NAMED:
647 Perl_dump_indent(aTHX_ level, file, "SV = %s\n", SvPEEK(cSVOPo_sv));
653 Perl_dump_indent(aTHX_ level, file, "LINE = %d\n",CopLINE(cCOPo));
654 if (CopSTASHPV(cCOPo))
655 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
657 if (cCOPo->cop_label)
658 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
662 Perl_dump_indent(aTHX_ level, file, "REDO ===> ");
663 if (cLOOPo->op_redoop)
664 PerlIO_printf(file, "%d\n", cLOOPo->op_redoop->op_seq);
666 PerlIO_printf(file, "DONE\n");
667 Perl_dump_indent(aTHX_ level, file, "NEXT ===> ");
668 if (cLOOPo->op_nextop)
669 PerlIO_printf(file, "%d\n", cLOOPo->op_nextop->op_seq);
671 PerlIO_printf(file, "DONE\n");
672 Perl_dump_indent(aTHX_ level, file, "LAST ===> ");
673 if (cLOOPo->op_lastop)
674 PerlIO_printf(file, "%d\n", cLOOPo->op_lastop->op_seq);
676 PerlIO_printf(file, "DONE\n");
684 Perl_dump_indent(aTHX_ level, file, "OTHER ===> ");
685 if (cLOGOPo->op_other)
686 PerlIO_printf(file, "%d\n", cLOGOPo->op_other->op_seq);
688 PerlIO_printf(file, "DONE\n");
694 do_pmop_dump(level, file, cPMOPo);
702 if (o->op_private & OPpREFCOUNTED)
703 Perl_dump_indent(aTHX_ level, file, "REFCNT = %"UVuf"\n", (UV)o->op_targ);
708 if (o->op_flags & OPf_KIDS) {
710 for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling)
711 do_op_dump(level, file, kid);
713 Perl_dump_indent(aTHX_ level-1, file, "}\n");
717 Perl_op_dump(pTHX_ OP *o)
719 do_op_dump(0, Perl_debug_log, o);
723 Perl_gv_dump(pTHX_ GV *gv)
728 PerlIO_printf(Perl_debug_log, "{}\n");
732 PerlIO_printf(Perl_debug_log, "{\n");
733 gv_fullname3(sv, gv, Nullch);
734 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "GV_NAME = %s", SvPVX(sv));
735 if (gv != GvEGV(gv)) {
736 gv_efullname3(sv, GvEGV(gv), Nullch);
737 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", SvPVX(sv));
739 PerlIO_putc(Perl_debug_log, '\n');
740 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "}\n");
744 /* map magic types to the symbolic names
745 * (with the PERL_MAGIC_ prefixed stripped)
748 static struct { char type; char *name; } magic_names[] = {
749 { PERL_MAGIC_sv, "sv(\\0)" },
750 { PERL_MAGIC_arylen, "arylen(#)" },
751 { PERL_MAGIC_glob, "glob(*)" },
752 { PERL_MAGIC_pos, "pos(.)" },
753 { PERL_MAGIC_backref, "backref(<)" },
754 { PERL_MAGIC_overload, "overload(A)" },
755 { PERL_MAGIC_bm, "bm(B)" },
756 { PERL_MAGIC_regdata, "regdata(D)" },
757 { PERL_MAGIC_env, "env(E)" },
758 { PERL_MAGIC_isa, "isa(I)" },
759 { PERL_MAGIC_dbfile, "dbfile(L)" },
760 { PERL_MAGIC_shared, "shared(N)" },
761 { PERL_MAGIC_tied, "tied(P)" },
762 { PERL_MAGIC_sig, "sig(S)" },
763 { PERL_MAGIC_uvar, "uvar(U)" },
764 { PERL_MAGIC_overload_elem, "overload_elem(a)" },
765 { PERL_MAGIC_overload_table, "overload_table(c)" },
766 { PERL_MAGIC_regdatum, "regdatum(d)" },
767 { PERL_MAGIC_envelem, "envelem(e)" },
768 { PERL_MAGIC_fm, "fm(f)" },
769 { PERL_MAGIC_regex_global, "regex_global(g)" },
770 { PERL_MAGIC_isaelem, "isaelem(i)" },
771 { PERL_MAGIC_nkeys, "nkeys(k)" },
772 { PERL_MAGIC_dbline, "dbline(l)" },
773 { PERL_MAGIC_mutex, "mutex(m)" },
774 { PERL_MAGIC_shared_scalar, "shared_scalar(n)" },
775 { PERL_MAGIC_collxfrm, "collxfrm(o)" },
776 { PERL_MAGIC_tiedelem, "tiedelem(p)" },
777 { PERL_MAGIC_tiedscalar, "tiedscalar(q)" },
778 { PERL_MAGIC_qr, "qr(r)" },
779 { PERL_MAGIC_sigelem, "sigelem(s)" },
780 { PERL_MAGIC_taint, "taint(t)" },
781 { PERL_MAGIC_uvar_elem, "uvar_elem(v)" },
782 { PERL_MAGIC_vec, "vec(v)" },
783 { PERL_MAGIC_vstring, "vstring(V)" },
784 { PERL_MAGIC_utf8, "utf8(w)" },
785 { PERL_MAGIC_substr, "substr(x)" },
786 { PERL_MAGIC_defelem, "defelem(y)" },
787 { PERL_MAGIC_ext, "ext(~)" },
788 /* this null string terminates the list */
793 Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
795 for (; mg; mg = mg->mg_moremagic) {
796 Perl_dump_indent(aTHX_ level, file,
797 " MAGIC = 0x%"UVxf"\n", PTR2UV(mg));
798 if (mg->mg_virtual) {
799 MGVTBL *v = mg->mg_virtual;
801 if (v == &PL_vtbl_sv) s = "sv";
802 else if (v == &PL_vtbl_env) s = "env";
803 else if (v == &PL_vtbl_envelem) s = "envelem";
804 else if (v == &PL_vtbl_sig) s = "sig";
805 else if (v == &PL_vtbl_sigelem) s = "sigelem";
806 else if (v == &PL_vtbl_pack) s = "pack";
807 else if (v == &PL_vtbl_packelem) s = "packelem";
808 else if (v == &PL_vtbl_dbline) s = "dbline";
809 else if (v == &PL_vtbl_isa) s = "isa";
810 else if (v == &PL_vtbl_arylen) s = "arylen";
811 else if (v == &PL_vtbl_glob) s = "glob";
812 else if (v == &PL_vtbl_mglob) s = "mglob";
813 else if (v == &PL_vtbl_nkeys) s = "nkeys";
814 else if (v == &PL_vtbl_taint) s = "taint";
815 else if (v == &PL_vtbl_substr) s = "substr";
816 else if (v == &PL_vtbl_vec) s = "vec";
817 else if (v == &PL_vtbl_pos) s = "pos";
818 else if (v == &PL_vtbl_bm) s = "bm";
819 else if (v == &PL_vtbl_fm) s = "fm";
820 else if (v == &PL_vtbl_uvar) s = "uvar";
821 else if (v == &PL_vtbl_defelem) s = "defelem";
822 #ifdef USE_LOCALE_COLLATE
823 else if (v == &PL_vtbl_collxfrm) s = "collxfrm";
825 else if (v == &PL_vtbl_amagic) s = "amagic";
826 else if (v == &PL_vtbl_amagicelem) s = "amagicelem";
827 else if (v == &PL_vtbl_backref) s = "backref";
828 else if (v == &PL_vtbl_utf8) s = "utf8";
830 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = &PL_vtbl_%s\n", s);
832 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0x%"UVxf"\n", PTR2UV(v));
835 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0\n");
838 Perl_dump_indent(aTHX_ level, file, " MG_PRIVATE = %d\n", mg->mg_private);
843 for (n=0; magic_names[n].name; n++) {
844 if (mg->mg_type == magic_names[n].type) {
845 name = magic_names[n].name;
850 Perl_dump_indent(aTHX_ level, file,
851 " MG_TYPE = PERL_MAGIC_%s\n", name);
853 Perl_dump_indent(aTHX_ level, file,
854 " MG_TYPE = UNKNOWN(\\%o)\n", mg->mg_type);
858 Perl_dump_indent(aTHX_ level, file, " MG_FLAGS = 0x%02X\n", mg->mg_flags);
859 if (mg->mg_type == PERL_MAGIC_envelem &&
860 mg->mg_flags & MGf_TAINTEDDIR)
861 Perl_dump_indent(aTHX_ level, file, " TAINTEDDIR\n");
862 if (mg->mg_flags & MGf_REFCOUNTED)
863 Perl_dump_indent(aTHX_ level, file, " REFCOUNTED\n");
864 if (mg->mg_flags & MGf_GSKIP)
865 Perl_dump_indent(aTHX_ level, file, " GSKIP\n");
866 if (mg->mg_type == PERL_MAGIC_regex_global &&
867 mg->mg_flags & MGf_MINMATCH)
868 Perl_dump_indent(aTHX_ level, file, " MINMATCH\n");
871 Perl_dump_indent(aTHX_ level, file, " MG_OBJ = 0x%"UVxf"\n", PTR2UV(mg->mg_obj));
872 if (mg->mg_flags & MGf_REFCOUNTED)
873 do_sv_dump(level+2, file, mg->mg_obj, nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
876 Perl_dump_indent(aTHX_ level, file, " MG_LEN = %ld\n", (long)mg->mg_len);
878 Perl_dump_indent(aTHX_ level, file, " MG_PTR = 0x%"UVxf, PTR2UV(mg->mg_ptr));
879 if (mg->mg_len >= 0) {
880 if (mg->mg_type != PERL_MAGIC_utf8) {
881 SV *sv = newSVpvn("", 0);
882 PerlIO_printf(file, " %s", pv_display(sv, mg->mg_ptr, mg->mg_len, 0, pvlim));
886 else if (mg->mg_len == HEf_SVKEY) {
887 PerlIO_puts(file, " => HEf_SVKEY\n");
888 do_sv_dump(level+2, file, (SV*)((mg)->mg_ptr), nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
892 PerlIO_puts(file, " ???? - please notify IZ");
893 PerlIO_putc(file, '\n');
895 if (mg->mg_type == PERL_MAGIC_utf8) {
896 STRLEN *cache = (STRLEN *) mg->mg_ptr;
899 for (i = 0; i < PERL_MAGIC_UTF8_CACHESIZE; i++)
900 Perl_dump_indent(aTHX_ level, file,
901 " %2"IVdf": %"UVuf" -> %"UVuf"\n",
904 (UV)cache[i * 2 + 1]);
911 Perl_magic_dump(pTHX_ MAGIC *mg)
913 do_magic_dump(0, Perl_debug_log, mg, 0, 0, 0, 0);
917 Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, char *name, HV *sv)
919 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
920 if (sv && HvNAME(sv))
921 PerlIO_printf(file, "\t\"%s\"\n", HvNAME(sv));
923 PerlIO_putc(file, '\n');
927 Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
929 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
930 if (sv && GvNAME(sv))
931 PerlIO_printf(file, "\t\"%s\"\n", GvNAME(sv));
933 PerlIO_putc(file, '\n');
937 Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
939 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
940 if (sv && GvNAME(sv)) {
941 PerlIO_printf(file, "\t\"");
943 PerlIO_printf(file, "%s\" :: \"", HvNAME(GvSTASH(sv)));
944 PerlIO_printf(file, "%s\"\n", GvNAME(sv));
947 PerlIO_putc(file, '\n');
951 Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
959 Perl_dump_indent(aTHX_ level, file, "SV = 0\n");
966 d = Perl_newSVpvf(aTHX_
967 "(0x%"UVxf") at 0x%"UVxf"\n%*s REFCNT = %"IVdf"\n%*s FLAGS = (",
968 PTR2UV(SvANY(sv)), PTR2UV(sv),
969 (int)(PL_dumpindent*level), "", (IV)SvREFCNT(sv),
970 (int)(PL_dumpindent*level), "");
972 if (flags & SVs_PADSTALE) sv_catpv(d, "PADSTALE,");
973 if (flags & SVs_PADTMP) sv_catpv(d, "PADTMP,");
974 if (flags & SVs_PADMY) sv_catpv(d, "PADMY,");
975 if (flags & SVs_TEMP) sv_catpv(d, "TEMP,");
976 if (flags & SVs_OBJECT) sv_catpv(d, "OBJECT,");
977 if (flags & SVs_GMG) sv_catpv(d, "GMG,");
978 if (flags & SVs_SMG) sv_catpv(d, "SMG,");
979 if (flags & SVs_RMG) sv_catpv(d, "RMG,");
981 if (flags & SVf_IOK) sv_catpv(d, "IOK,");
982 if (flags & SVf_NOK) sv_catpv(d, "NOK,");
983 if (flags & SVf_POK) sv_catpv(d, "POK,");
984 if (flags & SVf_ROK) {
986 if (SvWEAKREF(sv)) sv_catpv(d, "WEAKREF,");
988 if (flags & SVf_OOK) sv_catpv(d, "OOK,");
989 if (flags & SVf_FAKE) sv_catpv(d, "FAKE,");
990 if (flags & SVf_READONLY) sv_catpv(d, "READONLY,");
992 if (flags & SVf_AMAGIC) sv_catpv(d, "OVERLOAD,");
993 if (flags & SVp_IOK) sv_catpv(d, "pIOK,");
994 if (flags & SVp_NOK) sv_catpv(d, "pNOK,");
995 if (flags & SVp_POK) sv_catpv(d, "pPOK,");
996 if (flags & SVp_SCREAM) sv_catpv(d, "SCREAM,");
1001 if (CvANON(sv)) sv_catpv(d, "ANON,");
1002 if (CvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
1003 if (CvCLONE(sv)) sv_catpv(d, "CLONE,");
1004 if (CvCLONED(sv)) sv_catpv(d, "CLONED,");
1005 if (CvCONST(sv)) sv_catpv(d, "CONST,");
1006 if (CvNODEBUG(sv)) sv_catpv(d, "NODEBUG,");
1007 if (SvCOMPILED(sv)) sv_catpv(d, "COMPILED,");
1008 if (CvLVALUE(sv)) sv_catpv(d, "LVALUE,");
1009 if (CvMETHOD(sv)) sv_catpv(d, "METHOD,");
1010 if (CvLOCKED(sv)) sv_catpv(d, "LOCKED,");
1011 if (CvWEAKOUTSIDE(sv)) sv_catpv(d, "WEAKOUTSIDE,");
1012 if (CvASSERTION(sv)) sv_catpv(d, "ASSERTION,");
1015 if (HvSHAREKEYS(sv)) sv_catpv(d, "SHAREKEYS,");
1016 if (HvLAZYDEL(sv)) sv_catpv(d, "LAZYDEL,");
1017 if (HvHASKFLAGS(sv)) sv_catpv(d, "HASKFLAGS,");
1020 if (GvINTRO(sv)) sv_catpv(d, "INTRO,");
1021 if (GvMULTI(sv)) sv_catpv(d, "MULTI,");
1022 if (GvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
1023 if (GvASSUMECV(sv)) sv_catpv(d, "ASSUMECV,");
1024 if (GvIN_PAD(sv)) sv_catpv(d, "IN_PAD,");
1025 if (flags & SVpad_OUR) sv_catpv(d, "OUR,");
1026 if (GvIMPORTED(sv)) {
1027 sv_catpv(d, "IMPORT");
1028 if (GvIMPORTED(sv) == GVf_IMPORTED)
1029 sv_catpv(d, "ALL,");
1032 if (GvIMPORTED_SV(sv)) sv_catpv(d, " SV");
1033 if (GvIMPORTED_AV(sv)) sv_catpv(d, " AV");
1034 if (GvIMPORTED_HV(sv)) sv_catpv(d, " HV");
1035 if (GvIMPORTED_CV(sv)) sv_catpv(d, " CV");
1041 if (SvEVALED(sv)) sv_catpv(d, "EVALED,");
1042 if (SvIsUV(sv)) sv_catpv(d, "IsUV,");
1045 if (SvTAIL(sv)) sv_catpv(d, "TAIL,");
1046 if (SvVALID(sv)) sv_catpv(d, "VALID,");
1049 if (flags & SVpad_TYPED)
1050 sv_catpv(d, "TYPED,");
1053 if ((SvPOK(sv) || SvPOKp(sv)) && SvUTF8(sv))
1054 sv_catpv(d, "UTF8");
1056 if (*(SvEND(d) - 1) == ',')
1057 SvPVX(d)[--SvCUR(d)] = '\0';
1061 Perl_dump_indent(aTHX_ level, file, "SV = ");
1064 PerlIO_printf(file, "NULL%s\n", s);
1068 PerlIO_printf(file, "IV%s\n", s);
1071 PerlIO_printf(file, "NV%s\n", s);
1074 PerlIO_printf(file, "RV%s\n", s);
1077 PerlIO_printf(file, "PV%s\n", s);
1080 PerlIO_printf(file, "PVIV%s\n", s);
1083 PerlIO_printf(file, "PVNV%s\n", s);
1086 PerlIO_printf(file, "PVBM%s\n", s);
1089 PerlIO_printf(file, "PVMG%s\n", s);
1092 PerlIO_printf(file, "PVLV%s\n", s);
1095 PerlIO_printf(file, "PVAV%s\n", s);
1098 PerlIO_printf(file, "PVHV%s\n", s);
1101 PerlIO_printf(file, "PVCV%s\n", s);
1104 PerlIO_printf(file, "PVGV%s\n", s);
1107 PerlIO_printf(file, "PVFM%s\n", s);
1110 PerlIO_printf(file, "PVIO%s\n", s);
1113 PerlIO_printf(file, "UNKNOWN(0x%"UVxf") %s\n", (UV)type, s);
1117 if (type >= SVt_PVIV || type == SVt_IV) {
1119 #ifdef PERL_COPY_ON_WRITE
1123 Perl_dump_indent(aTHX_ level, file, " UV = %"UVuf, (UV)SvUVX(sv));
1125 Perl_dump_indent(aTHX_ level, file, " IV = %"IVdf, (IV)SvIVX(sv));
1127 PerlIO_printf(file, " (OFFSET)");
1128 #ifdef PERL_COPY_ON_WRITE
1129 if (SvIsCOW_shared_hash(sv))
1130 PerlIO_printf(file, " (HASH)");
1131 else if (SvIsCOW_normal(sv))
1132 PerlIO_printf(file, " (COW from 0x%"UVxf")", (UV)SvUVX(sv));
1134 PerlIO_putc(file, '\n');
1136 if (type >= SVt_PVNV || type == SVt_NV) {
1137 STORE_NUMERIC_LOCAL_SET_STANDARD();
1138 /* %Vg doesn't work? --jhi */
1139 #ifdef USE_LONG_DOUBLE
1140 Perl_dump_indent(aTHX_ level, file, " NV = %.*" PERL_PRIgldbl "\n", LDBL_DIG, SvNVX(sv));
1142 Perl_dump_indent(aTHX_ level, file, " NV = %.*g\n", DBL_DIG, SvNVX(sv));
1144 RESTORE_NUMERIC_LOCAL();
1147 Perl_dump_indent(aTHX_ level, file, " RV = 0x%"UVxf"\n", PTR2UV(SvRV(sv)));
1149 do_sv_dump(level+1, file, SvRV(sv), nest+1, maxnest, dumpops, pvlim);
1151 if (type < SVt_PV) {
1155 if (type <= SVt_PVLV) {
1157 Perl_dump_indent(aTHX_ level, file," PV = 0x%"UVxf" ", PTR2UV(SvPVX(sv)));
1159 PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim));
1160 PerlIO_printf(file, "%s", pv_display(d, SvPVX(sv), SvCUR(sv), SvLEN(sv), pvlim));
1161 if (SvUTF8(sv)) /* the 8? \x{....} */
1162 PerlIO_printf(file, " [UTF8 \"%s\"]", sv_uni_display(d, sv, 8 * sv_len_utf8(sv), UNI_DISPLAY_QQ));
1163 PerlIO_printf(file, "\n");
1164 Perl_dump_indent(aTHX_ level, file, " CUR = %"IVdf"\n", (IV)SvCUR(sv));
1165 Perl_dump_indent(aTHX_ level, file, " LEN = %"IVdf"\n", (IV)SvLEN(sv));
1168 Perl_dump_indent(aTHX_ level, file, " PV = 0\n");
1170 if (type >= SVt_PVMG) {
1172 do_magic_dump(level, file, SvMAGIC(sv), nest, maxnest, dumpops, pvlim);
1174 do_hv_dump(level, file, " STASH", SvSTASH(sv));
1178 Perl_dump_indent(aTHX_ level, file, " TYPE = %c\n", LvTYPE(sv));
1179 Perl_dump_indent(aTHX_ level, file, " TARGOFF = %"IVdf"\n", (IV)LvTARGOFF(sv));
1180 Perl_dump_indent(aTHX_ level, file, " TARGLEN = %"IVdf"\n", (IV)LvTARGLEN(sv));
1181 Perl_dump_indent(aTHX_ level, file, " TARG = 0x%"UVxf"\n", PTR2UV(LvTARG(sv)));
1182 /* XXX level+1 ??? */
1183 do_sv_dump(level, file, LvTARG(sv), nest+1, maxnest, dumpops, pvlim);
1186 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(AvARRAY(sv)));
1187 if (AvARRAY(sv) != AvALLOC(sv)) {
1188 PerlIO_printf(file, " (offset=%"IVdf")\n", (IV)(AvARRAY(sv) - AvALLOC(sv)));
1189 Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%"UVxf"\n", PTR2UV(AvALLOC(sv)));
1192 PerlIO_putc(file, '\n');
1193 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)AvFILLp(sv));
1194 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)AvMAX(sv));
1195 Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%"UVxf"\n", PTR2UV(AvARYLEN(sv)));
1196 flags = AvFLAGS(sv);
1198 if (flags & AVf_REAL) sv_catpv(d, ",REAL");
1199 if (flags & AVf_REIFY) sv_catpv(d, ",REIFY");
1200 if (flags & AVf_REUSED) sv_catpv(d, ",REUSED");
1201 Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n", SvCUR(d) ? SvPVX(d) + 1 : "");
1202 if (nest < maxnest && av_len((AV*)sv) >= 0) {
1204 for (count = 0; count <= av_len((AV*)sv) && count < maxnest; count++) {
1205 SV** elt = av_fetch((AV*)sv,count,0);
1207 Perl_dump_indent(aTHX_ level + 1, file, "Elt No. %"IVdf"\n", (IV)count);
1209 do_sv_dump(level+1, file, *elt, nest+1, maxnest, dumpops, pvlim);
1214 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(HvARRAY(sv)));
1215 if (HvARRAY(sv) && HvKEYS(sv)) {
1216 /* Show distribution of HEs in the ARRAY */
1218 #define FREQ_MAX (sizeof freq / sizeof freq[0] - 1)
1221 U32 pow2 = 2, keys = HvKEYS(sv);
1222 NV theoret, sum = 0;
1224 PerlIO_printf(file, " (");
1225 Zero(freq, FREQ_MAX + 1, int);
1226 for (i = 0; (STRLEN)i <= HvMAX(sv); i++) {
1227 HE* h; int count = 0;
1228 for (h = HvARRAY(sv)[i]; h; h = HeNEXT(h))
1230 if (count > FREQ_MAX)
1236 for (i = 0; i <= max; i++) {
1238 PerlIO_printf(file, "%d%s:%d", i,
1239 (i == FREQ_MAX) ? "+" : "",
1242 PerlIO_printf(file, ", ");
1245 PerlIO_putc(file, ')');
1246 /* The "quality" of a hash is defined as the total number of
1247 comparisons needed to access every element once, relative
1248 to the expected number needed for a random hash.
1250 The total number of comparisons is equal to the sum of
1251 the squares of the number of entries in each bucket.
1252 For a random hash of n keys into k buckets, the expected
1257 for (i = max; i > 0; i--) { /* Precision: count down. */
1258 sum += freq[i] * i * i;
1260 while ((keys = keys >> 1))
1262 theoret = HvKEYS(sv);
1263 theoret += theoret * (theoret-1)/pow2;
1264 PerlIO_putc(file, '\n');
1265 Perl_dump_indent(aTHX_ level, file, " hash quality = %.1"NVff"%%", theoret/sum*100);
1267 PerlIO_putc(file, '\n');
1268 Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)HvKEYS(sv));
1269 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)HvFILL(sv));
1270 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)HvMAX(sv));
1271 Perl_dump_indent(aTHX_ level, file, " RITER = %"IVdf"\n", (IV)HvRITER(sv));
1272 Perl_dump_indent(aTHX_ level, file, " EITER = 0x%"UVxf"\n", PTR2UV(HvEITER(sv)));
1274 Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%"UVxf"\n", PTR2UV(HvPMROOT(sv)));
1276 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", HvNAME(sv));
1277 if (nest < maxnest && !HvEITER(sv)) { /* Try to preserve iterator */
1280 int count = maxnest - nest;
1283 while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS))
1288 U32 hash = HeHASH(he);
1290 keysv = hv_iterkeysv(he);
1291 keypv = SvPV(keysv, len);
1292 elt = hv_iterval(hv, he);
1293 Perl_dump_indent(aTHX_ level+1, file, "Elt %s ", pv_display(d, keypv, len, 0, pvlim));
1295 PerlIO_printf(file, "[UTF8 \"%s\"] ", sv_uni_display(d, keysv, 8 * sv_len_utf8(keysv), UNI_DISPLAY_QQ));
1296 PerlIO_printf(file, "HASH = 0x%"UVxf"\n", (UV)hash);
1297 do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim);
1299 hv_iterinit(hv); /* Return to status quo */
1304 Perl_dump_indent(aTHX_ level, file, " PROTOTYPE = \"%s\"\n", SvPV_nolen(sv));
1307 do_hv_dump(level, file, " COMP_STASH", CvSTASH(sv));
1309 Perl_dump_indent(aTHX_ level, file, " START = 0x%"UVxf" ===> %"IVdf"\n", PTR2UV(CvSTART(sv)), (IV)CvSTART(sv)->op_seq);
1310 Perl_dump_indent(aTHX_ level, file, " ROOT = 0x%"UVxf"\n", PTR2UV(CvROOT(sv)));
1311 if (CvROOT(sv) && dumpops)
1312 do_op_dump(level+1, file, CvROOT(sv));
1313 Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%"UVxf"\n", PTR2UV(CvXSUB(sv)));
1314 Perl_dump_indent(aTHX_ level, file, " XSUBANY = %"IVdf"\n", (IV)CvXSUBANY(sv).any_i32);
1315 do_gvgv_dump(level, file, " GVGV::GV", CvGV(sv));
1316 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", CvFILE(sv));
1317 Perl_dump_indent(aTHX_ level, file, " DEPTH = %"IVdf"\n", (IV)CvDEPTH(sv));
1318 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)CvFLAGS(sv));
1319 Perl_dump_indent(aTHX_ level, file, " OUTSIDE_SEQ = %"UVuf"\n", (UV)CvOUTSIDE_SEQ(sv));
1320 if (type == SVt_PVFM)
1321 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)FmLINES(sv));
1322 Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%"UVxf"\n", PTR2UV(CvPADLIST(sv)));
1323 if (nest < maxnest) {
1324 do_dump_pad(level+1, file, CvPADLIST(sv), 0);
1327 CV *outside = CvOUTSIDE(sv);
1328 Perl_dump_indent(aTHX_ level, file, " OUTSIDE = 0x%"UVxf" (%s)\n",
1331 : CvANON(outside) ? "ANON"
1332 : (outside == PL_main_cv) ? "MAIN"
1333 : CvUNIQUE(outside) ? "UNIQUE"
1334 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
1336 if (nest < maxnest && (CvCLONE(sv) || CvCLONED(sv)))
1337 do_sv_dump(level+1, file, (SV*)CvOUTSIDE(sv), nest+1, maxnest, dumpops, pvlim);
1340 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", GvNAME(sv));
1341 Perl_dump_indent(aTHX_ level, file, " NAMELEN = %"IVdf"\n", (IV)GvNAMELEN(sv));
1342 do_hv_dump (level, file, " GvSTASH", GvSTASH(sv));
1343 Perl_dump_indent(aTHX_ level, file, " GP = 0x%"UVxf"\n", PTR2UV(GvGP(sv)));
1346 Perl_dump_indent(aTHX_ level, file, " SV = 0x%"UVxf"\n", PTR2UV(GvSV(sv)));
1347 Perl_dump_indent(aTHX_ level, file, " REFCNT = %"IVdf"\n", (IV)GvREFCNT(sv));
1348 Perl_dump_indent(aTHX_ level, file, " IO = 0x%"UVxf"\n", PTR2UV(GvIOp(sv)));
1349 Perl_dump_indent(aTHX_ level, file, " FORM = 0x%"UVxf" \n", PTR2UV(GvFORM(sv)));
1350 Perl_dump_indent(aTHX_ level, file, " AV = 0x%"UVxf"\n", PTR2UV(GvAV(sv)));
1351 Perl_dump_indent(aTHX_ level, file, " HV = 0x%"UVxf"\n", PTR2UV(GvHV(sv)));
1352 Perl_dump_indent(aTHX_ level, file, " CV = 0x%"UVxf"\n", PTR2UV(GvCV(sv)));
1353 Perl_dump_indent(aTHX_ level, file, " CVGEN = 0x%"UVxf"\n", (UV)GvCVGEN(sv));
1354 Perl_dump_indent(aTHX_ level, file, " GPFLAGS = 0x%"UVxf"\n", (UV)GvGPFLAGS(sv));
1355 Perl_dump_indent(aTHX_ level, file, " LINE = %"IVdf"\n", (IV)GvLINE(sv));
1356 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", GvFILE(sv));
1357 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)GvFLAGS(sv));
1358 do_gv_dump (level, file, " EGV", GvEGV(sv));
1361 Perl_dump_indent(aTHX_ level, file, " IFP = 0x%"UVxf"\n", PTR2UV(IoIFP(sv)));
1362 Perl_dump_indent(aTHX_ level, file, " OFP = 0x%"UVxf"\n", PTR2UV(IoOFP(sv)));
1363 Perl_dump_indent(aTHX_ level, file, " DIRP = 0x%"UVxf"\n", PTR2UV(IoDIRP(sv)));
1364 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)IoLINES(sv));
1365 Perl_dump_indent(aTHX_ level, file, " PAGE = %"IVdf"\n", (IV)IoPAGE(sv));
1366 Perl_dump_indent(aTHX_ level, file, " PAGE_LEN = %"IVdf"\n", (IV)IoPAGE_LEN(sv));
1367 Perl_dump_indent(aTHX_ level, file, " LINES_LEFT = %"IVdf"\n", (IV)IoLINES_LEFT(sv));
1369 Perl_dump_indent(aTHX_ level, file, " TOP_NAME = \"%s\"\n", IoTOP_NAME(sv));
1370 do_gv_dump (level, file, " TOP_GV", IoTOP_GV(sv));
1372 Perl_dump_indent(aTHX_ level, file, " FMT_NAME = \"%s\"\n", IoFMT_NAME(sv));
1373 do_gv_dump (level, file, " FMT_GV", IoFMT_GV(sv));
1374 if (IoBOTTOM_NAME(sv))
1375 Perl_dump_indent(aTHX_ level, file, " BOTTOM_NAME = \"%s\"\n", IoBOTTOM_NAME(sv));
1376 do_gv_dump (level, file, " BOTTOM_GV", IoBOTTOM_GV(sv));
1377 Perl_dump_indent(aTHX_ level, file, " SUBPROCESS = %"IVdf"\n", (IV)IoSUBPROCESS(sv));
1378 if (isPRINT(IoTYPE(sv)))
1379 Perl_dump_indent(aTHX_ level, file, " TYPE = '%c'\n", IoTYPE(sv));
1381 Perl_dump_indent(aTHX_ level, file, " TYPE = '\\%o'\n", IoTYPE(sv));
1382 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)IoFLAGS(sv));
1389 Perl_sv_dump(pTHX_ SV *sv)
1391 do_sv_dump(0, Perl_debug_log, sv, 0, 0, 0, 0);
1395 Perl_runops_debug(pTHX)
1398 if (ckWARN_d(WARN_DEBUGGING))
1399 Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "NULL OP IN RUN");
1406 if (PL_watchaddr != 0 && *PL_watchaddr != PL_watchok)
1407 PerlIO_printf(Perl_debug_log,
1408 "WARNING: %"UVxf" changed from %"UVxf" to %"UVxf"\n",
1409 PTR2UV(PL_watchaddr), PTR2UV(PL_watchok),
1410 PTR2UV(*PL_watchaddr));
1411 if (DEBUG_s_TEST_) {
1412 if (DEBUG_v_TEST_) {
1413 PerlIO_printf(Perl_debug_log, "\n");
1421 if (DEBUG_t_TEST_) debop(PL_op);
1422 if (DEBUG_P_TEST_) debprof(PL_op);
1424 } while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX)));
1431 Perl_debop(pTHX_ OP *o)
1433 AV *padlist, *comppad;
1437 if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
1440 Perl_deb(aTHX_ "%s", OP_NAME(o));
1441 switch (o->op_type) {
1443 PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOPo_sv));
1449 gv_fullname3(sv, cGVOPo_gv, Nullch);
1450 PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen(sv));
1454 PerlIO_printf(Perl_debug_log, "(NULL)");
1459 /* print the lexical's name */
1460 cv = deb_curcv(cxstack_ix);
1462 padlist = CvPADLIST(cv);
1463 comppad = (AV*)(*av_fetch(padlist, 0, FALSE));
1464 sv = *av_fetch(comppad, o->op_targ, FALSE);
1468 PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen(sv));
1470 PerlIO_printf(Perl_debug_log, "[%"UVuf"]", (UV)o->op_targ);
1475 PerlIO_printf(Perl_debug_log, "\n");
1480 S_deb_curcv(pTHX_ I32 ix)
1482 PERL_CONTEXT *cx = &cxstack[ix];
1483 if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT)
1484 return cx->blk_sub.cv;
1485 else if (CxTYPE(cx) == CXt_EVAL && !CxTRYBLOCK(cx))
1487 else if (ix == 0 && PL_curstackinfo->si_type == PERLSI_MAIN)
1492 return deb_curcv(ix - 1);
1496 Perl_watch(pTHX_ char **addr)
1498 PL_watchaddr = addr;
1500 PerlIO_printf(Perl_debug_log, "WATCHING, %"UVxf" is currently %"UVxf"\n",
1501 PTR2UV(PL_watchaddr), PTR2UV(PL_watchok));
1505 S_debprof(pTHX_ OP *o)
1507 if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
1509 if (!PL_profiledata)
1510 Newz(000, PL_profiledata, MAXO, U32);
1511 ++PL_profiledata[o->op_type];
1515 Perl_debprofdump(pTHX)
1518 if (!PL_profiledata)
1520 for (i = 0; i < MAXO; i++) {
1521 if (PL_profiledata[i])
1522 PerlIO_printf(Perl_debug_log,
1523 "%5lu %s\n", (unsigned long)PL_profiledata[i],