This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Further discourage old Thread code; tell how to tell
[perl5.git] / dump.c
CommitLineData
a0d0e21e 1/* dump.c
a687059c 2 *
bc89e66f 3 * Copyright (c) 1991-2001, Larry Wall
a687059c 4 *
6e21c824
LW
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.
8d063cd8 7 *
a0d0e21e
LW
8 */
9
10/*
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.'"
8d063cd8
LW
13 */
14
8d063cd8 15#include "EXTERN.h"
864dbfa3 16#define PERL_IN_DUMP_C
8d063cd8 17#include "perl.h"
f722798b 18#include "regcomp.h"
8d063cd8 19
3967c732 20void
864dbfa3 21Perl_dump_indent(pTHX_ I32 level, PerlIO *file, const char* pat, ...)
3967c732 22{
3967c732 23 va_list args;
3967c732 24 va_start(args, pat);
c5be433b 25 dump_vindent(level, file, pat, &args);
3967c732
JD
26 va_end(args);
27}
8adcabd8
LW
28
29void
c5be433b
GS
30Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args)
31{
c8db6e60 32 PerlIO_printf(file, "%*s", (int)(level*PL_dumpindent), "");
c5be433b
GS
33 PerlIO_vprintf(file, pat, *args);
34}
35
36void
864dbfa3 37Perl_dump_all(pTHX)
79072805 38{
760ac839 39 PerlIO_setlinebuf(Perl_debug_log);
3280af22 40 if (PL_main_root)
3967c732 41 op_dump(PL_main_root);
3280af22 42 dump_packsubs(PL_defstash);
463ee0b2
LW
43}
44
45void
864dbfa3 46Perl_dump_packsubs(pTHX_ HV *stash)
463ee0b2 47{
a0d0e21e 48 I32 i;
463ee0b2
LW
49 HE *entry;
50
8990e307
LW
51 if (!HvARRAY(stash))
52 return;
a0d0e21e 53 for (i = 0; i <= (I32) HvMAX(stash); i++) {
4db58590
PP
54 for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) {
55 GV *gv = (GV*)HeVAL(entry);
463ee0b2 56 HV *hv;
e29cdcb3
GS
57 if (SvTYPE(gv) != SVt_PVGV || !GvGP(gv))
58 continue;
8ebc5c01 59 if (GvCVu(gv))
463ee0b2 60 dump_sub(gv);
85e6fe83
LW
61 if (GvFORM(gv))
62 dump_form(gv);
6676db26
AMS
63 if (HeKEY(entry)[HeKLEN(entry)-1] == ':'
64 && (hv = GvHV(gv)) && hv != PL_defstash)
463ee0b2
LW
65 dump_packsubs(hv); /* nested package */
66 }
79072805
LW
67 }
68}
69
70void
864dbfa3 71Perl_dump_sub(pTHX_ GV *gv)
a687059c 72{
8990e307 73 SV *sv = sv_newmortal();
85e6fe83 74
f6aff53a 75 gv_fullname3(sv, gv, Nullch);
cea2e8a9 76 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nSUB %s = ", SvPVX(sv));
a0d0e21e 77 if (CvXSUB(GvCV(gv)))
894356b3 78 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "(xsub 0x%lx %d)\n",
a0d0e21e 79 (long)CvXSUB(GvCV(gv)),
894356b3 80 (int)CvXSUBANY(GvCV(gv)).any_i32);
85e6fe83 81 else if (CvROOT(GvCV(gv)))
3967c732 82 op_dump(CvROOT(GvCV(gv)));
85e6fe83 83 else
cea2e8a9 84 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "<undef>\n");
85e6fe83
LW
85}
86
87void
864dbfa3 88Perl_dump_form(pTHX_ GV *gv)
85e6fe83
LW
89{
90 SV *sv = sv_newmortal();
91
f6aff53a 92 gv_fullname3(sv, gv, Nullch);
cea2e8a9 93 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nFORMAT %s = ", SvPVX(sv));
85e6fe83 94 if (CvROOT(GvFORM(gv)))
3967c732 95 op_dump(CvROOT(GvFORM(gv)));
85e6fe83 96 else
cea2e8a9 97 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "<undef>\n");
a687059c
LW
98}
99
8adcabd8 100void
864dbfa3 101Perl_dump_eval(pTHX)
8d063cd8 102{
3967c732
JD
103 op_dump(PL_eval_root);
104}
105
106char *
e6abe6d8 107Perl_pv_display(pTHX_ SV *dsv, char *pv, STRLEN cur, STRLEN len, STRLEN pvlim)
3967c732
JD
108{
109 int truncated = 0;
110 int nul_terminated = len > cur && pv[cur] == '\0';
111
e6abe6d8 112 sv_setpvn(dsv, "\"", 1);
3967c732 113 for (; cur--; pv++) {
e6abe6d8 114 if (pvlim && SvCUR(dsv) >= pvlim) {
3967c732
JD
115 truncated++;
116 break;
117 }
118 if (isPRINT(*pv)) {
119 switch (*pv) {
e6abe6d8
JH
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;
3967c732
JD
127 }
128 }
129 else {
130 if (cur && isDIGIT(*(pv+1)))
e6abe6d8 131 Perl_sv_catpvf(aTHX_ dsv, "\\%03o", (U8)*pv);
3967c732 132 else
e6abe6d8 133 Perl_sv_catpvf(aTHX_ dsv, "\\%o", (U8)*pv);
3967c732
JD
134 }
135 }
e6abe6d8 136 sv_catpvn(dsv, "\"", 1);
3967c732 137 if (truncated)
e6abe6d8 138 sv_catpvn(dsv, "...", 3);
3967c732 139 if (nul_terminated)
e6abe6d8 140 sv_catpvn(dsv, "\\0", 2);
3967c732 141
e6abe6d8
JH
142 return SvPVX(dsv);
143}
144
145char *
143014bf 146Perl_pv_uni_display(pTHX_ SV *dsv, U8 *spv, STRLEN len, STRLEN pvlim, UV flags)
e6abe6d8
JH
147{
148 int truncated = 0;
149 char *s, *e;
150
b2ff9928 151 sv_setpvn(dsv, "", 0);
143014bf 152 for (s = (char *)spv, e = s + len; s < e; s += UTF8SKIP(s)) {
e6abe6d8
JH
153 UV u;
154 if (pvlim && SvCUR(dsv) >= pvlim) {
155 truncated++;
156 break;
157 }
158 u = utf8_to_uvchr((U8*)s, 0);
bc128d29 159 Perl_sv_catpvf(aTHX_ dsv, "\\x{%"UVxf"}", u);
e6abe6d8 160 }
e6abe6d8
JH
161 if (truncated)
162 sv_catpvn(dsv, "...", 3);
163
164 return SvPVX(dsv);
3967c732
JD
165}
166
167char *
143014bf
JH
168Perl_sv_uni_display(pTHX_ SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
169{
170 return Perl_pv_uni_display(aTHX_ dsv, (U8*)SvPVX(ssv), SvCUR(ssv),
171 pvlim, flags);
172}
173
174char *
864dbfa3 175Perl_sv_peek(pTHX_ SV *sv)
3967c732
JD
176{
177 SV *t = sv_newmortal();
2d8e6c8d 178 STRLEN n_a;
3967c732
JD
179 int unref = 0;
180
181 sv_setpvn(t, "", 0);
182 retry:
183 if (!sv) {
184 sv_catpv(t, "VOID");
185 goto finish;
186 }
187 else if (sv == (SV*)0x55555555 || SvTYPE(sv) == 'U') {
188 sv_catpv(t, "WILD");
189 goto finish;
190 }
191 else if (sv == &PL_sv_undef || sv == &PL_sv_no || sv == &PL_sv_yes) {
192 if (sv == &PL_sv_undef) {
193 sv_catpv(t, "SV_UNDEF");
194 if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|
195 SVs_GMG|SVs_SMG|SVs_RMG)) &&
196 SvREADONLY(sv))
197 goto finish;
198 }
199 else if (sv == &PL_sv_no) {
200 sv_catpv(t, "SV_NO");
201 if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
202 SVs_GMG|SVs_SMG|SVs_RMG)) &&
203 !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
204 SVp_POK|SVp_NOK)) &&
205 SvCUR(sv) == 0 &&
206 SvNVX(sv) == 0.0)
207 goto finish;
208 }
209 else {
210 sv_catpv(t, "SV_YES");
211 if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
212 SVs_GMG|SVs_SMG|SVs_RMG)) &&
213 !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
214 SVp_POK|SVp_NOK)) &&
215 SvCUR(sv) == 1 &&
216 SvPVX(sv) && *SvPVX(sv) == '1' &&
217 SvNVX(sv) == 1.0)
218 goto finish;
219 }
220 sv_catpv(t, ":");
221 }
222 else if (SvREFCNT(sv) == 0) {
223 sv_catpv(t, "(");
224 unref++;
225 }
04932ac8 226 else if (DEBUG_R_TEST && SvREFCNT(sv) > 1) {
29b291f7 227 Perl_sv_catpvf(aTHX_ t, "<%"UVuf">", (UV)SvREFCNT(sv));
04932ac8
DM
228 }
229
230
3967c732
JD
231 if (SvROK(sv)) {
232 sv_catpv(t, "\\");
233 if (SvCUR(t) + unref > 10) {
234 SvCUR(t) = unref + 3;
235 *SvEND(t) = '\0';
236 sv_catpv(t, "...");
237 goto finish;
238 }
239 sv = (SV*)SvRV(sv);
240 goto retry;
241 }
242 switch (SvTYPE(sv)) {
243 default:
244 sv_catpv(t, "FREED");
245 goto finish;
246
247 case SVt_NULL:
248 sv_catpv(t, "UNDEF");
249 goto finish;
250 case SVt_IV:
251 sv_catpv(t, "IV");
252 break;
253 case SVt_NV:
254 sv_catpv(t, "NV");
255 break;
256 case SVt_RV:
257 sv_catpv(t, "RV");
258 break;
259 case SVt_PV:
260 sv_catpv(t, "PV");
261 break;
262 case SVt_PVIV:
263 sv_catpv(t, "PVIV");
264 break;
265 case SVt_PVNV:
266 sv_catpv(t, "PVNV");
267 break;
268 case SVt_PVMG:
269 sv_catpv(t, "PVMG");
270 break;
271 case SVt_PVLV:
272 sv_catpv(t, "PVLV");
273 break;
274 case SVt_PVAV:
275 sv_catpv(t, "AV");
276 break;
277 case SVt_PVHV:
278 sv_catpv(t, "HV");
279 break;
280 case SVt_PVCV:
281 if (CvGV(sv))
cea2e8a9 282 Perl_sv_catpvf(aTHX_ t, "CV(%s)", GvNAME(CvGV(sv)));
3967c732
JD
283 else
284 sv_catpv(t, "CV()");
285 goto finish;
286 case SVt_PVGV:
287 sv_catpv(t, "GV");
288 break;
289 case SVt_PVBM:
290 sv_catpv(t, "BM");
291 break;
292 case SVt_PVFM:
293 sv_catpv(t, "FM");
294 break;
295 case SVt_PVIO:
296 sv_catpv(t, "IO");
297 break;
298 }
299
300 if (SvPOKp(sv)) {
301 if (!SvPVX(sv))
302 sv_catpv(t, "(null)");
303 else {
79cb57f6 304 SV *tmp = newSVpvn("", 0);
3967c732
JD
305 sv_catpv(t, "(");
306 if (SvOOK(sv))
cea2e8a9
GS
307 Perl_sv_catpvf(aTHX_ t, "[%s]", pv_display(tmp, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, 127));
308 Perl_sv_catpvf(aTHX_ t, "%s)", pv_display(tmp, SvPVX(sv), SvCUR(sv), SvLEN(sv), 127));
32639b87 309 if (SvUTF8(sv))
b2ff9928
JH
310 Perl_sv_catpvf(aTHX_ t, " [UTF8 \"%s\"]",
311 sv_uni_display(tmp, sv, 8 * sv_len_utf8(sv), 0));
3967c732
JD
312 SvREFCNT_dec(tmp);
313 }
314 }
315 else if (SvNOKp(sv)) {
e54dc35b 316 STORE_NUMERIC_LOCAL_SET_STANDARD();
cea2e8a9 317 Perl_sv_catpvf(aTHX_ t, "(%g)",SvNVX(sv));
e54dc35b 318 RESTORE_NUMERIC_LOCAL();
3967c732 319 }
57def98f 320 else if (SvIOKp(sv)) {
cf2093f6 321 if (SvIsUV(sv))
57def98f 322 Perl_sv_catpvf(aTHX_ t, "(%"UVuf")", (UV)SvUVX(sv));
cf2093f6 323 else
57def98f 324 Perl_sv_catpvf(aTHX_ t, "(%"IVdf")", (IV)SvIVX(sv));
25da4f38 325 }
3967c732
JD
326 else
327 sv_catpv(t, "()");
2ef28da1 328
3967c732
JD
329 finish:
330 if (unref) {
331 while (unref--)
332 sv_catpv(t, ")");
333 }
2d8e6c8d 334 return SvPV(t, n_a);
3967c732
JD
335}
336
337void
864dbfa3 338Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm)
3967c732
JD
339{
340 char ch;
341
342 if (!pm) {
cea2e8a9 343 Perl_dump_indent(aTHX_ level, file, "{}\n");
3967c732
JD
344 return;
345 }
cea2e8a9 346 Perl_dump_indent(aTHX_ level, file, "{\n");
3967c732
JD
347 level++;
348 if (pm->op_pmflags & PMf_ONCE)
349 ch = '?';
350 else
351 ch = '/';
aaa362c4 352 if (PM_GETRE(pm))
cea2e8a9 353 Perl_dump_indent(aTHX_ level, file, "PMf_PRE %c%s%c%s\n",
aaa362c4 354 ch, PM_GETRE(pm)->precomp, ch,
3967c732
JD
355 (pm->op_private & OPpRUNTIME) ? " (RUNTIME)" : "");
356 else
cea2e8a9 357 Perl_dump_indent(aTHX_ level, file, "PMf_PRE (RUNTIME)\n");
3967c732 358 if (pm->op_type != OP_PUSHRE && pm->op_pmreplroot) {
cea2e8a9 359 Perl_dump_indent(aTHX_ level, file, "PMf_REPL = ");
3967c732
JD
360 op_dump(pm->op_pmreplroot);
361 }
aaa362c4 362 if (pm->op_pmflags || (PM_GETRE(pm) && PM_GETRE(pm)->check_substr)) {
79cb57f6 363 SV *tmpsv = newSVpvn("", 0);
3967c732
JD
364 if (pm->op_pmdynflags & PMdf_USED)
365 sv_catpv(tmpsv, ",USED");
366 if (pm->op_pmdynflags & PMdf_TAINTED)
367 sv_catpv(tmpsv, ",TAINTED");
368 if (pm->op_pmflags & PMf_ONCE)
369 sv_catpv(tmpsv, ",ONCE");
aaa362c4
RS
370 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
371 && !(PM_GETRE(pm)->reganch & ROPT_NOSCAN))
3967c732 372 sv_catpv(tmpsv, ",SCANFIRST");
aaa362c4
RS
373 if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr
374 && PM_GETRE(pm)->reganch & ROPT_CHECK_ALL)
3967c732
JD
375 sv_catpv(tmpsv, ",ALL");
376 if (pm->op_pmflags & PMf_SKIPWHITE)
377 sv_catpv(tmpsv, ",SKIPWHITE");
378 if (pm->op_pmflags & PMf_CONST)
379 sv_catpv(tmpsv, ",CONST");
380 if (pm->op_pmflags & PMf_KEEP)
381 sv_catpv(tmpsv, ",KEEP");
382 if (pm->op_pmflags & PMf_GLOBAL)
383 sv_catpv(tmpsv, ",GLOBAL");
384 if (pm->op_pmflags & PMf_CONTINUE)
385 sv_catpv(tmpsv, ",CONTINUE");
386 if (pm->op_pmflags & PMf_RETAINT)
387 sv_catpv(tmpsv, ",RETAINT");
388 if (pm->op_pmflags & PMf_EVAL)
389 sv_catpv(tmpsv, ",EVAL");
cea2e8a9 390 Perl_dump_indent(aTHX_ level, file, "PMFLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
3967c732
JD
391 SvREFCNT_dec(tmpsv);
392 }
393
cea2e8a9 394 Perl_dump_indent(aTHX_ level-1, file, "}\n");
3967c732
JD
395}
396
397void
864dbfa3 398Perl_pmop_dump(pTHX_ PMOP *pm)
3967c732
JD
399{
400 do_pmop_dump(0, Perl_debug_log, pm);
79072805
LW
401}
402
403void
864dbfa3 404Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, OP *o)
79072805 405{
cea2e8a9 406 Perl_dump_indent(aTHX_ level, file, "{\n");
3967c732 407 level++;
11343788 408 if (o->op_seq)
3967c732 409 PerlIO_printf(file, "%-4d", o->op_seq);
93a17b20 410 else
3967c732 411 PerlIO_printf(file, " ");
c8db6e60
JH
412 PerlIO_printf(file,
413 "%*sTYPE = %s ===> ",
53e06cf0 414 (int)(PL_dumpindent*level-4), "", OP_NAME(o));
11343788
MB
415 if (o->op_next) {
416 if (o->op_seq)
3967c732 417 PerlIO_printf(file, "%d\n", o->op_next->op_seq);
93a17b20 418 else
3967c732 419 PerlIO_printf(file, "(%d)\n", o->op_next->op_seq);
93a17b20 420 }
79072805 421 else
3967c732 422 PerlIO_printf(file, "DONE\n");
11343788 423 if (o->op_targ) {
acb36ea4 424 if (o->op_type == OP_NULL)
ae7d165c 425 {
cea2e8a9 426 Perl_dump_indent(aTHX_ level, file, " (was %s)\n", PL_op_name[o->op_targ]);
ae7d165c
PJ
427 if (o->op_targ == OP_NEXTSTATE)
428 {
429 if (CopLINE(cCOPo))
430 Perl_dump_indent(aTHX_ level, file, "LINE = %d\n",CopLINE(cCOPo));
431 if (CopSTASHPV(cCOPo))
432 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
433 CopSTASHPV(cCOPo));
434 if (cCOPo->cop_label)
435 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
436 cCOPo->cop_label);
437 }
438 }
8990e307 439 else
894356b3 440 Perl_dump_indent(aTHX_ level, file, "TARG = %ld\n", (long)o->op_targ);
8990e307 441 }
748a9306 442#ifdef DUMPADDR
57def98f 443 Perl_dump_indent(aTHX_ level, file, "ADDR = 0x%"UVxf" => 0x%"UVxf"\n", (UV)o, (UV)o->op_next);
79072805 444#endif
11343788 445 if (o->op_flags) {
79cb57f6 446 SV *tmpsv = newSVpvn("", 0);
5dc0d613 447 switch (o->op_flags & OPf_WANT) {
54310121 448 case OPf_WANT_VOID:
46fc3d4c 449 sv_catpv(tmpsv, ",VOID");
54310121
PP
450 break;
451 case OPf_WANT_SCALAR:
46fc3d4c 452 sv_catpv(tmpsv, ",SCALAR");
54310121
PP
453 break;
454 case OPf_WANT_LIST:
46fc3d4c 455 sv_catpv(tmpsv, ",LIST");
54310121
PP
456 break;
457 default:
46fc3d4c 458 sv_catpv(tmpsv, ",UNKNOWN");
54310121
PP
459 break;
460 }
11343788 461 if (o->op_flags & OPf_KIDS)
46fc3d4c 462 sv_catpv(tmpsv, ",KIDS");
11343788 463 if (o->op_flags & OPf_PARENS)
46fc3d4c 464 sv_catpv(tmpsv, ",PARENS");
11343788 465 if (o->op_flags & OPf_STACKED)
46fc3d4c 466 sv_catpv(tmpsv, ",STACKED");
11343788 467 if (o->op_flags & OPf_REF)
46fc3d4c 468 sv_catpv(tmpsv, ",REF");
11343788 469 if (o->op_flags & OPf_MOD)
46fc3d4c 470 sv_catpv(tmpsv, ",MOD");
11343788 471 if (o->op_flags & OPf_SPECIAL)
46fc3d4c 472 sv_catpv(tmpsv, ",SPECIAL");
cea2e8a9 473 Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
46fc3d4c 474 SvREFCNT_dec(tmpsv);
79072805 475 }
11343788 476 if (o->op_private) {
79cb57f6 477 SV *tmpsv = newSVpvn("", 0);
07447971
GS
478 if (PL_opargs[o->op_type] & OA_TARGLEX) {
479 if (o->op_private & OPpTARGET_MY)
480 sv_catpv(tmpsv, ",TARGET_MY");
481 }
bf91b999
SC
482 else if (o->op_type == OP_LEAVESUB ||
483 o->op_type == OP_LEAVE ||
484 o->op_type == OP_LEAVESUBLV ||
485 o->op_type == OP_LEAVEWRITE) {
486 if (o->op_private & OPpREFCOUNTED)
487 sv_catpv(tmpsv, ",REFCOUNTED");
488 }
489 else if (o->op_type == OP_AASSIGN) {
11343788 490 if (o->op_private & OPpASSIGN_COMMON)
46fc3d4c 491 sv_catpv(tmpsv, ",COMMON");
10c8fecd
GS
492 if (o->op_private & OPpASSIGN_HASH)
493 sv_catpv(tmpsv, ",HASH");
8d063cd8 494 }
11343788
MB
495 else if (o->op_type == OP_SASSIGN) {
496 if (o->op_private & OPpASSIGN_BACKWARDS)
46fc3d4c 497 sv_catpv(tmpsv, ",BACKWARDS");
a0d0e21e 498 }
11343788
MB
499 else if (o->op_type == OP_TRANS) {
500 if (o->op_private & OPpTRANS_SQUASH)
46fc3d4c 501 sv_catpv(tmpsv, ",SQUASH");
11343788 502 if (o->op_private & OPpTRANS_DELETE)
46fc3d4c 503 sv_catpv(tmpsv, ",DELETE");
11343788 504 if (o->op_private & OPpTRANS_COMPLEMENT)
46fc3d4c 505 sv_catpv(tmpsv, ",COMPLEMENT");
bf91b999
SC
506 if (o->op_private & OPpTRANS_IDENTICAL)
507 sv_catpv(tmpsv, ",IDENTICAL");
508 if (o->op_private & OPpTRANS_GROWS)
509 sv_catpv(tmpsv, ",GROWS");
8d063cd8 510 }
11343788
MB
511 else if (o->op_type == OP_REPEAT) {
512 if (o->op_private & OPpREPEAT_DOLIST)
46fc3d4c 513 sv_catpv(tmpsv, ",DOLIST");
8d063cd8 514 }
11343788
MB
515 else if (o->op_type == OP_ENTERSUB ||
516 o->op_type == OP_RV2SV ||
23f1ca44 517 o->op_type == OP_GVSV ||
11343788
MB
518 o->op_type == OP_RV2AV ||
519 o->op_type == OP_RV2HV ||
520 o->op_type == OP_RV2GV ||
521 o->op_type == OP_AELEM ||
522 o->op_type == OP_HELEM )
85e6fe83 523 {
5dc0d613
MB
524 if (o->op_type == OP_ENTERSUB) {
525 if (o->op_private & OPpENTERSUB_AMPER)
46fc3d4c 526 sv_catpv(tmpsv, ",AMPER");
5dc0d613 527 if (o->op_private & OPpENTERSUB_DB)
46fc3d4c 528 sv_catpv(tmpsv, ",DB");
d3011074
IZ
529 if (o->op_private & OPpENTERSUB_HASTARG)
530 sv_catpv(tmpsv, ",HASTARG");
bf91b999
SC
531 if (o->op_private & OPpENTERSUB_NOPAREN)
532 sv_catpv(tmpsv, ",NOPAREN");
533 if (o->op_private & OPpENTERSUB_INARGS)
534 sv_catpv(tmpsv, ",INARGS");
68dc0745 535 }
bf91b999 536 else {
d3011074 537 switch (o->op_private & OPpDEREF) {
5f05dabc 538 case OPpDEREF_SV:
46fc3d4c 539 sv_catpv(tmpsv, ",SV");
5f05dabc
PP
540 break;
541 case OPpDEREF_AV:
46fc3d4c 542 sv_catpv(tmpsv, ",AV");
5f05dabc
PP
543 break;
544 case OPpDEREF_HV:
46fc3d4c 545 sv_catpv(tmpsv, ",HV");
5f05dabc
PP
546 break;
547 }
bf91b999
SC
548 if (o->op_private & OPpMAYBE_LVSUB)
549 sv_catpv(tmpsv, ",MAYBE_LVSUB");
550 }
5dc0d613
MB
551 if (o->op_type == OP_AELEM || o->op_type == OP_HELEM) {
552 if (o->op_private & OPpLVAL_DEFER)
46fc3d4c 553 sv_catpv(tmpsv, ",LVAL_DEFER");
68dc0745
PP
554 }
555 else {
5dc0d613 556 if (o->op_private & HINT_STRICT_REFS)
46fc3d4c 557 sv_catpv(tmpsv, ",STRICT_REFS");
192587c2
GS
558 if (o->op_private & OPpOUR_INTRO)
559 sv_catpv(tmpsv, ",OUR_INTRO");
68dc0745 560 }
8d063cd8 561 }
11343788
MB
562 else if (o->op_type == OP_CONST) {
563 if (o->op_private & OPpCONST_BARE)
46fc3d4c 564 sv_catpv(tmpsv, ",BARE");
7a52d87a
GS
565 if (o->op_private & OPpCONST_STRICT)
566 sv_catpv(tmpsv, ",STRICT");
bf91b999
SC
567 if (o->op_private & OPpCONST_ARYBASE)
568 sv_catpv(tmpsv, ",ARYBASE");
569 if (o->op_private & OPpCONST_WARNING)
570 sv_catpv(tmpsv, ",WARNING");
571 if (o->op_private & OPpCONST_ENTERED)
572 sv_catpv(tmpsv, ",ENTERED");
79072805 573 }
11343788
MB
574 else if (o->op_type == OP_FLIP) {
575 if (o->op_private & OPpFLIP_LINENUM)
46fc3d4c 576 sv_catpv(tmpsv, ",LINENUM");
79072805 577 }
11343788
MB
578 else if (o->op_type == OP_FLOP) {
579 if (o->op_private & OPpFLIP_LINENUM)
46fc3d4c 580 sv_catpv(tmpsv, ",LINENUM");
cd06dffe
GS
581 } else if (o->op_type == OP_RV2CV) {
582 if (o->op_private & OPpLVAL_INTRO)
583 sv_catpv(tmpsv, ",INTRO");
79072805 584 }
bf91b999
SC
585 else if (o->op_type == OP_GV) {
586 if (o->op_private & OPpEARLY_CV)
587 sv_catpv(tmpsv, ",EARLY_CV");
588 }
589 else if (o->op_type == OP_LIST) {
590 if (o->op_private & OPpLIST_GUESSED)
591 sv_catpv(tmpsv, ",GUESSED");
592 }
593 else if (o->op_type == OP_DELETE) {
594 if (o->op_private & OPpSLICE)
595 sv_catpv(tmpsv, ",SLICE");
596 }
597 else if (o->op_type == OP_EXISTS) {
598 if (o->op_private & OPpEXISTS_SUB)
599 sv_catpv(tmpsv, ",EXISTS_SUB");
600 }
601 else if (o->op_type == OP_SORT) {
602 if (o->op_private & OPpSORT_NUMERIC)
603 sv_catpv(tmpsv, ",NUMERIC");
604 if (o->op_private & OPpSORT_INTEGER)
605 sv_catpv(tmpsv, ",INTEGER");
606 if (o->op_private & OPpSORT_REVERSE)
607 sv_catpv(tmpsv, ",REVERSE");
608 }
609 else if (o->op_type == OP_THREADSV) {
610 if (o->op_private & OPpDONE_SVREF)
611 sv_catpv(tmpsv, ",SVREF");
612 }
613 else if (o->op_type == OP_OPEN || o->op_type == OP_BACKTICK) {
614 if (o->op_private & OPpOPEN_IN_RAW)
615 sv_catpv(tmpsv, ",IN_RAW");
616 if (o->op_private & OPpOPEN_IN_CRLF)
617 sv_catpv(tmpsv, ",IN_CRLF");
618 if (o->op_private & OPpOPEN_OUT_RAW)
619 sv_catpv(tmpsv, ",OUT_RAW");
620 if (o->op_private & OPpOPEN_OUT_CRLF)
621 sv_catpv(tmpsv, ",OUT_CRLF");
622 }
623 else if (o->op_type == OP_EXIT) {
624 if (o->op_private & OPpEXIT_VMSISH)
96e176bf
CL
625 sv_catpv(tmpsv, ",EXIT_VMSISH");
626 if (o->op_private & OPpHUSH_VMSISH)
627 sv_catpv(tmpsv, ",HUSH_VMSISH");
628 }
629 else if (o->op_type == OP_DIE) {
630 if (o->op_private & OPpHUSH_VMSISH)
631 sv_catpv(tmpsv, ",HUSH_VMSISH");
bf91b999 632 }
11343788 633 if (o->op_flags & OPf_MOD && o->op_private & OPpLVAL_INTRO)
46fc3d4c
PP
634 sv_catpv(tmpsv, ",INTRO");
635 if (SvCUR(tmpsv))
cea2e8a9 636 Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX(tmpsv) + 1);
46fc3d4c 637 SvREFCNT_dec(tmpsv);
8d063cd8 638 }
8d063cd8 639
11343788 640 switch (o->op_type) {
971a9dd3 641 case OP_AELEMFAST:
93a17b20 642 case OP_GVSV:
79072805 643 case OP_GV:
971a9dd3
GS
644#ifdef USE_ITHREADS
645 Perl_dump_indent(aTHX_ level, file, "PADIX = %d\n", cPADOPo->op_padix);
646#else
647 if (cSVOPo->op_sv) {
46fc3d4c 648 SV *tmpsv = NEWSV(0,0);
155aba94 649 STRLEN n_a;
8990e307 650 ENTER;
8990e307 651 SAVEFREESV(tmpsv);
971a9dd3 652 gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, Nullch);
cea2e8a9 653 Perl_dump_indent(aTHX_ level, file, "GV = %s\n", SvPV(tmpsv, n_a));
8990e307 654 LEAVE;
378cc40b 655 }
79072805 656 else
cea2e8a9 657 Perl_dump_indent(aTHX_ level, file, "GV = NULL\n");
971a9dd3 658#endif
79072805
LW
659 break;
660 case OP_CONST:
f5d5a27c 661 case OP_METHOD_NAMED:
cea2e8a9 662 Perl_dump_indent(aTHX_ level, file, "SV = %s\n", SvPEEK(cSVOPo->op_sv));
79072805 663 break;
7399586d 664 case OP_SETSTATE:
93a17b20
LW
665 case OP_NEXTSTATE:
666 case OP_DBSTATE:
57843af0
GS
667 if (CopLINE(cCOPo))
668 Perl_dump_indent(aTHX_ level, file, "LINE = %d\n",CopLINE(cCOPo));
ed094faf
GS
669 if (CopSTASHPV(cCOPo))
670 Perl_dump_indent(aTHX_ level, file, "PACKAGE = \"%s\"\n",
671 CopSTASHPV(cCOPo));
11343788 672 if (cCOPo->cop_label)
ed094faf
GS
673 Perl_dump_indent(aTHX_ level, file, "LABEL = \"%s\"\n",
674 cCOPo->cop_label);
79072805
LW
675 break;
676 case OP_ENTERLOOP:
cea2e8a9 677 Perl_dump_indent(aTHX_ level, file, "REDO ===> ");
11343788 678 if (cLOOPo->op_redoop)
3967c732 679 PerlIO_printf(file, "%d\n", cLOOPo->op_redoop->op_seq);
79072805 680 else
3967c732 681 PerlIO_printf(file, "DONE\n");
cea2e8a9 682 Perl_dump_indent(aTHX_ level, file, "NEXT ===> ");
11343788 683 if (cLOOPo->op_nextop)
3967c732 684 PerlIO_printf(file, "%d\n", cLOOPo->op_nextop->op_seq);
79072805 685 else
3967c732 686 PerlIO_printf(file, "DONE\n");
cea2e8a9 687 Perl_dump_indent(aTHX_ level, file, "LAST ===> ");
11343788 688 if (cLOOPo->op_lastop)
3967c732 689 PerlIO_printf(file, "%d\n", cLOOPo->op_lastop->op_seq);
79072805 690 else
3967c732 691 PerlIO_printf(file, "DONE\n");
79072805
LW
692 break;
693 case OP_COND_EXPR:
1a67a97c 694 case OP_RANGE:
a0d0e21e 695 case OP_MAPWHILE:
79072805
LW
696 case OP_GREPWHILE:
697 case OP_OR:
698 case OP_AND:
cea2e8a9 699 Perl_dump_indent(aTHX_ level, file, "OTHER ===> ");
11343788 700 if (cLOGOPo->op_other)
3967c732 701 PerlIO_printf(file, "%d\n", cLOGOPo->op_other->op_seq);
79072805 702 else
3967c732 703 PerlIO_printf(file, "DONE\n");
79072805
LW
704 break;
705 case OP_PUSHRE:
706 case OP_MATCH:
8782bef2 707 case OP_QR:
79072805 708 case OP_SUBST:
3967c732 709 do_pmop_dump(level, file, cPMOPo);
79072805 710 break;
7934575e
GS
711 case OP_LEAVE:
712 case OP_LEAVEEVAL:
713 case OP_LEAVESUB:
714 case OP_LEAVESUBLV:
715 case OP_LEAVEWRITE:
716 case OP_SCOPE:
717 if (o->op_private & OPpREFCOUNTED)
718 Perl_dump_indent(aTHX_ level, file, "REFCNT = %"UVuf"\n", (UV)o->op_targ);
719 break;
a0d0e21e
LW
720 default:
721 break;
79072805 722 }
11343788 723 if (o->op_flags & OPf_KIDS) {
79072805 724 OP *kid;
11343788 725 for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling)
3967c732 726 do_op_dump(level, file, kid);
8d063cd8 727 }
cea2e8a9 728 Perl_dump_indent(aTHX_ level-1, file, "}\n");
3967c732
JD
729}
730
731void
864dbfa3 732Perl_op_dump(pTHX_ OP *o)
3967c732
JD
733{
734 do_op_dump(0, Perl_debug_log, o);
8d063cd8
LW
735}
736
8adcabd8 737void
864dbfa3 738Perl_gv_dump(pTHX_ GV *gv)
378cc40b 739{
79072805 740 SV *sv;
378cc40b 741
79072805 742 if (!gv) {
760ac839 743 PerlIO_printf(Perl_debug_log, "{}\n");
378cc40b
LW
744 return;
745 }
8990e307 746 sv = sv_newmortal();
760ac839 747 PerlIO_printf(Perl_debug_log, "{\n");
f6aff53a 748 gv_fullname3(sv, gv, Nullch);
cea2e8a9 749 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "GV_NAME = %s", SvPVX(sv));
79072805 750 if (gv != GvEGV(gv)) {
f6aff53a 751 gv_efullname3(sv, GvEGV(gv), Nullch);
cea2e8a9 752 Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", SvPVX(sv));
8adcabd8 753 }
3967c732 754 PerlIO_putc(Perl_debug_log, '\n');
cea2e8a9 755 Perl_dump_indent(aTHX_ 0, Perl_debug_log, "}\n");
8d063cd8
LW
756}
757
14befaf4
DM
758
759/* map magic types to the symbolic name
760 * (with the PERL_MAGIC_ prefixed stripped)
761 */
762
763static struct { char type; char *name; } magic_names[] = {
516a5887
JH
764 { PERL_MAGIC_sv, "sv(\\0)" },
765 { PERL_MAGIC_arylen, "arylen(#)" },
766 { PERL_MAGIC_glob, "glob(*)" },
767 { PERL_MAGIC_pos, "pos(.)" },
768 { PERL_MAGIC_backref, "backref(<)" },
769 { PERL_MAGIC_overload, "overload(A)" },
770 { PERL_MAGIC_bm, "bm(B)" },
771 { PERL_MAGIC_regdata, "regdata(D)" },
772 { PERL_MAGIC_env, "env(E)" },
773 { PERL_MAGIC_isa, "isa(I)" },
774 { PERL_MAGIC_dbfile, "dbfile(L)" },
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_collxfrm, "collxfrm(o)" },
789 { PERL_MAGIC_tiedelem, "tiedelem(p)" },
790 { PERL_MAGIC_tiedscalar, "tiedscalar(q)" },
791 { PERL_MAGIC_qr, "qr(r)" },
792 { PERL_MAGIC_sigelem, "sigelem(s)" },
793 { PERL_MAGIC_taint, "taint(t)" },
794 { PERL_MAGIC_vec, "vec(v)" },
795 { PERL_MAGIC_substr, "substr(x)" },
796 { PERL_MAGIC_defelem, "defelem(y)" },
797 { PERL_MAGIC_ext, "ext(~)" },
798 /* this null string terminates the list */
799 { 0, 0 },
14befaf4
DM
800};
801
8adcabd8 802void
864dbfa3 803Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
8d063cd8 804{
3967c732 805 for (; mg; mg = mg->mg_moremagic) {
b900a521
JH
806 Perl_dump_indent(aTHX_ level, file,
807 " MAGIC = 0x%"UVxf"\n", PTR2UV(mg));
3967c732
JD
808 if (mg->mg_virtual) {
809 MGVTBL *v = mg->mg_virtual;
810 char *s = 0;
811 if (v == &PL_vtbl_sv) s = "sv";
812 else if (v == &PL_vtbl_env) s = "env";
813 else if (v == &PL_vtbl_envelem) s = "envelem";
814 else if (v == &PL_vtbl_sig) s = "sig";
815 else if (v == &PL_vtbl_sigelem) s = "sigelem";
816 else if (v == &PL_vtbl_pack) s = "pack";
817 else if (v == &PL_vtbl_packelem) s = "packelem";
818 else if (v == &PL_vtbl_dbline) s = "dbline";
819 else if (v == &PL_vtbl_isa) s = "isa";
820 else if (v == &PL_vtbl_arylen) s = "arylen";
821 else if (v == &PL_vtbl_glob) s = "glob";
822 else if (v == &PL_vtbl_mglob) s = "mglob";
823 else if (v == &PL_vtbl_nkeys) s = "nkeys";
824 else if (v == &PL_vtbl_taint) s = "taint";
825 else if (v == &PL_vtbl_substr) s = "substr";
826 else if (v == &PL_vtbl_vec) s = "vec";
827 else if (v == &PL_vtbl_pos) s = "pos";
828 else if (v == &PL_vtbl_bm) s = "bm";
829 else if (v == &PL_vtbl_fm) s = "fm";
830 else if (v == &PL_vtbl_uvar) s = "uvar";
831 else if (v == &PL_vtbl_defelem) s = "defelem";
832#ifdef USE_LOCALE_COLLATE
833 else if (v == &PL_vtbl_collxfrm) s = "collxfrm";
834#endif
3967c732
JD
835 else if (v == &PL_vtbl_amagic) s = "amagic";
836 else if (v == &PL_vtbl_amagicelem) s = "amagicelem";
810b8aa5 837 else if (v == &PL_vtbl_backref) s = "backref";
3967c732 838 if (s)
cea2e8a9 839 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = &PL_vtbl_%s\n", s);
3967c732 840 else
b900a521 841 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0x%"UVxf"\n", PTR2UV(v));
3967c732
JD
842 }
843 else
cea2e8a9 844 Perl_dump_indent(aTHX_ level, file, " MG_VIRTUAL = 0\n");
8d063cd8 845
3967c732 846 if (mg->mg_private)
cea2e8a9 847 Perl_dump_indent(aTHX_ level, file, " MG_PRIVATE = %d\n", mg->mg_private);
3967c732 848
14befaf4
DM
849 {
850 int n;
851 char *name = 0;
852 for (n=0; magic_names[n].name; n++) {
853 if (mg->mg_type == magic_names[n].type) {
854 name = magic_names[n].name;
855 break;
856 }
857 }
858 if (name)
859 Perl_dump_indent(aTHX_ level, file,
860 " MG_TYPE = PERL_MAGIC_%s\n", name);
861 else
862 Perl_dump_indent(aTHX_ level, file,
863 " MG_TYPE = UNKNOWN(\\%o)\n", mg->mg_type);
864 }
3967c732
JD
865
866 if (mg->mg_flags) {
cea2e8a9 867 Perl_dump_indent(aTHX_ level, file, " MG_FLAGS = 0x%02X\n", mg->mg_flags);
3967c732 868 if (mg->mg_flags & MGf_TAINTEDDIR)
cea2e8a9 869 Perl_dump_indent(aTHX_ level, file, " TAINTEDDIR\n");
3967c732 870 if (mg->mg_flags & MGf_REFCOUNTED)
cea2e8a9 871 Perl_dump_indent(aTHX_ level, file, " REFCOUNTED\n");
3967c732 872 if (mg->mg_flags & MGf_GSKIP)
cea2e8a9 873 Perl_dump_indent(aTHX_ level, file, " GSKIP\n");
3967c732 874 if (mg->mg_flags & MGf_MINMATCH)
cea2e8a9 875 Perl_dump_indent(aTHX_ level, file, " MINMATCH\n");
3967c732
JD
876 }
877 if (mg->mg_obj) {
b900a521 878 Perl_dump_indent(aTHX_ level, file, " MG_OBJ = 0x%"UVxf"\n", PTR2UV(mg->mg_obj));
3967c732
JD
879 if (mg->mg_flags & MGf_REFCOUNTED)
880 do_sv_dump(level+2, file, mg->mg_obj, nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
881 }
882 if (mg->mg_len)
894356b3 883 Perl_dump_indent(aTHX_ level, file, " MG_LEN = %ld\n", (long)mg->mg_len);
3967c732 884 if (mg->mg_ptr) {
b900a521 885 Perl_dump_indent(aTHX_ level, file, " MG_PTR = 0x%"UVxf, PTR2UV(mg->mg_ptr));
3967c732 886 if (mg->mg_len >= 0) {
79cb57f6 887 SV *sv = newSVpvn("", 0);
3967c732
JD
888 PerlIO_printf(file, " %s", pv_display(sv, mg->mg_ptr, mg->mg_len, 0, pvlim));
889 SvREFCNT_dec(sv);
890 }
891 else if (mg->mg_len == HEf_SVKEY) {
892 PerlIO_puts(file, " => HEf_SVKEY\n");
893 do_sv_dump(level+2, file, (SV*)((mg)->mg_ptr), nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */
894 continue;
895 }
896 else
897 PerlIO_puts(file, " ???? - please notify IZ");
898 PerlIO_putc(file, '\n');
899 }
378cc40b 900 }
3967c732
JD
901}
902
903void
864dbfa3 904Perl_magic_dump(pTHX_ MAGIC *mg)
3967c732
JD
905{
906 do_magic_dump(0, Perl_debug_log, mg, 0, 0, 0, 0);
907}
908
909void
864dbfa3 910Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, char *name, HV *sv)
3967c732 911{
b900a521 912 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
3967c732
JD
913 if (sv && HvNAME(sv))
914 PerlIO_printf(file, "\t\"%s\"\n", HvNAME(sv));
79072805 915 else
3967c732
JD
916 PerlIO_putc(file, '\n');
917}
918
919void
864dbfa3 920Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
3967c732 921{
b900a521 922 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
3967c732
JD
923 if (sv && GvNAME(sv))
924 PerlIO_printf(file, "\t\"%s\"\n", GvNAME(sv));
c90c0ff4 925 else
3967c732
JD
926 PerlIO_putc(file, '\n');
927}
928
929void
864dbfa3 930Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv)
3967c732 931{
b900a521 932 Perl_dump_indent(aTHX_ level, file, "%s = 0x%"UVxf, name, PTR2UV(sv));
3967c732
JD
933 if (sv && GvNAME(sv)) {
934 PerlIO_printf(file, "\t\"");
6676db26 935 if (GvSTASH(sv))
3967c732
JD
936 PerlIO_printf(file, "%s\" :: \"", HvNAME(GvSTASH(sv)));
937 PerlIO_printf(file, "%s\"\n", GvNAME(sv));
8d063cd8 938 }
3967c732
JD
939 else
940 PerlIO_putc(file, '\n');
941}
942
943void
864dbfa3 944Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim)
3967c732 945{
cea89e20 946 SV *d;
3967c732
JD
947 char *s;
948 U32 flags;
949 U32 type;
2d8e6c8d 950 STRLEN n_a;
3967c732
JD
951
952 if (!sv) {
cea2e8a9 953 Perl_dump_indent(aTHX_ level, file, "SV = 0\n");
3967c732 954 return;
378cc40b 955 }
2ef28da1 956
3967c732
JD
957 flags = SvFLAGS(sv);
958 type = SvTYPE(sv);
79072805 959
cea89e20 960 d = Perl_newSVpvf(aTHX_
57def98f 961 "(0x%"UVxf") at 0x%"UVxf"\n%*s REFCNT = %"IVdf"\n%*s FLAGS = (",
56431972 962 PTR2UV(SvANY(sv)), PTR2UV(sv),
894356b3
GS
963 (int)(PL_dumpindent*level), "", (IV)SvREFCNT(sv),
964 (int)(PL_dumpindent*level), "");
8d063cd8 965
3967c732
JD
966 if (flags & SVs_PADBUSY) sv_catpv(d, "PADBUSY,");
967 if (flags & SVs_PADTMP) sv_catpv(d, "PADTMP,");
968 if (flags & SVs_PADMY) sv_catpv(d, "PADMY,");
969 if (flags & SVs_TEMP) sv_catpv(d, "TEMP,");
970 if (flags & SVs_OBJECT) sv_catpv(d, "OBJECT,");
971 if (flags & SVs_GMG) sv_catpv(d, "GMG,");
972 if (flags & SVs_SMG) sv_catpv(d, "SMG,");
973 if (flags & SVs_RMG) sv_catpv(d, "RMG,");
4db58590 974
3967c732
JD
975 if (flags & SVf_IOK) sv_catpv(d, "IOK,");
976 if (flags & SVf_NOK) sv_catpv(d, "NOK,");
977 if (flags & SVf_POK) sv_catpv(d, "POK,");
810b8aa5
GS
978 if (flags & SVf_ROK) {
979 sv_catpv(d, "ROK,");
980 if (SvWEAKREF(sv)) sv_catpv(d, "WEAKREF,");
981 }
3967c732
JD
982 if (flags & SVf_OOK) sv_catpv(d, "OOK,");
983 if (flags & SVf_FAKE) sv_catpv(d, "FAKE,");
984 if (flags & SVf_READONLY) sv_catpv(d, "READONLY,");
4db58590 985
3967c732 986 if (flags & SVf_AMAGIC) sv_catpv(d, "OVERLOAD,");
3967c732
JD
987 if (flags & SVp_IOK) sv_catpv(d, "pIOK,");
988 if (flags & SVp_NOK) sv_catpv(d, "pNOK,");
989 if (flags & SVp_POK) sv_catpv(d, "pPOK,");
990 if (flags & SVp_SCREAM) sv_catpv(d, "SCREAM,");
991
992 switch (type) {
993 case SVt_PVCV:
994 case SVt_PVFM:
995 if (CvANON(sv)) sv_catpv(d, "ANON,");
996 if (CvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
997 if (CvCLONE(sv)) sv_catpv(d, "CLONE,");
998 if (CvCLONED(sv)) sv_catpv(d, "CLONED,");
de3f1649 999 if (CvCONST(sv)) sv_catpv(d, "CONST,");
3967c732 1000 if (CvNODEBUG(sv)) sv_catpv(d, "NODEBUG,");
25da4f38 1001 if (SvCOMPILED(sv)) sv_catpv(d, "COMPILED,");
18f7acf9
TJ
1002 if (CvLVALUE(sv)) sv_catpv(d, "LVALUE,");
1003 if (CvMETHOD(sv)) sv_catpv(d, "METHOD,");
3967c732
JD
1004 break;
1005 case SVt_PVHV:
1006 if (HvSHAREKEYS(sv)) sv_catpv(d, "SHAREKEYS,");
1007 if (HvLAZYDEL(sv)) sv_catpv(d, "LAZYDEL,");
1008 break;
1009 case SVt_PVGV:
1010 if (GvINTRO(sv)) sv_catpv(d, "INTRO,");
1011 if (GvMULTI(sv)) sv_catpv(d, "MULTI,");
7fb37951 1012 if (GvUNIQUE(sv)) sv_catpv(d, "UNIQUE,");
3967c732 1013 if (GvASSUMECV(sv)) sv_catpv(d, "ASSUMECV,");
12c18039 1014 if (GvIN_PAD(sv)) sv_catpv(d, "IN_PAD,");
addd1794 1015 if (flags & SVpad_OUR) sv_catpv(d, "OUR,");
3967c732
JD
1016 if (GvIMPORTED(sv)) {
1017 sv_catpv(d, "IMPORT");
1018 if (GvIMPORTED(sv) == GVf_IMPORTED)
1019 sv_catpv(d, "ALL,");
1020 else {
1021 sv_catpv(d, "(");
1022 if (GvIMPORTED_SV(sv)) sv_catpv(d, " SV");
1023 if (GvIMPORTED_AV(sv)) sv_catpv(d, " AV");
1024 if (GvIMPORTED_HV(sv)) sv_catpv(d, " HV");
1025 if (GvIMPORTED_CV(sv)) sv_catpv(d, " CV");
1026 sv_catpv(d, " ),");
1027 }
1028 }
addd1794 1029 /* FALL THROUGH */
25da4f38
IZ
1030 default:
1031 if (SvEVALED(sv)) sv_catpv(d, "EVALED,");
1032 if (SvIsUV(sv)) sv_catpv(d, "IsUV,");
1033 break;
3967c732
JD
1034 case SVt_PVBM:
1035 if (SvTAIL(sv)) sv_catpv(d, "TAIL,");
25da4f38 1036 if (SvVALID(sv)) sv_catpv(d, "VALID,");
3967c732 1037 break;
addd1794
AMS
1038 case SVt_PVMG:
1039 if (flags & SVpad_TYPED)
1040 sv_catpv(d, "TYPED,");
1041 break;
3967c732 1042 }
8b1981a6 1043 if (SvPOK(sv) && SvUTF8(sv))
9fe74ede 1044 sv_catpv(d, "UTF8");
3967c732
JD
1045
1046 if (*(SvEND(d) - 1) == ',')
1047 SvPVX(d)[--SvCUR(d)] = '\0';
1048 sv_catpv(d, ")");
1049 s = SvPVX(d);
1050
cea2e8a9 1051 Perl_dump_indent(aTHX_ level, file, "SV = ");
3967c732
JD
1052 switch (type) {
1053 case SVt_NULL:
1054 PerlIO_printf(file, "NULL%s\n", s);
cea89e20 1055 SvREFCNT_dec(d);
3967c732
JD
1056 return;
1057 case SVt_IV:
1058 PerlIO_printf(file, "IV%s\n", s);
1059 break;
1060 case SVt_NV:
1061 PerlIO_printf(file, "NV%s\n", s);
1062 break;
1063 case SVt_RV:
1064 PerlIO_printf(file, "RV%s\n", s);
1065 break;
1066 case SVt_PV:
1067 PerlIO_printf(file, "PV%s\n", s);
1068 break;
1069 case SVt_PVIV:
1070 PerlIO_printf(file, "PVIV%s\n", s);
1071 break;
1072 case SVt_PVNV:
1073 PerlIO_printf(file, "PVNV%s\n", s);
1074 break;
1075 case SVt_PVBM:
1076 PerlIO_printf(file, "PVBM%s\n", s);
1077 break;
1078 case SVt_PVMG:
1079 PerlIO_printf(file, "PVMG%s\n", s);
1080 break;
1081 case SVt_PVLV:
1082 PerlIO_printf(file, "PVLV%s\n", s);
1083 break;
1084 case SVt_PVAV:
1085 PerlIO_printf(file, "PVAV%s\n", s);
1086 break;
1087 case SVt_PVHV:
1088 PerlIO_printf(file, "PVHV%s\n", s);
1089 break;
1090 case SVt_PVCV:
1091 PerlIO_printf(file, "PVCV%s\n", s);
1092 break;
1093 case SVt_PVGV:
1094 PerlIO_printf(file, "PVGV%s\n", s);
1095 break;
1096 case SVt_PVFM:
1097 PerlIO_printf(file, "PVFM%s\n", s);
1098 break;
1099 case SVt_PVIO:
1100 PerlIO_printf(file, "PVIO%s\n", s);
1101 break;
1102 default:
faccc32b 1103 PerlIO_printf(file, "UNKNOWN(0x%"UVxf") %s\n", (UV)type, s);
cea89e20 1104 SvREFCNT_dec(d);
3967c732
JD
1105 return;
1106 }
1107 if (type >= SVt_PVIV || type == SVt_IV) {
cf2093f6 1108 if (SvIsUV(sv))
57def98f 1109 Perl_dump_indent(aTHX_ level, file, " UV = %"UVuf, (UV)SvUVX(sv));
cf2093f6 1110 else
57def98f 1111 Perl_dump_indent(aTHX_ level, file, " IV = %"IVdf, (IV)SvIVX(sv));
3967c732
JD
1112 if (SvOOK(sv))
1113 PerlIO_printf(file, " (OFFSET)");
1114 PerlIO_putc(file, '\n');
1115 }
1116 if (type >= SVt_PVNV || type == SVt_NV) {
e54dc35b 1117 STORE_NUMERIC_LOCAL_SET_STANDARD();
57def98f 1118 /* %Vg doesn't work? --jhi */
cf2093f6 1119#ifdef USE_LONG_DOUBLE
2d4389e4 1120 Perl_dump_indent(aTHX_ level, file, " NV = %.*" PERL_PRIgldbl "\n", LDBL_DIG, SvNVX(sv));
cf2093f6 1121#else
cea2e8a9 1122 Perl_dump_indent(aTHX_ level, file, " NV = %.*g\n", DBL_DIG, SvNVX(sv));
cf2093f6 1123#endif
e54dc35b 1124 RESTORE_NUMERIC_LOCAL();
3967c732
JD
1125 }
1126 if (SvROK(sv)) {
57def98f 1127 Perl_dump_indent(aTHX_ level, file, " RV = 0x%"UVxf"\n", PTR2UV(SvRV(sv)));
3967c732
JD
1128 if (nest < maxnest)
1129 do_sv_dump(level+1, file, SvRV(sv), nest+1, maxnest, dumpops, pvlim);
cea89e20 1130 SvREFCNT_dec(d);
3967c732
JD
1131 return;
1132 }
cea89e20
JH
1133 if (type < SVt_PV) {
1134 SvREFCNT_dec(d);
3967c732 1135 return;
cea89e20 1136 }
3967c732
JD
1137 if (type <= SVt_PVLV) {
1138 if (SvPVX(sv)) {
57def98f 1139 Perl_dump_indent(aTHX_ level, file," PV = 0x%"UVxf" ", PTR2UV(SvPVX(sv)));
3967c732
JD
1140 if (SvOOK(sv))
1141 PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim));
e6abe6d8
JH
1142 PerlIO_printf(file, "%s", pv_display(d, SvPVX(sv), SvCUR(sv), SvLEN(sv), pvlim));
1143 if (SvUTF8(sv)) /* the 8? \x{....} */
b2ff9928 1144 PerlIO_printf(file, " [UTF8 \"%s\"]", sv_uni_display(d, sv, 8 * sv_len_utf8(sv), 0));
e6abe6d8 1145 PerlIO_printf(file, "\n");
57def98f
JH
1146 Perl_dump_indent(aTHX_ level, file, " CUR = %"IVdf"\n", (IV)SvCUR(sv));
1147 Perl_dump_indent(aTHX_ level, file, " LEN = %"IVdf"\n", (IV)SvLEN(sv));
3967c732
JD
1148 }
1149 else
cea2e8a9 1150 Perl_dump_indent(aTHX_ level, file, " PV = 0\n");
3967c732
JD
1151 }
1152 if (type >= SVt_PVMG) {
1153 if (SvMAGIC(sv))
1154 do_magic_dump(level, file, SvMAGIC(sv), nest, maxnest, dumpops, pvlim);
1155 if (SvSTASH(sv))
1156 do_hv_dump(level, file, " STASH", SvSTASH(sv));
1157 }
1158 switch (type) {
1159 case SVt_PVLV:
cea2e8a9 1160 Perl_dump_indent(aTHX_ level, file, " TYPE = %c\n", LvTYPE(sv));
57def98f
JH
1161 Perl_dump_indent(aTHX_ level, file, " TARGOFF = %"IVdf"\n", (IV)LvTARGOFF(sv));
1162 Perl_dump_indent(aTHX_ level, file, " TARGLEN = %"IVdf"\n", (IV)LvTARGLEN(sv));
1163 Perl_dump_indent(aTHX_ level, file, " TARG = 0x%"UVxf"\n", PTR2UV(LvTARG(sv)));
3967c732
JD
1164 /* XXX level+1 ??? */
1165 do_sv_dump(level, file, LvTARG(sv), nest+1, maxnest, dumpops, pvlim);
1166 break;
1167 case SVt_PVAV:
57def98f 1168 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(AvARRAY(sv)));
3967c732 1169 if (AvARRAY(sv) != AvALLOC(sv)) {
57def98f
JH
1170 PerlIO_printf(file, " (offset=%"IVdf")\n", (IV)(AvARRAY(sv) - AvALLOC(sv)));
1171 Perl_dump_indent(aTHX_ level, file, " ALLOC = 0x%"UVxf"\n", PTR2UV(AvALLOC(sv)));
3967c732
JD
1172 }
1173 else
1174 PerlIO_putc(file, '\n');
57def98f
JH
1175 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)AvFILLp(sv));
1176 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)AvMAX(sv));
1177 Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%"UVxf"\n", PTR2UV(AvARYLEN(sv)));
3967c732
JD
1178 flags = AvFLAGS(sv);
1179 sv_setpv(d, "");
1180 if (flags & AVf_REAL) sv_catpv(d, ",REAL");
1181 if (flags & AVf_REIFY) sv_catpv(d, ",REIFY");
1182 if (flags & AVf_REUSED) sv_catpv(d, ",REUSED");
cea2e8a9 1183 Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n", SvCUR(d) ? SvPVX(d) + 1 : "");
3967c732
JD
1184 if (nest < maxnest && av_len((AV*)sv) >= 0) {
1185 int count;
1186 for (count = 0; count <= av_len((AV*)sv) && count < maxnest; count++) {
1187 SV** elt = av_fetch((AV*)sv,count,0);
1188
57def98f 1189 Perl_dump_indent(aTHX_ level + 1, file, "Elt No. %"IVdf"\n", (IV)count);
2ef28da1 1190 if (elt)
3967c732
JD
1191 do_sv_dump(level+1, file, *elt, nest+1, maxnest, dumpops, pvlim);
1192 }
1193 }
1194 break;
1195 case SVt_PVHV:
57def98f 1196 Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(HvARRAY(sv)));
3967c732
JD
1197 if (HvARRAY(sv) && HvKEYS(sv)) {
1198 /* Show distribution of HEs in the ARRAY */
1199 int freq[200];
1200#define FREQ_MAX (sizeof freq / sizeof freq[0] - 1)
1201 int i;
1202 int max = 0;
1203 U32 pow2 = 2, keys = HvKEYS(sv);
65202027 1204 NV theoret, sum = 0;
3967c732
JD
1205
1206 PerlIO_printf(file, " (");
1207 Zero(freq, FREQ_MAX + 1, int);
1208 for (i = 0; i <= HvMAX(sv); i++) {
1209 HE* h; int count = 0;
1210 for (h = HvARRAY(sv)[i]; h; h = HeNEXT(h))
1211 count++;
1212 if (count > FREQ_MAX)
1213 count = FREQ_MAX;
1214 freq[count]++;
1215 if (max < count)
1216 max = count;
1217 }
1218 for (i = 0; i <= max; i++) {
1219 if (freq[i]) {
1220 PerlIO_printf(file, "%d%s:%d", i,
1221 (i == FREQ_MAX) ? "+" : "",
1222 freq[i]);
1223 if (i != max)
1224 PerlIO_printf(file, ", ");
1225 }
1226 }
1227 PerlIO_putc(file, ')');
b8fa94d8
MG
1228 /* The "quality" of a hash is defined as the total number of
1229 comparisons needed to access every element once, relative
1230 to the expected number needed for a random hash.
1231
1232 The total number of comparisons is equal to the sum of
e76cd0fa
AMS
1233 the squares of the number of entries in each bucket.
1234 For a random hash of n keys into k buckets, the expected
b8fa94d8
MG
1235 value is
1236 n + n(n-1)/2k
1237 */
1238
3967c732
JD
1239 for (i = max; i > 0; i--) { /* Precision: count down. */
1240 sum += freq[i] * i * i;
1241 }
155aba94 1242 while ((keys = keys >> 1))
3967c732 1243 pow2 = pow2 << 1;
3967c732 1244 theoret = HvKEYS(sv);
b8fa94d8 1245 theoret += theoret * (theoret-1)/pow2;
3967c732 1246 PerlIO_putc(file, '\n');
6b4667fc 1247 Perl_dump_indent(aTHX_ level, file, " hash quality = %.1"NVff"%%", theoret/sum*100);
3967c732
JD
1248 }
1249 PerlIO_putc(file, '\n');
57def98f
JH
1250 Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)HvKEYS(sv));
1251 Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)HvFILL(sv));
1252 Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)HvMAX(sv));
1253 Perl_dump_indent(aTHX_ level, file, " RITER = %"IVdf"\n", (IV)HvRITER(sv));
1254 Perl_dump_indent(aTHX_ level, file, " EITER = 0x%"UVxf"\n", PTR2UV(HvEITER(sv)));
3967c732 1255 if (HvPMROOT(sv))
57def98f 1256 Perl_dump_indent(aTHX_ level, file, " PMROOT = 0x%"UVxf"\n", PTR2UV(HvPMROOT(sv)));
3967c732 1257 if (HvNAME(sv))
cea2e8a9 1258 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", HvNAME(sv));
3967c732
JD
1259 if (nest < maxnest && !HvEITER(sv)) { /* Try to preserve iterator */
1260 HE *he;
1261 HV *hv = (HV*)sv;
1262 int count = maxnest - nest;
1263
1264 hv_iterinit(hv);
1265 while ((he = hv_iternext(hv)) && count--) {
98c991d1
JH
1266 SV *elt, *keysv;
1267 char *keypv;
1268 STRLEN len;
3967c732
JD
1269 U32 hash = HeHASH(he);
1270
98c991d1
JH
1271 keysv = hv_iterkeysv(he);
1272 keypv = SvPV(keysv, len);
3967c732 1273 elt = hv_iterval(hv, he);
98c991d1
JH
1274 Perl_dump_indent(aTHX_ level+1, file, "Elt %s ", pv_display(d, keypv, len, 0, pvlim));
1275 if (SvUTF8(keysv))
b2ff9928 1276 PerlIO_printf(file, "[UTF8 \"%s\"] ", sv_uni_display(d, keysv, 8 * sv_len_utf8(keysv), 0));
98c991d1 1277 PerlIO_printf(file, "HASH = 0x%"UVxf"\n", (UV)hash);
3967c732
JD
1278 do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim);
1279 }
1280 hv_iterinit(hv); /* Return to status quo */
1281 }
1282 break;
1283 case SVt_PVCV:
1284 if (SvPOK(sv))
cea2e8a9 1285 Perl_dump_indent(aTHX_ level, file, " PROTOTYPE = \"%s\"\n", SvPV(sv,n_a));
3967c732
JD
1286 /* FALL THROUGH */
1287 case SVt_PVFM:
1288 do_hv_dump(level, file, " COMP_STASH", CvSTASH(sv));
1289 if (CvSTART(sv))
57def98f
JH
1290 Perl_dump_indent(aTHX_ level, file, " START = 0x%"UVxf" ===> %"IVdf"\n", PTR2UV(CvSTART(sv)), (IV)CvSTART(sv)->op_seq);
1291 Perl_dump_indent(aTHX_ level, file, " ROOT = 0x%"UVxf"\n", PTR2UV(CvROOT(sv)));
3967c732
JD
1292 if (CvROOT(sv) && dumpops)
1293 do_op_dump(level+1, file, CvROOT(sv));
57def98f
JH
1294 Perl_dump_indent(aTHX_ level, file, " XSUB = 0x%"UVxf"\n", PTR2UV(CvXSUB(sv)));
1295 Perl_dump_indent(aTHX_ level, file, " XSUBANY = %"IVdf"\n", (IV)CvXSUBANY(sv).any_i32);
3967c732 1296 do_gvgv_dump(level, file, " GVGV::GV", CvGV(sv));
57843af0 1297 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", CvFILE(sv));
57def98f 1298 Perl_dump_indent(aTHX_ level, file, " DEPTH = %"IVdf"\n", (IV)CvDEPTH(sv));
4d1ff10f 1299#ifdef USE_5005THREADS
07270b1a
GS
1300 Perl_dump_indent(aTHX_ level, file, " MUTEXP = 0x%"UVxf"\n", PTR2UV(CvMUTEXP(sv)));
1301 Perl_dump_indent(aTHX_ level, file, " OWNER = 0x%"UVxf"\n", PTR2UV(CvOWNER(sv)));
4d1ff10f 1302#endif /* USE_5005THREADS */
894356b3 1303 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)CvFLAGS(sv));
3967c732 1304 if (type == SVt_PVFM)
57def98f
JH
1305 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)FmLINES(sv));
1306 Perl_dump_indent(aTHX_ level, file, " PADLIST = 0x%"UVxf"\n", PTR2UV(CvPADLIST(sv)));
3967c732
JD
1307 if (nest < maxnest && CvPADLIST(sv)) {
1308 AV* padlist = CvPADLIST(sv);
1309 AV* pad_name = (AV*)*av_fetch(padlist, 0, FALSE);
1310 AV* pad = (AV*)*av_fetch(padlist, 1, FALSE);
1311 SV** pname = AvARRAY(pad_name);
1312 SV** ppad = AvARRAY(pad);
1313 I32 ix;
1314
1315 for (ix = 1; ix <= AvFILL(pad_name); ix++) {
b9c39e73 1316 if (SvPOK(pname[ix]))
57def98f
JH
1317 Perl_dump_indent(aTHX_ level,
1318 /* %5d below is enough whitespace. */
2ef28da1 1319 file,
57def98f 1320 "%5d. 0x%"UVxf" (%s\"%s\" %"IVdf"-%"IVdf")\n",
894356b3 1321 (int)ix, PTR2UV(ppad[ix]),
cf2093f6
JH
1322 SvFAKE(pname[ix]) ? "FAKE " : "",
1323 SvPVX(pname[ix]),
1324 (IV)SvNVX(pname[ix]),
1325 (IV)SvIVX(pname[ix]));
3967c732
JD
1326 }
1327 }
1328 {
1329 CV *outside = CvOUTSIDE(sv);
2ef28da1 1330 Perl_dump_indent(aTHX_ level, file, " OUTSIDE = 0x%"UVxf" (%s)\n",
57def98f 1331 PTR2UV(outside),
cf2093f6
JH
1332 (!outside ? "null"
1333 : CvANON(outside) ? "ANON"
1334 : (outside == PL_main_cv) ? "MAIN"
1335 : CvUNIQUE(outside) ? "UNIQUE"
1336 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
3967c732
JD
1337 }
1338 if (nest < maxnest && (CvCLONE(sv) || CvCLONED(sv)))
1339 do_sv_dump(level+1, file, (SV*)CvOUTSIDE(sv), nest+1, maxnest, dumpops, pvlim);
1340 break;
1341 case SVt_PVGV:
cea2e8a9 1342 Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", GvNAME(sv));
57def98f 1343 Perl_dump_indent(aTHX_ level, file, " NAMELEN = %"IVdf"\n", (IV)GvNAMELEN(sv));
3967c732 1344 do_hv_dump (level, file, " GvSTASH", GvSTASH(sv));
57def98f 1345 Perl_dump_indent(aTHX_ level, file, " GP = 0x%"UVxf"\n", PTR2UV(GvGP(sv)));
f472eb5c
GS
1346 if (!GvGP(sv))
1347 break;
57def98f
JH
1348 Perl_dump_indent(aTHX_ level, file, " SV = 0x%"UVxf"\n", PTR2UV(GvSV(sv)));
1349 Perl_dump_indent(aTHX_ level, file, " REFCNT = %"IVdf"\n", (IV)GvREFCNT(sv));
1350 Perl_dump_indent(aTHX_ level, file, " IO = 0x%"UVxf"\n", PTR2UV(GvIOp(sv)));
1351 Perl_dump_indent(aTHX_ level, file, " FORM = 0x%"UVxf" \n", PTR2UV(GvFORM(sv)));
1352 Perl_dump_indent(aTHX_ level, file, " AV = 0x%"UVxf"\n", PTR2UV(GvAV(sv)));
1353 Perl_dump_indent(aTHX_ level, file, " HV = 0x%"UVxf"\n", PTR2UV(GvHV(sv)));
1354 Perl_dump_indent(aTHX_ level, file, " CV = 0x%"UVxf"\n", PTR2UV(GvCV(sv)));
1355 Perl_dump_indent(aTHX_ level, file, " CVGEN = 0x%"UVxf"\n", (UV)GvCVGEN(sv));
f4c556ac 1356 Perl_dump_indent(aTHX_ level, file, " GPFLAGS = 0x%"UVxf"\n", (UV)GvGPFLAGS(sv));
57def98f 1357 Perl_dump_indent(aTHX_ level, file, " LINE = %"IVdf"\n", (IV)GvLINE(sv));
b195d487 1358 Perl_dump_indent(aTHX_ level, file, " FILE = \"%s\"\n", GvFILE(sv));
e39917cc 1359 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)GvFLAGS(sv));
3967c732
JD
1360 do_gv_dump (level, file, " EGV", GvEGV(sv));
1361 break;
1362 case SVt_PVIO:
57def98f
JH
1363 Perl_dump_indent(aTHX_ level, file, " IFP = 0x%"UVxf"\n", PTR2UV(IoIFP(sv)));
1364 Perl_dump_indent(aTHX_ level, file, " OFP = 0x%"UVxf"\n", PTR2UV(IoOFP(sv)));
1365 Perl_dump_indent(aTHX_ level, file, " DIRP = 0x%"UVxf"\n", PTR2UV(IoDIRP(sv)));
1366 Perl_dump_indent(aTHX_ level, file, " LINES = %"IVdf"\n", (IV)IoLINES(sv));
1367 Perl_dump_indent(aTHX_ level, file, " PAGE = %"IVdf"\n", (IV)IoPAGE(sv));
1368 Perl_dump_indent(aTHX_ level, file, " PAGE_LEN = %"IVdf"\n", (IV)IoPAGE_LEN(sv));
1369 Perl_dump_indent(aTHX_ level, file, " LINES_LEFT = %"IVdf"\n", (IV)IoLINES_LEFT(sv));
27533608 1370 if (IoTOP_NAME(sv))
cea2e8a9 1371 Perl_dump_indent(aTHX_ level, file, " TOP_NAME = \"%s\"\n", IoTOP_NAME(sv));
3967c732 1372 do_gv_dump (level, file, " TOP_GV", IoTOP_GV(sv));
27533608 1373 if (IoFMT_NAME(sv))
cea2e8a9 1374 Perl_dump_indent(aTHX_ level, file, " FMT_NAME = \"%s\"\n", IoFMT_NAME(sv));
3967c732 1375 do_gv_dump (level, file, " FMT_GV", IoFMT_GV(sv));
27533608 1376 if (IoBOTTOM_NAME(sv))
cea2e8a9 1377 Perl_dump_indent(aTHX_ level, file, " BOTTOM_NAME = \"%s\"\n", IoBOTTOM_NAME(sv));
3967c732 1378 do_gv_dump (level, file, " BOTTOM_GV", IoBOTTOM_GV(sv));
57def98f 1379 Perl_dump_indent(aTHX_ level, file, " SUBPROCESS = %"IVdf"\n", (IV)IoSUBPROCESS(sv));
27533608 1380 if (isPRINT(IoTYPE(sv)))
cea2e8a9 1381 Perl_dump_indent(aTHX_ level, file, " TYPE = '%c'\n", IoTYPE(sv));
27533608 1382 else
cea2e8a9 1383 Perl_dump_indent(aTHX_ level, file, " TYPE = '\\%o'\n", IoTYPE(sv));
57def98f 1384 Perl_dump_indent(aTHX_ level, file, " FLAGS = 0x%"UVxf"\n", (UV)IoFLAGS(sv));
3967c732
JD
1385 break;
1386 }
cea89e20 1387 SvREFCNT_dec(d);
3967c732
JD
1388}
1389
1390void
864dbfa3 1391Perl_sv_dump(pTHX_ SV *sv)
3967c732
JD
1392{
1393 do_sv_dump(0, Perl_debug_log, sv, 0, 0, 0, 0);
8d063cd8 1394}