1 /* $RCSfile: dump.c,v $$Revision: 4.1 $$Date: 92/08/07 17:20:03 $
3 * Copyright (c) 1991, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
9 * Revision 4.1 92/08/07 17:20:03 lwall
12 * Revision 4.0.1.2 92/06/08 13:14:22 lwall
13 * patch20: removed implicit int declarations on funcions
14 * patch20: fixed confusion between a *var's real name and its effective name
16 * Revision 4.0.1.1 91/06/07 10:58:44 lwall
17 * patch4: new copyright notice
19 * Revision 4.0 91/03/20 01:08:25 lwall
32 #else /* Rest of file is for DEBUGGING */
42 setvbuf(stderr, Nullch, _IOLBF, 0);
46 dump_packsubs(defstash);
58 for (i = 0; i <= HvMAX(stash); i++) {
59 for (entry = HvARRAY(stash)[i]; entry; entry = entry->hent_next) {
60 GV *gv = (GV*)entry->hent_val;
64 if (*entry->hent_key == '_' && (hv = GvHV(gv)) && HvNAME(hv) &&
66 dump_packsubs(hv); /* nested package */
75 SV *sv = sv_newmortal();
78 dump("\nSUB %s = ", SvPVX(sv));
79 if (CvUSERSUB(GvCV(gv)))
80 dump("(xsub 0x%x %d)\n",
81 (long)CvUSERSUB(GvCV(gv)),
82 CvUSERINDEX(GvCV(gv)));
83 else if (CvROOT(GvCV(gv)))
84 dump_op(CvROOT(GvCV(gv)));
108 fprintf(stderr, "%-4d", op->op_seq);
110 fprintf(stderr, " ");
111 dump("TYPE = %s ===> ", op_name[op->op_type]);
114 fprintf(stderr, "%d\n", op->op_next->op_seq);
116 fprintf(stderr, "(%d)\n", op->op_next->op_seq);
119 fprintf(stderr, "DONE\n");
122 if (op->op_type == OP_NULL)
123 dump(" (was %s)\n", op_name[op->op_targ]);
125 dump("TARG = %d\n", op->op_targ);
128 dump("ADDR = 0x%lx => 0x%lx\n",op, op->op_next);
132 if (op->op_flags & OPf_KNOW) {
133 if (op->op_flags & OPf_LIST)
134 (void)strcat(buf,"LIST,");
136 (void)strcat(buf,"SCALAR,");
139 (void)strcat(buf,"UNKNOWN,");
140 if (op->op_flags & OPf_KIDS)
141 (void)strcat(buf,"KIDS,");
142 if (op->op_flags & OPf_PARENS)
143 (void)strcat(buf,"PARENS,");
144 if (op->op_flags & OPf_STACKED)
145 (void)strcat(buf,"STACKED,");
146 if (op->op_flags & OPf_LVAL)
147 (void)strcat(buf,"LVAL,");
148 if (op->op_flags & OPf_INTRO)
149 (void)strcat(buf,"INTRO,");
150 if (op->op_flags & OPf_SPECIAL)
151 (void)strcat(buf,"SPECIAL,");
153 buf[strlen(buf)-1] = '\0';
154 dump("FLAGS = (%s)\n",buf);
156 if (op->op_private) {
158 if (op->op_type == OP_AASSIGN) {
159 if (op->op_private & OPpASSIGN_COMMON)
160 (void)strcat(buf,"COMMON,");
162 else if (op->op_type == OP_TRANS) {
163 if (op->op_private & OPpTRANS_SQUASH)
164 (void)strcat(buf,"SQUASH,");
165 if (op->op_private & OPpTRANS_DELETE)
166 (void)strcat(buf,"DELETE,");
167 if (op->op_private & OPpTRANS_COMPLEMENT)
168 (void)strcat(buf,"COMPLEMENT,");
170 else if (op->op_type == OP_REPEAT) {
171 if (op->op_private & OPpREPEAT_DOLIST)
172 (void)strcat(buf,"DOLIST,");
174 else if (op->op_type == OP_ENTERSUBR) {
175 if (op->op_private & OPpSUBR_DB)
176 (void)strcat(buf,"DB,");
178 else if (op->op_type == OP_CONST) {
179 if (op->op_private & OPpCONST_BARE)
180 (void)strcat(buf,"BARE,");
182 else if (op->op_type == OP_FLIP) {
183 if (op->op_private & OPpFLIP_LINENUM)
184 (void)strcat(buf,"LINENUM,");
186 else if (op->op_type == OP_FLOP) {
187 if (op->op_private & OPpFLIP_LINENUM)
188 (void)strcat(buf,"LINENUM,");
191 buf[strlen(buf)-1] = '\0';
192 dump("PRIVATE = (%s)\n",buf);
196 switch (op->op_type) {
203 gv_fullname(tmpsv,cGVOP->op_gv);
204 dump("GV = %s\n", SvPV(tmpsv, na));
211 dump("SV = %s\n", SvPEEK(cSVOP->op_sv));
216 dump("LINE = %d\n",cCOP->cop_line);
218 dump("LABEL = \"%s\"\n",cCOP->cop_label);
222 if (cLOOP->op_redoop)
223 fprintf(stderr, "%d\n", cLOOP->op_redoop->op_seq);
225 fprintf(stderr, "DONE\n");
227 if (cLOOP->op_nextop)
228 fprintf(stderr, "%d\n", cLOOP->op_nextop->op_seq);
230 fprintf(stderr, "DONE\n");
232 if (cLOOP->op_lastop)
233 fprintf(stderr, "%d\n", cLOOP->op_lastop->op_seq);
235 fprintf(stderr, "DONE\n");
239 if (cCONDOP->op_true)
240 fprintf(stderr, "%d\n", cCONDOP->op_true->op_seq);
242 fprintf(stderr, "DONE\n");
244 if (cCONDOP->op_false)
245 fprintf(stderr, "%d\n", cCONDOP->op_false->op_seq);
247 fprintf(stderr, "DONE\n");
254 if (cLOGOP->op_other)
255 fprintf(stderr, "%d\n", cLOGOP->op_other->op_seq);
257 fprintf(stderr, "DONE\n");
265 if (op->op_flags & OPf_KIDS) {
267 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling)
281 fprintf(stderr,"{}\n");
286 fprintf(stderr,"{\n");
288 dump("GV_NAME = %s", SvPVX(sv));
289 if (gv != GvEGV(gv)) {
290 gv_efullname(sv,GvEGV(gv));
291 dump("-> %s", SvPVX(sv));
310 if (pm->op_pmflags & PMf_ONCE)
315 dump("PMf_PRE %c%s%c\n",ch,pm->op_pmregexp->precomp,ch);
316 if (pm->op_type != OP_PUSHRE && pm->op_pmreplroot) {
318 dump_op(pm->op_pmreplroot);
320 if (pm->op_pmshort) {
321 dump("PMf_SHORT = %s\n",SvPEEK(pm->op_pmshort));
323 if (pm->op_pmflags) {
325 if (pm->op_pmflags & PMf_USED)
326 (void)strcat(buf,"USED,");
327 if (pm->op_pmflags & PMf_ONCE)
328 (void)strcat(buf,"ONCE,");
329 if (pm->op_pmflags & PMf_SCANFIRST)
330 (void)strcat(buf,"SCANFIRST,");
331 if (pm->op_pmflags & PMf_ALL)
332 (void)strcat(buf,"ALL,");
333 if (pm->op_pmflags & PMf_SKIPWHITE)
334 (void)strcat(buf,"SKIPWHITE,");
335 if (pm->op_pmflags & PMf_FOLD)
336 (void)strcat(buf,"FOLD,");
337 if (pm->op_pmflags & PMf_CONST)
338 (void)strcat(buf,"CONST,");
339 if (pm->op_pmflags & PMf_KEEP)
340 (void)strcat(buf,"KEEP,");
341 if (pm->op_pmflags & PMf_GLOBAL)
342 (void)strcat(buf,"GLOBAL,");
343 if (pm->op_pmflags & PMf_RUNTIME)
344 (void)strcat(buf,"RUNTIME,");
345 if (pm->op_pmflags & PMf_EVAL)
346 (void)strcat(buf,"EVAL,");
348 buf[strlen(buf)-1] = '\0';
349 dump("PMFLAGS = (%s)\n",buf);
357 static void dump(arg1,arg2,arg3,arg4,arg5)
359 long arg2, arg3, arg4, arg5;
363 for (i = dumplvl*4; i; i--)
364 (void)putc(' ',stderr);
365 fprintf(stderr,arg1, arg2, arg3, arg4, arg5);