Reverse integrate Malcolm's chanes into local
[p5sagit/p5-mst-13.2.git] / run.c
CommitLineData
a0d0e21e 1/* run.c
2 *
9607fc9c 3 * Copyright (c) 1991-1997, Larry Wall
a0d0e21e 4 *
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.
7 *
8 */
9
79072805 10#include "EXTERN.h"
11#include "perl.h"
12
a0d0e21e 13/*
14 * "Away now, Shadowfax! Run, greatheart, run as you have never run before!
15 * Now we are come to the lands where you were foaled, and every stone you
16 * know. Run now! Hope is in speed!" --Gandalf
17 */
18
4633a7c4 19dEXT char **watchaddr = 0;
20dEXT char *watchok;
79072805 21
a0d0e21e 22int
8ac85365 23runops_standard(void) {
11343788 24 dTHR;
a0d0e21e 25 SAVEI32(runlevel);
26 runlevel++;
27
11343788 28 while ( op = (*op->op_ppaddr)(ARGS) ) ;
fd18d308 29
30 TAINT_NOT;
a0d0e21e 31 return 0;
79072805 32}
33
2ddcc7aa 34#ifdef DEBUGGING
11343788 35static void debprof _((OP*o));
a0d0e21e 36
37int
8ac85365 38runops_debug(void) {
11343788 39 dTHR;
79072805 40 if (!op) {
41 warn("NULL OP IN RUN");
a0d0e21e 42 return 0;
79072805 43 }
a0d0e21e 44
45 SAVEI32(runlevel);
46 runlevel++;
47
79072805 48 do {
49 if (debug) {
50 if (watchaddr != 0 && *watchaddr != watchok)
760ac839 51 PerlIO_printf(Perl_debug_log, "WARNING: %lx changed from %lx to %lx\n",
a0d0e21e 52 (long)watchaddr, (long)watchok, (long)*watchaddr);
79072805 53 DEBUG_s(debstack());
54 DEBUG_t(debop(op));
a0d0e21e 55 DEBUG_P(debprof(op));
79072805 56 }
11343788 57 } while ( op = (*op->op_ppaddr)(ARGS) );
fd18d308 58
59 TAINT_NOT;
a0d0e21e 60 return 0;
79072805 61}
62
79072805 63I32
8ac85365 64debop(OP *o)
79072805 65{
66 SV *sv;
11343788 67 deb("%s", op_name[o->op_type]);
68 switch (o->op_type) {
79072805 69 case OP_CONST:
5dc0d613 70 PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOPo->op_sv));
79072805 71 break;
72 case OP_GVSV:
73 case OP_GV:
11343788 74 if (cGVOPo->op_gv) {
79072805 75 sv = NEWSV(0,0);
5dc0d613 76 gv_fullname3(sv, cGVOPo->op_gv, Nullch);
760ac839 77 PerlIO_printf(Perl_debug_log, "(%s)", SvPV(sv, na));
8990e307 78 SvREFCNT_dec(sv);
79072805 79 }
80 else
760ac839 81 PerlIO_printf(Perl_debug_log, "(NULL)");
79072805 82 break;
a0d0e21e 83 default:
84 break;
79072805 85 }
760ac839 86 PerlIO_printf(Perl_debug_log, "\n");
79072805 87 return 0;
88}
89
90void
8ac85365 91watch(char **addr)
79072805 92{
93 watchaddr = addr;
94 watchok = *addr;
760ac839 95 PerlIO_printf(Perl_debug_log, "WATCHING, %lx is currently %lx\n",
a0d0e21e 96 (long)watchaddr, (long)watchok);
79072805 97}
a0d0e21e 98
99static void
8ac85365 100debprof(OP *o)
a0d0e21e 101{
102 if (!profiledata)
103 New(000, profiledata, MAXO, U32);
11343788 104 ++profiledata[o->op_type];
a0d0e21e 105}
106
107void
8ac85365 108debprofdump(void)
a0d0e21e 109{
9607fc9c 110 unsigned i;
a0d0e21e 111 if (!profiledata)
112 return;
113 for (i = 0; i < MAXO; i++) {
114 if (profiledata[i])
9607fc9c 115 PerlIO_printf(Perl_debug_log,
116 "%u\t%lu\n", i, (unsigned long)profiledata[i]);
a0d0e21e 117 }
118}
119
120#endif
121