3 * Copyright (c) 1991-2002, 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%lx %d)\n",
79 (long)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_ && SvREFCNT(sv) > 1) {
198 Perl_sv_catpvf(aTHX_ t, "<%"UVuf">", (UV)SvREFCNT(sv));
204 if (SvCUR(t) + unref > 10) {
205 SvCUR(t) = unref + 3;
213 switch (SvTYPE(sv)) {
215 sv_catpv(t, "FREED");
219 sv_catpv(t, "UNDEF");
253 Perl_sv_catpvf(aTHX_ t, "CV(%s)", GvNAME(CvGV(sv)));
273 sv_catpv(t, "(null)");
275 SV *tmp = newSVpvn("", 0);
278 Perl_sv_catpvf(aTHX_ t, "[%s]", pv_display(tmp, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, 127));
279 Perl_sv_catpvf(aTHX_ t, "%s)", pv_display(tmp, SvPVX(sv), SvCUR(sv), SvLEN(sv), 127));
281 Perl_sv_catpvf(aTHX_ t, " [UTF8 \"%s\"]",
282 sv_uni_display(tmp, sv, 8 * sv_len_utf8(sv),
287 else if (SvNOKp(sv)) {
288 STORE_NUMERIC_LOCAL_SET_STANDARD();
289 Perl_sv_catpvf(aTHX_ t, "(%"NVgf")",SvNVX(sv));
290 RESTORE_NUMERIC_LOCAL();
292 else if (SvIOKp(sv)) {
294 Perl_sv_catpvf(aTHX_ t, "(%"UVuf")", (UV)SvUVX(sv));
296 Perl_sv_catpvf(aTHX_ t, "(%"IVdf")", (IV)SvIVX(sv));
310 Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm)
315 Perl_dump_indent(aTHX_ level, file, "{}\n");
318 Perl_dump_indent(aTHX_ level, file, "{\n");
320 if (pm->op_pmflags & PMf_ONCE)
325 Perl_dump_indent(aTHX_ level, file, "PMf_PRE %c%s%c%s\n",
326 ch, PM_GETRE(pm)->precomp, ch,
327 (pm->op_private & OPpRUNTIME) ? " (RUNTIME)" : "");
329 Perl_dump_indent(aTHX_ level, file, "PMf_PRE (RUNTIME)\n");
330 if (pm->op_type != OP_PUSHRE && pm->op_pmreplroot) {
331 Perl_dump_indent(aTHX_ level, file, "PMf_REPL = ");
332 op_dump(pm->op_pmreplroot);
334 if (pm->op_pmflags || (PM_GETRE(pm) && PM_GETRE(pm)->check_substr)) {
335 SV *tmpsv = newSVpvn("", 0);
336 if (pm->op_pmdynflags & PMdf_USED)
337 sv_catpv(tmpsv, ",USED");
338 if (pm->op_pmdynflags & PMdf_TAINTED)
339 sv_catpv(tmpsv, ",TAINTED");
340 if (pm->op_pmflags & PMf_ONCE)
341 sv_catpv(tmpsv, ",ONCE");
342 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
343 && !(PM_GETRE(pm)->reganch & ROPT_NOSCAN))
344 sv_catpv(tmpsv, ",SCANFIRST");
345 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
346 && PM_GETRE(pm)->reganch & ROPT_CHECK_ALL)
347 sv_catpv(tmpsv, ",ALL");
348 if (pm->op_pmflags & PMf_SKIPWHITE)
349 sv_catpv(tmpsv, ",SKIPWHITE");
350 if (pm->op_pmflags & PMf_CONST)
351 sv_catpv(tmpsv, ",CONST");
352 if (pm->op_pmflags & PMf_KEEP)
353 sv_catpv(tmpsv, ",KEEP");
354 if (pm->op_pmflags & PMf_GLOBAL)
355 sv_catpv(tmpsv, ",GLOBAL");
356 if (pm->op_pmflags & PMf_CONTINUE)
357 sv_catpv(tmpsv, ",CONTINUE");
358 if (pm->op_pmflags & PMf_RETAINT)
359 sv_catpv(tmpsv, ",RETAINT");
360 if (pm->op_pmflags & PMf_EVAL)
361 sv_catpv(tmpsv, ",EVAL");
362 Perl_dump_indent(aTHX_ level, file, "PMFLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
366 Perl_dump_indent(aTHX_ level-1, file, "}\n");
370 Perl_pmop_dump(pTHX_ PMOP *pm)
372 do_pmop_dump(0, Perl_debug_log, pm);
376 Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, OP *o)
378 Perl_dump_indent(aTHX_ level, file, "{\n");
381 PerlIO_printf(file, "%-4d", o->op_seq);
383 PerlIO_printf(file, " ");
385 "%*sTYPE = %s ===> ",
386 (int)(PL_dumpindent*level-4), "", OP_NAME(o));
389 PerlIO_printf(file, "%d\n", o->op_next->op_seq);
391 PerlIO_printf(file, "(%d)\n", o->op_next->op_seq);
394 PerlIO_printf(file, "DONE\n");
396 if (o->op_type == OP_NULL)
398 Perl_dump_indent(aTHX_ level, file, " (was %s)\n", PL_op_name[o->op_targ]);
399 if (o->op_targ == OP_NEXTSTATE)
402 Perl_dump_indent(aTHX_ level, file, "LINE = %d\n",CopLINE(cCOPo));
403 if (CopSTASHPV(cCOPo))
404 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
406 if (cCOPo->cop_label)
407 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
412 Perl_dump_indent(aTHX_ level, file, "TARG = %ld\n", (long)o->op_targ);
415 Perl_dump_indent(aTHX_ level, file, "ADDR = 0x%"UVxf" => 0x%"UVxf"\n", (UV)o, (UV)o->op_next);
418 SV *tmpsv = newSVpvn("", 0);
419 switch (o->op_flags & OPf_WANT) {
421 sv_catpv(tmpsv, ",VOID");
423 case OPf_WANT_SCALAR:
424 sv_catpv(tmpsv, ",SCALAR");
427 sv_catpv(tmpsv, ",LIST");
430 sv_catpv(tmpsv, ",UNKNOWN");
433 if (o->op_flags & OPf_KIDS)
434 sv_catpv(tmpsv, ",KIDS");
435 if (o->op_flags & OPf_PARENS)
436 sv_catpv(tmpsv, ",PARENS");
437 if (o->op_flags & OPf_STACKED)
438 sv_catpv(tmpsv, ",STACKED");
439 if (o->op_flags & OPf_REF)
440 sv_catpv(tmpsv, ",REF");
441 if (o->op_flags & OPf_MOD)
442 sv_catpv(tmpsv, ",MOD");
443 if (o->op_flags & OPf_SPECIAL)
444 sv_catpv(tmpsv, ",SPECIAL");
445 Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
449 SV *tmpsv = newSVpvn("", 0);
450 if (PL_opargs[o->op_type] & OA_TARGLEX) {
451 if (o->op_private & OPpTARGET_MY)
452 sv_catpv(tmpsv, ",TARGET_MY");
454 else if (o->op_type == OP_LEAVESUB ||
455 o->op_type == OP_LEAVE ||
456 o->op_type == OP_LEAVESUBLV ||
457 o->op_type == OP_LEAVEWRITE) {
458 if (o->op_private & OPpREFCOUNTED)
459 sv_catpv(tmpsv, ",REFCOUNTED");
461 else if (o->op_type == OP_AASSIGN) {
462 if (o->op_private & OPpASSIGN_COMMON)
463 sv_catpv(tmpsv, ",COMMON");
464 if (o->op_private & OPpASSIGN_HASH)
465 sv_catpv(tmpsv, ",HASH");
467 else if (o->op_type == OP_SASSIGN) {
468 if (o->op_private & OPpASSIGN_BACKWARDS)
469 sv_catpv(tmpsv, ",BACKWARDS");
471 else if (o->op_type == OP_TRANS) {
472 if (o->op_private & OPpTRANS_SQUASH)
473 sv_catpv(tmpsv, ",SQUASH");
474 if (o->op_private & OPpTRANS_DELETE)
475 sv_catpv(tmpsv, ",DELETE");
476 if (o->op_private & OPpTRANS_COMPLEMENT)
477 sv_catpv(tmpsv, ",COMPLEMENT");
478 if (o->op_private & OPpTRANS_IDENTICAL)
479 sv_catpv(tmpsv, ",IDENTICAL");
480 if (o->op_private & OPpTRANS_GROWS)
481 sv_catpv(tmpsv, ",GROWS");
483 else if (o->op_type == OP_REPEAT) {
484 if (o->op_private & OPpREPEAT_DOLIST)
485 sv_catpv(tmpsv, ",DOLIST");
487 else if (o->op_type == OP_ENTERSUB ||
488 o->op_type == OP_RV2SV ||
489 o->op_type == OP_GVSV ||
490 o->op_type == OP_RV2AV ||
491 o->op_type == OP_RV2HV ||
492 o->op_type == OP_RV2GV ||
493 o->op_type == OP_AELEM ||
494 o->op_type == OP_HELEM )
496 if (o->op_type == OP_ENTERSUB) {
497 if (o->op_private & OPpENTERSUB_AMPER)
498 sv_catpv(tmpsv, ",AMPER");
499 if (o->op_private & OPpENTERSUB_DB)
500 sv_catpv(tmpsv, ",DB");
501 if (o->op_private & OPpENTERSUB_HASTARG)
502 sv_catpv(tmpsv, ",HASTARG");
503 if (o->op_private & OPpENTERSUB_NOPAREN)
504 sv_catpv(tmpsv, ",NOPAREN");
505 if (o->op_private & OPpENTERSUB_INARGS)
506 sv_catpv(tmpsv, ",INARGS");
507 if (o->op_private & OPpENTERSUB_NOMOD)
508 sv_catpv(tmpsv, ",NOMOD");
511 switch (o->op_private & OPpDEREF) {
513 sv_catpv(tmpsv, ",SV");
516 sv_catpv(tmpsv, ",AV");
519 sv_catpv(tmpsv, ",HV");
522 if (o->op_private & OPpMAYBE_LVSUB)
523 sv_catpv(tmpsv, ",MAYBE_LVSUB");
525 if (o->op_type == OP_AELEM || o->op_type == OP_HELEM) {
526 if (o->op_private & OPpLVAL_DEFER)
527 sv_catpv(tmpsv, ",LVAL_DEFER");
530 if (o->op_private & HINT_STRICT_REFS)
531 sv_catpv(tmpsv, ",STRICT_REFS");
532 if (o->op_private & OPpOUR_INTRO)
533 sv_catpv(tmpsv, ",OUR_INTRO");
536 else if (o->op_type == OP_CONST) {
537 if (o->op_private & OPpCONST_BARE)
538 sv_catpv(tmpsv, ",BARE");
539 if (o->op_private & OPpCONST_STRICT)
540 sv_catpv(tmpsv, ",STRICT");
541 if (o->op_private & OPpCONST_ARYBASE)
542 sv_catpv(tmpsv, ",ARYBASE");
543 if (o->op_private & OPpCONST_WARNING)
544 sv_catpv(tmpsv, ",WARNING");
545 if (o->op_private & OPpCONST_ENTERED)
546 sv_catpv(tmpsv, ",ENTERED");
548 else if (o->op_type == OP_FLIP) {
549 if (o->op_private & OPpFLIP_LINENUM)
550 sv_catpv(tmpsv, ",LINENUM");
552 else if (o->op_type == OP_FLOP) {
553 if (o->op_private & OPpFLIP_LINENUM)
554 sv_catpv(tmpsv, ",LINENUM");
556 else if (o->op_type == OP_RV2CV) {
557 if (o->op_private & OPpLVAL_INTRO)
558 sv_catpv(tmpsv, ",INTRO");
560 else if (o->op_type == OP_GV) {
561 if (o->op_private & OPpEARLY_CV)
562 sv_catpv(tmpsv, ",EARLY_CV");
564 else if (o->op_type == OP_LIST) {
565 if (o->op_private & OPpLIST_GUESSED)
566 sv_catpv(tmpsv, ",GUESSED");
568 else if (o->op_type == OP_DELETE) {
569 if (o->op_private & OPpSLICE)
570 sv_catpv(tmpsv, ",SLICE");
572 else if (o->op_type == OP_EXISTS) {
573 if (o->op_private & OPpEXISTS_SUB)
574 sv_catpv(tmpsv, ",EXISTS_SUB");
576 else if (o->op_type == OP_SORT) {
577 if (o->op_private & OPpSORT_NUMERIC)
578 sv_catpv(tmpsv, ",NUMERIC");
579 if (o->op_private & OPpSORT_INTEGER)
580 sv_catpv(tmpsv, ",INTEGER");
581 if (o->op_private & OPpSORT_REVERSE)
582 sv_catpv(tmpsv, ",REVERSE");
584 else if (o->op_type == OP_THREADSV) {
585 if (o->op_private & OPpDONE_SVREF)
586 sv_catpv(tmpsv, ",SVREF");
588 else if (o->op_type == OP_OPEN || o->op_type == OP_BACKTICK) {
589 if (o->op_private & OPpOPEN_IN_RAW)
590 sv_catpv(tmpsv, ",IN_RAW");
591 if (o->op_private & OPpOPEN_IN_CRLF)
592 sv_catpv(tmpsv, ",IN_CRLF");
593 if (o->op_private & OPpOPEN_OUT_RAW)
594 sv_catpv(tmpsv, ",OUT_RAW");
595 if (o->op_private & OPpOPEN_OUT_CRLF)
596 sv_catpv(tmpsv, ",OUT_CRLF");
598 else if (o->op_type == OP_EXIT) {
599 if (o->op_private & OPpEXIT_VMSISH)
600 sv_catpv(tmpsv, ",EXIT_VMSISH");
601 if (o->op_private & OPpHUSH_VMSISH)
602 sv_catpv(tmpsv, ",HUSH_VMSISH");
604 else if (o->op_type == OP_DIE) {
605 if (o->op_private & OPpHUSH_VMSISH)
606 sv_catpv(tmpsv, ",HUSH_VMSISH");
608 if (o->op_flags & OPf_MOD && o->op_private & OPpLVAL_INTRO)
609 sv_catpv(tmpsv, ",INTRO");
611 Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX(tmpsv) + 1);
615 switch (o->op_type) {
620 Perl_dump_indent(aTHX_ level, file, "PADIX = %d\n", cPADOPo->op_padix);
623 SV *tmpsv = NEWSV(0,0);
627 gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, Nullch);
628 Perl_dump_indent(aTHX_ level, file, "GV = %s\n", SvPV(tmpsv, n_a));
632 Perl_dump_indent(aTHX_ level, file, "GV = NULL\n");
636 case OP_METHOD_NAMED:
637 Perl_dump_indent(aTHX_ level, file, "SV = %s\n", SvPEEK(cSVOPo->op_sv));
643 Perl_dump_indent(aTHX_ level, file, "LINE = %d\n",CopLINE(cCOPo));
644 if (CopSTASHPV(cCOPo))
645 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
647 if (cCOPo->cop_label)
648 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
652 Perl_dump_indent(aTHX_ level, file, "REDO ===> ");
653 if (cLOOPo->op_redoop)
654 PerlIO_printf(file, "%d\n", cLOOPo->op_redoop->op_seq);
656 PerlIO_printf(file, "DONE\n");
657 Perl_dump_indent(aTHX_ level, file, "NEXT ===> ");
658 if (cLOOPo->op_nextop)
659 PerlIO_printf(file, "%d\n", cLOOPo->op_nextop->op_seq);
661 PerlIO_printf(file, "DONE\n");
662 Perl_dump_indent(aTHX_ level, file, "LAST ===> ");
663 if (cLOOPo->op_lastop)
664 PerlIO_printf(file, "%d\n", cLOOPo->op_lastop->op_seq);
666 PerlIO_printf(file, "DONE\n");
674 Perl_dump_indent(aTHX_ level, file, "OTHER ===> ");
675 if (cLOGOPo->op_other)
676 PerlIO_printf(file, "%d\n", cLOGOPo->op_other->op_seq);
678 PerlIO_printf(file, "DONE\n");
684 do_pmop_dump(level, file, cPMOPo);
692 if (o->op_private & OPpREFCOUNTED)
693 Perl_dump_indent(aTHX_ level, file, "REFCNT = %"UVuf"\n", (UV)o->op_targ);
698 if (o->op_flags & OPf_KIDS) {
700 for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling)
701 do_op_dump(level, file, kid);
703 Perl_dump_indent(aTHX_ level-1, file, "}\n");
707 Perl_op_dump(pTHX_ OP *o)
709 do_op_dump(0, Perl_debug_log, o);
713 Perl_gv_dump(pTHX_ GV *gv)
718 PerlIO_printf(Perl_debug_log, "{}\n");
722 PerlIO_printf(Perl_debug_log, "{\n");
723 gv_fullname3(sv, gv, Nullch);
724 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "GV_NAME = %s", SvPVX(sv));
725 if (gv != GvEGV(gv)) {
726 gv_efullname3(sv, GvEGV(gv), Nullch);
727 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", SvPVX(sv));
729 PerlIO_putc(Perl_debug_log, '\n');
730 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "}\n");
734 /* map magic types to the symbolic name
735 * (with the PERL_MAGIC_ prefixed stripped)
738 static struct { char type; char *name; } magic_names[] = {
739 { PERL_MAGIC_sv, "sv(\\0)" },
740 { PERL_MAGIC_arylen, "arylen(#)" },
741 { PERL_MAGIC_glob, "glob(*)" },
742 { PERL_MAGIC_pos, "pos(.)" },
743 { PERL_MAGIC_backref, "backref(<)" },
744 { PERL_MAGIC_overload, "overload(A)" },
745 { PERL_MAGIC_bm, "bm(B)" },
746 { PERL_MAGIC_regdata, "regdata(D)" },
747 { PERL_MAGIC_env, "env(E)" },
748 { PERL_MAGIC_isa, "isa(I)" },
749 { PERL_MAGIC_dbfile, "dbfile(L)" },
750 { PERL_MAGIC_tied, "tied(P)" },
751 { PERL_MAGIC_sig, "sig(S)" },
752 { PERL_MAGIC_uvar, "uvar(U)" },
753 { PERL_MAGIC_overload_elem, "overload_elem(a)" },
754 { PERL_MAGIC_overload_table, "overload_table(c)" },
755 { PERL_MAGIC_regdatum, "regdatum(d)" },
756 { PERL_MAGIC_envelem, "envelem(e)" },
757 { PERL_MAGIC_fm, "fm(f)" },
758 { PERL_MAGIC_regex_global, "regex_global(g)" },
759 { PERL_MAGIC_isaelem, "isaelem(i)" },
760 { PERL_MAGIC_nkeys, "nkeys(k)" },
761 { PERL_MAGIC_dbline, "dbline(l)" },
762 { PERL_MAGIC_mutex, "mutex(m)" },
763 { PERL_MAGIC_collxfrm, "collxfrm(o)" },
764 { PERL_MAGIC_tiedelem, "tiedelem(p)" },
765 { PERL_MAGIC_tiedscalar, "tiedscalar(q)" },
766 { PERL_MAGIC_qr, "qr(r)" },
767 { PERL_MAGIC_sigelem, "sigelem(s)" },
768 { PERL_MAGIC_taint, "taint(t)" },
769 { PERL_MAGIC_vec, "vec(v)" },
770 { PERL_MAGIC_substr, "substr(x)" },
771 { PERL_MAGIC_defelem, "defelem(y)" },
772 { PERL_MAGIC_ext, "ext(~)" },
773 /* this null string terminates the list */
778 Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
780 for (; mg; mg = mg->mg_moremagic) {
781 Perl_dump_indent(aTHX_ level, file,
782 " MAGIC = 0x%"UVxf"\n", PTR2UV(mg));
783 if (mg->mg_virtual) {
784 MGVTBL *v = mg->mg_virtual;
786 if (v == &PL_vtbl_sv) s = "sv";
787 else if (v == &PL_vtbl_env) s = "env";
788 else if (v == &PL_vtbl_envelem) s = "envelem";
789 else if (v == &PL_vtbl_sig) s = "sig";
790 else if (v == &PL_vtbl_sigelem) s = "sigelem";
791 else if (v == &PL_vtbl_pack) s = "pack";
792 else if (v == &PL_vtbl_packelem) s = "packelem";
793 else if (v == &PL_vtbl_dbline) s = "dbline";
794 else if (v == &PL_vtbl_isa) s = "isa";
795 else if (v == &PL_vtbl_arylen) s = "arylen";
796 else if (v == &PL_vtbl_glob) s = "glob";
797 else if (v == &PL_vtbl_mglob) s = "mglob";
798 else if (v == &PL_vtbl_nkeys) s = "nkeys";
799 else if (v == &PL_vtbl_taint) s = "taint";
800 else if (v == &PL_vtbl_substr) s = "substr";
801 else if (v == &PL_vtbl_vec) s = "vec";
802 else if (v == &PL_vtbl_pos) s = "pos";
803 else if (v == &PL_vtbl_bm) s = "bm";
804 else if (v == &PL_vtbl_fm) s = "fm";
805 else if (v == &PL_vtbl_uvar) s = "uvar";
806 else if (v == &PL_vtbl_defelem) s = "defelem";
807 #ifdef USE_LOCALE_COLLATE
808 else if (v == &PL_vtbl_collxfrm) s = "collxfrm";
810 else if (v == &PL_vtbl_amagic) s = "amagic";
811 else if (v == &PL_vtbl_amagicelem) s = "amagicelem";
812 else if (v == &PL_vtbl_backref) s = "backref";
814 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = &PL_vtbl_%s\n", s);
816 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0x%"UVxf"\n", PTR2UV(v));
819 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0\n");
822 Perl_dump_indent(aTHX_ level, file, " MG_PRIVATE = %d\n", mg->mg_private);
827 for (n=0; magic_names[n].name; n++) {
828 if (mg->mg_type == magic_names[n].type) {
829 name = magic_names[n].name;
834 Perl_dump_indent(aTHX_ level, file,
835 " MG_TYPE = PERL_MAGIC_%s\n", name);
837 Perl_dump_indent(aTHX_ level, file,
838 " MG_TYPE = UNKNOWN(\\%o)\n", mg->mg_type);
842 Perl_dump_indent(aTHX_ level, file, " MG_FLAGS = 0x%02X\n", mg->mg_flags);
843 if (mg->mg_flags & MGf_TAINTEDDIR)
844 Perl_dump_indent(aTHX_ level, file, " TAINTEDDIR\n");
845 if (mg->mg_flags & MGf_REFCOUNTED)
846 Perl_dump_indent(aTHX_ level, file, " REFCOUNTED\n");
847 if (mg->mg_flags & MGf_GSKIP)
848 Perl_dump_indent(aTHX_ level, file, " GSKIP\n");
849 if (mg->mg_flags & MGf_MINMATCH)
850 Perl_dump_indent(aTHX_ level, file, " MINMATCH\n");
853 Perl_dump_indent(aTHX_ level, file, " MG_OBJ = 0x%"UVxf"\n", PTR2UV(mg->mg_obj));
854 if (mg->mg_flags & MGf_REFCOUNTED)
855 do_sv_dump(level+2, file, mg->mg_obj, nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
858 Perl_dump_indent(aTHX_ level, file, " MG_LEN = %ld\n", (long)mg->mg_len);
860 Perl_dump_indent(aTHX_ level, file, " MG_PTR = 0x%"UVxf, PTR2UV(mg->mg_ptr));
861 if (mg->mg_len >= 0) {
862 SV *sv = newSVpvn("", 0);
863 PerlIO_printf(file, " %s", pv_display(sv, mg->mg_ptr, mg->mg_len, 0, pvlim));
866 else if (mg->mg_len == HEf_SVKEY) {
867 PerlIO_puts(file, " => HEf_SVKEY\n");
868 do_sv_dump(level+2, file, (SV*)((mg)->mg_ptr), nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
872 PerlIO_puts(file, " ???? - please notify IZ");
873 PerlIO_putc(file, '\n');
879 Perl_magic_dump(pTHX_ MAGIC *mg)
881 do_magic_dump(0, Perl_debug_log, mg, 0, 0, 0, 0);
885 Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, char *name, HV *sv)
887 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
888 if (sv && HvNAME(sv))
889 PerlIO_printf(file, "\t\"%s\"\n", HvNAME(sv));
891 PerlIO_putc(file, '\n');
895 Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
897 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
898 if (sv && GvNAME(sv))
899 PerlIO_printf(file, "\t\"%s\"\n", GvNAME(sv));
901 PerlIO_putc(file, '\n');
905 Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
907 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
908 if (sv && GvNAME(sv)) {
909 PerlIO_printf(file, "\t\"");
911 PerlIO_printf(file, "%s\" :: \"", HvNAME(GvSTASH(sv)));
912 PerlIO_printf(file, "%s\"\n", GvNAME(sv));
915 PerlIO_putc(file, '\n');
919 Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
928 Perl_dump_indent(aTHX_ level, file, "SV = 0\n");
935 d = Perl_newSVpvf(aTHX_
936 "(0x%"UVxf") at 0x%"UVxf"\n%*s REFCNT = %"IVdf"\n%*s FLAGS = (",
937 PTR2UV(SvANY(sv)), PTR2UV(sv),
938 (int)(PL_dumpindent*level), "", (IV)SvREFCNT(sv),
939 (int)(PL_dumpindent*level), "");
941 if (flags & SVs_PADBUSY) sv_catpv(d, "PADBUSY,");
942 if (flags & SVs_PADTMP) sv_catpv(d, "PADTMP,");
943 if (flags & SVs_PADMY) sv_catpv(d, "PADMY,");
944 if (flags & SVs_TEMP) sv_catpv(d, "TEMP,");
945 if (flags & SVs_OBJECT) sv_catpv(d, "OBJECT,");
946 if (flags & SVs_GMG) sv_catpv(d, "GMG,");
947 if (flags & SVs_SMG) sv_catpv(d, "SMG,");
948 if (flags & SVs_RMG) sv_catpv(d, "RMG,");
950 if (flags & SVf_IOK) sv_catpv(d, "IOK,");
951 if (flags & SVf_NOK) sv_catpv(d, "NOK,");
952 if (flags & SVf_POK) sv_catpv(d, "POK,");
953 if (flags & SVf_ROK) {
955 if (SvWEAKREF(sv)) sv_catpv(d, "WEAKREF,");
957 if (flags & SVf_OOK) sv_catpv(d, "OOK,");
958 if (flags & SVf_FAKE) sv_catpv(d, "FAKE,");
959 if (flags & SVf_READONLY) sv_catpv(d, "READONLY,");
961 if (flags & SVf_AMAGIC) sv_catpv(d, "OVERLOAD,");
962 if (flags & SVp_IOK) sv_catpv(d, "pIOK,");
963 if (flags & SVp_NOK) sv_catpv(d, "pNOK,");
964 if (flags & SVp_POK) sv_catpv(d, "pPOK,");
965 if (flags & SVp_SCREAM) sv_catpv(d, "SCREAM,");
970 if (CvANON(sv)) sv_catpv(d, "ANON,");
971 if (CvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
972 if (CvCLONE(sv)) sv_catpv(d, "CLONE,");
973 if (CvCLONED(sv)) sv_catpv(d, "CLONED,");
974 if (CvCONST(sv)) sv_catpv(d, "CONST,");
975 if (CvNODEBUG(sv)) sv_catpv(d, "NODEBUG,");
976 if (SvCOMPILED(sv)) sv_catpv(d, "COMPILED,");
977 if (CvLVALUE(sv)) sv_catpv(d, "LVALUE,");
978 if (CvMETHOD(sv)) sv_catpv(d, "METHOD,");
981 if (HvSHAREKEYS(sv)) sv_catpv(d, "SHAREKEYS,");
982 if (HvLAZYDEL(sv)) sv_catpv(d, "LAZYDEL,");
983 if (HvUTF8KEYS(sv)) sv_catpv(d, "UTF8,");
986 if (GvINTRO(sv)) sv_catpv(d, "INTRO,");
987 if (GvMULTI(sv)) sv_catpv(d, "MULTI,");
988 if (GvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
989 if (GvASSUMECV(sv)) sv_catpv(d, "ASSUMECV,");
990 if (GvIN_PAD(sv)) sv_catpv(d, "IN_PAD,");
991 if (flags & SVpad_OUR) sv_catpv(d, "OUR,");
992 if (GvIMPORTED(sv)) {
993 sv_catpv(d, "IMPORT");
994 if (GvIMPORTED(sv) == GVf_IMPORTED)
998 if (GvIMPORTED_SV(sv)) sv_catpv(d, " SV");
999 if (GvIMPORTED_AV(sv)) sv_catpv(d, " AV");
1000 if (GvIMPORTED_HV(sv)) sv_catpv(d, " HV");
1001 if (GvIMPORTED_CV(sv)) sv_catpv(d, " CV");
1007 if (SvEVALED(sv)) sv_catpv(d, "EVALED,");
1008 if (SvIsUV(sv)) sv_catpv(d, "IsUV,");
1011 if (SvTAIL(sv)) sv_catpv(d, "TAIL,");
1012 if (SvVALID(sv)) sv_catpv(d, "VALID,");
1015 if (flags & SVpad_TYPED)
1016 sv_catpv(d, "TYPED,");
1019 if (SvPOK(sv) && SvUTF8(sv))
1020 sv_catpv(d, "UTF8");
1022 if (*(SvEND(d) - 1) == ',')
1023 SvPVX(d)[--SvCUR(d)] = '\0';
1027 Perl_dump_indent(aTHX_ level, file, "SV = ");
1030 PerlIO_printf(file, "NULL%s\n", s);
1034 PerlIO_printf(file, "IV%s\n", s);
1037 PerlIO_printf(file, "NV%s\n", s);
1040 PerlIO_printf(file, "RV%s\n", s);
1043 PerlIO_printf(file, "PV%s\n", s);
1046 PerlIO_printf(file, "PVIV%s\n", s);
1049 PerlIO_printf(file, "PVNV%s\n", s);
1052 PerlIO_printf(file, "PVBM%s\n", s);
1055 PerlIO_printf(file, "PVMG%s\n", s);
1058 PerlIO_printf(file, "PVLV%s\n", s);
1061 PerlIO_printf(file, "PVAV%s\n", s);
1064 PerlIO_printf(file, "PVHV%s\n", s);
1067 PerlIO_printf(file, "PVCV%s\n", s);
1070 PerlIO_printf(file, "PVGV%s\n", s);
1073 PerlIO_printf(file, "PVFM%s\n", s);
1076 PerlIO_printf(file, "PVIO%s\n", s);
1079 PerlIO_printf(file, "UNKNOWN(0x%"UVxf") %s\n", (UV)type, s);
1083 if (type >= SVt_PVIV || type == SVt_IV) {
1085 Perl_dump_indent(aTHX_ level, file, " UV = %"UVuf, (UV)SvUVX(sv));
1087 Perl_dump_indent(aTHX_ level, file, " IV = %"IVdf, (IV)SvIVX(sv));
1089 PerlIO_printf(file, " (OFFSET)");
1090 PerlIO_putc(file, '\n');
1092 if (type >= SVt_PVNV || type == SVt_NV) {
1093 STORE_NUMERIC_LOCAL_SET_STANDARD();
1094 /* %Vg doesn't work? --jhi */
1095 #ifdef USE_LONG_DOUBLE
1096 Perl_dump_indent(aTHX_ level, file, " NV = %.*" PERL_PRIgldbl "\n", LDBL_DIG, SvNVX(sv));
1098 Perl_dump_indent(aTHX_ level, file, " NV = %.*g\n", DBL_DIG, SvNVX(sv));
1100 RESTORE_NUMERIC_LOCAL();
1103 Perl_dump_indent(aTHX_ level, file, " RV = 0x%"UVxf"\n", PTR2UV(SvRV(sv)));
1105 do_sv_dump(level+1, file, SvRV(sv), nest+1, maxnest, dumpops, pvlim);
1109 if (type < SVt_PV) {
1113 if (type <= SVt_PVLV) {
1115 Perl_dump_indent(aTHX_ level, file," PV = 0x%"UVxf" ", PTR2UV(SvPVX(sv)));
1117 PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim));
1118 PerlIO_printf(file, "%s", pv_display(d, SvPVX(sv), SvCUR(sv), SvLEN(sv), pvlim));
1119 if (SvUTF8(sv)) /* the 8? \x{....} */
1120 PerlIO_printf(file, " [UTF8 \"%s\"]", sv_uni_display(d, sv, 8 * sv_len_utf8(sv), UNI_DISPLAY_QQ));
1121 PerlIO_printf(file, "\n");
1122 Perl_dump_indent(aTHX_ level, file, " CUR = %"IVdf"\n", (IV)SvCUR(sv));
1123 Perl_dump_indent(aTHX_ level, file, " LEN = %"IVdf"\n", (IV)SvLEN(sv));
1126 Perl_dump_indent(aTHX_ level, file, " PV = 0\n");
1128 if (type >= SVt_PVMG) {
1130 do_magic_dump(level, file, SvMAGIC(sv), nest, maxnest, dumpops, pvlim);
1132 do_hv_dump(level, file, " STASH", SvSTASH(sv));
1136 Perl_dump_indent(aTHX_ level, file, " TYPE = %c\n", LvTYPE(sv));
1137 Perl_dump_indent(aTHX_ level, file, " TARGOFF = %"IVdf"\n", (IV)LvTARGOFF(sv));
1138 Perl_dump_indent(aTHX_ level, file, " TARGLEN = %"IVdf"\n", (IV)LvTARGLEN(sv));
1139 Perl_dump_indent(aTHX_ level, file, " TARG = 0x%"UVxf"\n", PTR2UV(LvTARG(sv)));
1140 /* XXX level+1 ??? */
1141 do_sv_dump(level, file, LvTARG(sv), nest+1, maxnest, dumpops, pvlim);
1144 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(AvARRAY(sv)));
1145 if (AvARRAY(sv) != AvALLOC(sv)) {
1146 PerlIO_printf(file, " (offset=%"IVdf")\n", (IV)(AvARRAY(sv) - AvALLOC(sv)));
1147 Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%"UVxf"\n", PTR2UV(AvALLOC(sv)));
1150 PerlIO_putc(file, '\n');
1151 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)AvFILLp(sv));
1152 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)AvMAX(sv));
1153 Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%"UVxf"\n", PTR2UV(AvARYLEN(sv)));
1154 flags = AvFLAGS(sv);
1156 if (flags & AVf_REAL) sv_catpv(d, ",REAL");
1157 if (flags & AVf_REIFY) sv_catpv(d, ",REIFY");
1158 if (flags & AVf_REUSED) sv_catpv(d, ",REUSED");
1159 Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n", SvCUR(d) ? SvPVX(d) + 1 : "");
1160 if (nest < maxnest && av_len((AV*)sv) >= 0) {
1162 for (count = 0; count <= av_len((AV*)sv) && count < maxnest; count++) {
1163 SV** elt = av_fetch((AV*)sv,count,0);
1165 Perl_dump_indent(aTHX_ level + 1, file, "Elt No. %"IVdf"\n", (IV)count);
1167 do_sv_dump(level+1, file, *elt, nest+1, maxnest, dumpops, pvlim);
1172 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(HvARRAY(sv)));
1173 if (HvARRAY(sv) && HvKEYS(sv)) {
1174 /* Show distribution of HEs in the ARRAY */
1176 #define FREQ_MAX (sizeof freq / sizeof freq[0] - 1)
1179 U32 pow2 = 2, keys = HvKEYS(sv);
1180 NV theoret, sum = 0;
1182 PerlIO_printf(file, " (");
1183 Zero(freq, FREQ_MAX + 1, int);
1184 for (i = 0; i <= HvMAX(sv); i++) {
1185 HE* h; int count = 0;
1186 for (h = HvARRAY(sv)[i]; h; h = HeNEXT(h))
1188 if (count > FREQ_MAX)
1194 for (i = 0; i <= max; i++) {
1196 PerlIO_printf(file, "%d%s:%d", i,
1197 (i == FREQ_MAX) ? "+" : "",
1200 PerlIO_printf(file, ", ");
1203 PerlIO_putc(file, ')');
1204 /* The "quality" of a hash is defined as the total number of
1205 comparisons needed to access every element once, relative
1206 to the expected number needed for a random hash.
1208 The total number of comparisons is equal to the sum of
1209 the squares of the number of entries in each bucket.
1210 For a random hash of n keys into k buckets, the expected
1215 for (i = max; i > 0; i--) { /* Precision: count down. */
1216 sum += freq[i] * i * i;
1218 while ((keys = keys >> 1))
1220 theoret = HvKEYS(sv);
1221 theoret += theoret * (theoret-1)/pow2;
1222 PerlIO_putc(file, '\n');
1223 Perl_dump_indent(aTHX_ level, file, " hash quality = %.1"NVff"%%", theoret/sum*100);
1225 PerlIO_putc(file, '\n');
1226 Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)HvKEYS(sv));
1227 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)HvFILL(sv));
1228 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)HvMAX(sv));
1229 Perl_dump_indent(aTHX_ level, file, " RITER = %"IVdf"\n", (IV)HvRITER(sv));
1230 Perl_dump_indent(aTHX_ level, file, " EITER = 0x%"UVxf"\n", PTR2UV(HvEITER(sv)));
1232 Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%"UVxf"\n", PTR2UV(HvPMROOT(sv)));
1234 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", HvNAME(sv));
1235 if (nest < maxnest && !HvEITER(sv)) { /* Try to preserve iterator */
1238 int count = maxnest - nest;
1241 while ((he = hv_iternext(hv)) && count--) {
1245 U32 hash = HeHASH(he);
1247 keysv = hv_iterkeysv(he);
1248 keypv = SvPV(keysv, len);
1249 elt = hv_iterval(hv, he);
1250 Perl_dump_indent(aTHX_ level+1, file, "Elt %s ", pv_display(d, keypv, len, 0, pvlim));
1252 PerlIO_printf(file, "[UTF8 \"%s\"] ", sv_uni_display(d, keysv, 8 * sv_len_utf8(keysv), UNI_DISPLAY_QQ));
1253 PerlIO_printf(file, "HASH = 0x%"UVxf"\n", (UV)hash);
1254 do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim);
1256 hv_iterinit(hv); /* Return to status quo */
1261 Perl_dump_indent(aTHX_ level, file, " PROTOTYPE = \"%s\"\n", SvPV(sv,n_a));
1264 do_hv_dump(level, file, " COMP_STASH", CvSTASH(sv));
1266 Perl_dump_indent(aTHX_ level, file, " START = 0x%"UVxf" ===> %"IVdf"\n", PTR2UV(CvSTART(sv)), (IV)CvSTART(sv)->op_seq);
1267 Perl_dump_indent(aTHX_ level, file, " ROOT = 0x%"UVxf"\n", PTR2UV(CvROOT(sv)));
1268 if (CvROOT(sv) && dumpops)
1269 do_op_dump(level+1, file, CvROOT(sv));
1270 Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%"UVxf"\n", PTR2UV(CvXSUB(sv)));
1271 Perl_dump_indent(aTHX_ level, file, " XSUBANY = %"IVdf"\n", (IV)CvXSUBANY(sv).any_i32);
1272 do_gvgv_dump(level, file, " GVGV::GV", CvGV(sv));
1273 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", CvFILE(sv));
1274 Perl_dump_indent(aTHX_ level, file, " DEPTH = %"IVdf"\n", (IV)CvDEPTH(sv));
1275 #ifdef USE_5005THREADS
1276 Perl_dump_indent(aTHX_ level, file, " MUTEXP = 0x%"UVxf"\n", PTR2UV(CvMUTEXP(sv)));
1277 Perl_dump_indent(aTHX_ level, file, " OWNER = 0x%"UVxf"\n", PTR2UV(CvOWNER(sv)));
1278 #endif /* USE_5005THREADS */
1279 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)CvFLAGS(sv));
1280 if (type == SVt_PVFM)
1281 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)FmLINES(sv));
1282 Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%"UVxf"\n", PTR2UV(CvPADLIST(sv)));
1283 if (nest < maxnest && CvPADLIST(sv)) {
1284 AV* padlist = CvPADLIST(sv);
1285 AV* pad_name = (AV*)*av_fetch(padlist, 0, FALSE);
1286 AV* pad = (AV*)*av_fetch(padlist, 1, FALSE);
1287 SV** pname = AvARRAY(pad_name);
1288 SV** ppad = AvARRAY(pad);
1291 for (ix = 1; ix <= AvFILL(pad_name); ix++) {
1292 if (SvPOK(pname[ix]))
1293 Perl_dump_indent(aTHX_ level,
1294 /* %5d below is enough whitespace. */
1296 "%5d. 0x%"UVxf" (%s\"%s\" %"IVdf"-%"IVdf")\n",
1297 (int)ix, PTR2UV(ppad[ix]),
1298 SvFAKE(pname[ix]) ? "FAKE " : "",
1300 (IV)SvNVX(pname[ix]),
1301 (IV)SvIVX(pname[ix]));
1305 CV *outside = CvOUTSIDE(sv);
1306 Perl_dump_indent(aTHX_ level, file, " OUTSIDE = 0x%"UVxf" (%s)\n",
1309 : CvANON(outside) ? "ANON"
1310 : (outside == PL_main_cv) ? "MAIN"
1311 : CvUNIQUE(outside) ? "UNIQUE"
1312 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
1314 if (nest < maxnest && (CvCLONE(sv) || CvCLONED(sv)))
1315 do_sv_dump(level+1, file, (SV*)CvOUTSIDE(sv), nest+1, maxnest, dumpops, pvlim);
1318 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", GvNAME(sv));
1319 Perl_dump_indent(aTHX_ level, file, " NAMELEN = %"IVdf"\n", (IV)GvNAMELEN(sv));
1320 do_hv_dump (level, file, " GvSTASH", GvSTASH(sv));
1321 Perl_dump_indent(aTHX_ level, file, " GP = 0x%"UVxf"\n", PTR2UV(GvGP(sv)));
1324 Perl_dump_indent(aTHX_ level, file, " SV = 0x%"UVxf"\n", PTR2UV(GvSV(sv)));
1325 Perl_dump_indent(aTHX_ level, file, " REFCNT = %"IVdf"\n", (IV)GvREFCNT(sv));
1326 Perl_dump_indent(aTHX_ level, file, " IO = 0x%"UVxf"\n", PTR2UV(GvIOp(sv)));
1327 Perl_dump_indent(aTHX_ level, file, " FORM = 0x%"UVxf" \n", PTR2UV(GvFORM(sv)));
1328 Perl_dump_indent(aTHX_ level, file, " AV = 0x%"UVxf"\n", PTR2UV(GvAV(sv)));
1329 Perl_dump_indent(aTHX_ level, file, " HV = 0x%"UVxf"\n", PTR2UV(GvHV(sv)));
1330 Perl_dump_indent(aTHX_ level, file, " CV = 0x%"UVxf"\n", PTR2UV(GvCV(sv)));
1331 Perl_dump_indent(aTHX_ level, file, " CVGEN = 0x%"UVxf"\n", (UV)GvCVGEN(sv));
1332 Perl_dump_indent(aTHX_ level, file, " GPFLAGS = 0x%"UVxf"\n", (UV)GvGPFLAGS(sv));
1333 Perl_dump_indent(aTHX_ level, file, " LINE = %"IVdf"\n", (IV)GvLINE(sv));
1334 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", GvFILE(sv));
1335 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)GvFLAGS(sv));
1336 do_gv_dump (level, file, " EGV", GvEGV(sv));
1339 Perl_dump_indent(aTHX_ level, file, " IFP = 0x%"UVxf"\n", PTR2UV(IoIFP(sv)));
1340 Perl_dump_indent(aTHX_ level, file, " OFP = 0x%"UVxf"\n", PTR2UV(IoOFP(sv)));
1341 Perl_dump_indent(aTHX_ level, file, " DIRP = 0x%"UVxf"\n", PTR2UV(IoDIRP(sv)));
1342 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)IoLINES(sv));
1343 Perl_dump_indent(aTHX_ level, file, " PAGE = %"IVdf"\n", (IV)IoPAGE(sv));
1344 Perl_dump_indent(aTHX_ level, file, " PAGE_LEN = %"IVdf"\n", (IV)IoPAGE_LEN(sv));
1345 Perl_dump_indent(aTHX_ level, file, " LINES_LEFT = %"IVdf"\n", (IV)IoLINES_LEFT(sv));
1347 Perl_dump_indent(aTHX_ level, file, " TOP_NAME = \"%s\"\n", IoTOP_NAME(sv));
1348 do_gv_dump (level, file, " TOP_GV", IoTOP_GV(sv));
1350 Perl_dump_indent(aTHX_ level, file, " FMT_NAME = \"%s\"\n", IoFMT_NAME(sv));
1351 do_gv_dump (level, file, " FMT_GV", IoFMT_GV(sv));
1352 if (IoBOTTOM_NAME(sv))
1353 Perl_dump_indent(aTHX_ level, file, " BOTTOM_NAME = \"%s\"\n", IoBOTTOM_NAME(sv));
1354 do_gv_dump (level, file, " BOTTOM_GV", IoBOTTOM_GV(sv));
1355 Perl_dump_indent(aTHX_ level, file, " SUBPROCESS = %"IVdf"\n", (IV)IoSUBPROCESS(sv));
1356 if (isPRINT(IoTYPE(sv)))
1357 Perl_dump_indent(aTHX_ level, file, " TYPE = '%c'\n", IoTYPE(sv));
1359 Perl_dump_indent(aTHX_ level, file, " TYPE = '\\%o'\n", IoTYPE(sv));
1360 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)IoFLAGS(sv));
1367 Perl_sv_dump(pTHX_ SV *sv)
1369 do_sv_dump(0, Perl_debug_log, sv, 0, 0, 0, 0);
1373 Perl_runops_debug(pTHX)
1376 if (ckWARN_d(WARN_DEBUGGING))
1377 Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "NULL OP IN RUN");
1384 if (PL_watchaddr != 0 && *PL_watchaddr != PL_watchok)
1385 PerlIO_printf(Perl_debug_log,
1386 "WARNING: %"UVxf" changed from %"UVxf" to %"UVxf"\n",
1387 PTR2UV(PL_watchaddr), PTR2UV(PL_watchok),
1388 PTR2UV(*PL_watchaddr));
1389 if (DEBUG_s_TEST_) debstack();
1390 if (DEBUG_t_TEST_) debop(PL_op);
1391 if (DEBUG_P_TEST_) debprof(PL_op);
1393 } while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX)));
1400 Perl_debop(pTHX_ OP *o)
1402 AV *padlist, *comppad;
1407 if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
1410 Perl_deb(aTHX_ "%s", OP_NAME(o));
1411 switch (o->op_type) {
1413 PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOPo_sv));
1419 gv_fullname3(sv, cGVOPo_gv, Nullch);
1420 PerlIO_printf(Perl_debug_log, "(%s)", SvPV(sv, n_a));
1424 PerlIO_printf(Perl_debug_log, "(NULL)");
1429 /* print the lexical's name */
1430 cv = deb_curcv(cxstack_ix);
1432 padlist = CvPADLIST(cv);
1433 comppad = (AV*)(*av_fetch(padlist, 0, FALSE));
1434 sv = *av_fetch(comppad, o->op_targ, FALSE);
1438 PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen(sv));
1440 PerlIO_printf(Perl_debug_log, "[%"UVuf"]", (UV)o->op_targ);
1445 PerlIO_printf(Perl_debug_log, "\n");
1450 S_deb_curcv(pTHX_ I32 ix)
1452 PERL_CONTEXT *cx = &cxstack[ix];
1453 if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT)
1454 return cx->blk_sub.cv;
1455 else if (CxTYPE(cx) == CXt_EVAL && !CxTRYBLOCK(cx))
1457 else if (ix == 0 && PL_curstackinfo->si_type == PERLSI_MAIN)
1462 return deb_curcv(ix - 1);
1466 Perl_watch(pTHX_ char **addr)
1468 PL_watchaddr = addr;
1470 PerlIO_printf(Perl_debug_log, "WATCHING, %"UVxf" is currently %"UVxf"\n",
1471 PTR2UV(PL_watchaddr), PTR2UV(PL_watchok));
1475 S_debprof(pTHX_ OP *o)
1477 if (CopSTASH_eq(PL_curcop, PL_debstash) && !DEBUG_J_TEST_)
1479 if (!PL_profiledata)
1480 Newz(000, PL_profiledata, MAXO, U32);
1481 ++PL_profiledata[o->op_type];
1485 Perl_debprofdump(pTHX)
1488 if (!PL_profiledata)
1490 for (i = 0; i < MAXO; i++) {
1491 if (PL_profiledata[i])
1492 PerlIO_printf(Perl_debug_log,
1493 "%5lu %s\n", (unsigned long)PL_profiledata[i],