X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=dump.c;h=e74c8c4217e8cfcbedda24cd40568e6c30ead403;hb=e43cfa93c2ef6ac50be4121f06de5f795aa3fa62;hp=f5073a0deca4a386b5ec2462e50ccde209ba2bcd;hpb=748a93069b3d16374a9859d1456065dd3ae11394;p=p5sagit%2Fp5-mst-13.2.git diff --git a/dump.c b/dump.c index f5073a0..e74c8c4 100644 --- a/dump.c +++ b/dump.c @@ -1,6 +1,6 @@ /* dump.c * - * Copyright (c) 1991-1994, Larry Wall + * Copyright (c) 1991-1997, Larry Wall * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -22,16 +22,16 @@ dump_all() } #else /* Rest of file is for DEBUGGING */ +#ifdef I_STDARG +static void dump(char *pat, ...); +#else static void dump(); +#endif void dump_all() { -#ifdef HAS_SETLINEBUF - setlinebuf(stderr); -#else - setvbuf(stderr, Nullch, _IOLBF, 0); -#endif + PerlIO_setlinebuf(Perl_debug_log); if (main_root) dump_op(main_root); dump_packsubs(defstash); @@ -47,14 +47,14 @@ HV* stash; if (!HvARRAY(stash)) return; for (i = 0; i <= (I32) HvMAX(stash); i++) { - for (entry = HvARRAY(stash)[i]; entry; entry = entry->hent_next) { - GV *gv = (GV*)entry->hent_val; + for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) { + GV *gv = (GV*)HeVAL(entry); HV *hv; - if (GvCV(gv)) + if (GvCVu(gv)) dump_sub(gv); if (GvFORM(gv)) dump_form(gv); - if (entry->hent_key[entry->hent_klen-1] == ':' && + if (HeKEY(entry)[HeKLEN(entry)-1] == ':' && (hv = GvHV(gv)) && HvNAME(hv) && hv != defstash) dump_packsubs(hv); /* nested package */ } @@ -67,7 +67,7 @@ GV* gv; { SV *sv = sv_newmortal(); - gv_fullname(sv,gv); + gv_fullname3(sv, gv, Nullch); dump("\nSUB %s = ", SvPVX(sv)); if (CvXSUB(GvCV(gv))) dump("(xsub 0x%x %d)\n", @@ -85,7 +85,7 @@ GV* gv; { SV *sv = sv_newmortal(); - gv_fullname(sv,gv); + gv_fullname3(sv, gv, Nullch); dump("\nFORMAT %s = ", SvPVX(sv)); if (CvROOT(GvFORM(gv))) dump_op(CvROOT(GvFORM(gv))); @@ -107,18 +107,18 @@ register OP *op; dump("{\n"); if (op->op_seq) - fprintf(stderr, "%-4d", op->op_seq); + PerlIO_printf(Perl_debug_log, "%-4d", op->op_seq); else - fprintf(stderr, " "); + PerlIO_printf(Perl_debug_log, " "); dump("TYPE = %s ===> ", op_name[op->op_type]); if (op->op_next) { if (op->op_seq) - fprintf(stderr, "%d\n", op->op_next->op_seq); + PerlIO_printf(Perl_debug_log, "%d\n", op->op_next->op_seq); else - fprintf(stderr, "(%d)\n", op->op_next->op_seq); + PerlIO_printf(Perl_debug_log, "(%d)\n", op->op_next->op_seq); } else - fprintf(stderr, "DONE\n"); + PerlIO_printf(Perl_debug_log, "DONE\n"); dumplvl++; if (op->op_targ) { if (op->op_type == OP_NULL) @@ -131,14 +131,20 @@ register OP *op; #endif if (op->op_flags) { *buf = '\0'; - if (op->op_flags & OPf_KNOW) { - if (op->op_flags & OPf_LIST) - (void)strcat(buf,"LIST,"); - else - (void)strcat(buf,"SCALAR,"); - } - else + switch (op->op_flags & OPf_WANT) { + case OPf_WANT_VOID: + (void)strcat(buf,"VOID,"); + break; + case OPf_WANT_SCALAR: + (void)strcat(buf,"SCALAR,"); + break; + case OPf_WANT_LIST: + (void)strcat(buf,"LIST,"); + break; + default: (void)strcat(buf,"UNKNOWN,"); + break; + } if (op->op_flags & OPf_KIDS) (void)strcat(buf,"KIDS,"); if (op->op_flags & OPf_PARENS) @@ -185,14 +191,31 @@ register OP *op; op->op_type == OP_AELEM || op->op_type == OP_HELEM ) { - if (op->op_private & OPpDEREF_DB) - (void)strcat(buf,"DB,"); - if (op->op_private & OPpDEREF_AV) - (void)strcat(buf,"AV,"); - if (op->op_private & OPpDEREF_HV) - (void)strcat(buf,"HV,"); - if (op->op_private & HINT_STRICT_REFS) - (void)strcat(buf,"STRICT_REFS,"); + if (op->op_type == OP_ENTERSUB) { + if (op->op_private & OPpENTERSUB_AMPER) + (void)strcat(buf,"AMPER,"); + if (op->op_private & OPpENTERSUB_DB) + (void)strcat(buf,"DB,"); + } + switch (op->op_private & OPpDEREF) { + case OPpDEREF_SV: + (void)strcat(buf, "SV,"); + break; + case OPpDEREF_AV: + (void)strcat(buf, "AV,"); + break; + case OPpDEREF_HV: + (void)strcat(buf, "HV,"); + break; + } + if (op->op_type == OP_AELEM || op->op_type == OP_HELEM) { + if (op->op_private & OPpLVAL_DEFER) + (void)strcat(buf,"LVAL_DEFER,"); + } + else { + if (op->op_private & HINT_STRICT_REFS) + (void)strcat(buf,"STRICT_REFS,"); + } } else if (op->op_type == OP_CONST) { if (op->op_private & OPpCONST_BARE) @@ -221,7 +244,7 @@ register OP *op; ENTER; tmpsv = NEWSV(0,0); SAVEFREESV(tmpsv); - gv_fullname(tmpsv,cGVOP->op_gv); + gv_fullname3(tmpsv, cGVOP->op_gv, Nullch); dump("GV = %s\n", SvPV(tmpsv, na)); LEAVE; } @@ -241,31 +264,31 @@ register OP *op; case OP_ENTERLOOP: dump("REDO ===> "); if (cLOOP->op_redoop) - fprintf(stderr, "%d\n", cLOOP->op_redoop->op_seq); + PerlIO_printf(Perl_debug_log, "%d\n", cLOOP->op_redoop->op_seq); else - fprintf(stderr, "DONE\n"); + PerlIO_printf(Perl_debug_log, "DONE\n"); dump("NEXT ===> "); if (cLOOP->op_nextop) - fprintf(stderr, "%d\n", cLOOP->op_nextop->op_seq); + PerlIO_printf(Perl_debug_log, "%d\n", cLOOP->op_nextop->op_seq); else - fprintf(stderr, "DONE\n"); + PerlIO_printf(Perl_debug_log, "DONE\n"); dump("LAST ===> "); if (cLOOP->op_lastop) - fprintf(stderr, "%d\n", cLOOP->op_lastop->op_seq); + PerlIO_printf(Perl_debug_log, "%d\n", cLOOP->op_lastop->op_seq); else - fprintf(stderr, "DONE\n"); + PerlIO_printf(Perl_debug_log, "DONE\n"); break; case OP_COND_EXPR: dump("TRUE ===> "); if (cCONDOP->op_true) - fprintf(stderr, "%d\n", cCONDOP->op_true->op_seq); + PerlIO_printf(Perl_debug_log, "%d\n", cCONDOP->op_true->op_seq); else - fprintf(stderr, "DONE\n"); + PerlIO_printf(Perl_debug_log, "DONE\n"); dump("FALSE ===> "); if (cCONDOP->op_false) - fprintf(stderr, "%d\n", cCONDOP->op_false->op_seq); + PerlIO_printf(Perl_debug_log, "%d\n", cCONDOP->op_false->op_seq); else - fprintf(stderr, "DONE\n"); + PerlIO_printf(Perl_debug_log, "DONE\n"); break; case OP_MAPWHILE: case OP_GREPWHILE: @@ -273,9 +296,9 @@ register OP *op; case OP_AND: dump("OTHER ===> "); if (cLOGOP->op_other) - fprintf(stderr, "%d\n", cLOGOP->op_other->op_seq); + PerlIO_printf(Perl_debug_log, "%d\n", cLOGOP->op_other->op_seq); else - fprintf(stderr, "DONE\n"); + PerlIO_printf(Perl_debug_log, "DONE\n"); break; case OP_PUSHRE: case OP_MATCH: @@ -301,16 +324,16 @@ register GV *gv; SV *sv; if (!gv) { - fprintf(stderr,"{}\n"); + PerlIO_printf(Perl_debug_log, "{}\n"); return; } sv = sv_newmortal(); dumplvl++; - fprintf(stderr,"{\n"); - gv_fullname(sv,gv); + PerlIO_printf(Perl_debug_log, "{\n"); + gv_fullname3(sv, gv, Nullch); dump("GV_NAME = %s", SvPVX(sv)); if (gv != GvEGV(gv)) { - gv_efullname(sv,GvEGV(gv)); + gv_efullname3(sv, GvEGV(gv), Nullch); dump("-> %s", SvPVX(sv)); } dump("\n"); @@ -355,8 +378,6 @@ register PMOP *pm; (void)strcat(buf,"ALL,"); if (pm->op_pmflags & PMf_SKIPWHITE) (void)strcat(buf,"SKIPWHITE,"); - if (pm->op_pmflags & PMf_FOLD) - (void)strcat(buf,"FOLD,"); if (pm->op_pmflags & PMf_CONST) (void)strcat(buf,"CONST,"); if (pm->op_pmflags & PMf_KEEP) @@ -376,6 +397,8 @@ register PMOP *pm; dump("}\n"); } + +#if !defined(I_STDARG) && !defined(I_VARARGS) /* VARARGS1 */ static void dump(arg1,arg2,arg3,arg4,arg5) char *arg1; @@ -384,7 +407,36 @@ long arg2, arg3, arg4, arg5; I32 i; for (i = dumplvl*4; i; i--) - (void)putc(' ',stderr); - fprintf(stderr,arg1, arg2, arg3, arg4, arg5); + (void)PerlIO_putc(Perl_debug_log,' '); + PerlIO_printf(Perl_debug_log, arg1, arg2, arg3, arg4, arg5); +} + +#else + +#ifdef I_STDARG +static void +dump(char *pat,...) +#else +/*VARARGS0*/ +static void +dump(pat,va_alist) + char *pat; + va_dcl +#endif +{ + I32 i; + va_list args; + +#ifdef I_STDARG + va_start(args, pat); +#else + va_start(args); +#endif + for (i = dumplvl*4; i; i--) + (void)PerlIO_putc(Perl_debug_log,' '); + PerlIO_vprintf(Perl_debug_log,pat,args); + va_end(args); } #endif + +#endif