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