[asperl] more changes to satisfy non-debug VC build (C-API doesn't
[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
76e3520e 19#ifdef PERL_OBJECT
20#define CALLOP this->*op
21#else
22#define CALLOP *op
23#endif
79072805 24
a0d0e21e 25int
8ac85365 26runops_standard(void) {
11343788 27 dTHR;
a0d0e21e 28
76e3520e 29 while ( op = (CALLOP->op_ppaddr)(ARGS) ) ;
fd18d308 30
31 TAINT_NOT;
a0d0e21e 32 return 0;
79072805 33}
34
22239a37 35dEXT char **watchaddr = 0;
36dEXT char *watchok;
37
76e3520e 38#ifndef PERL_OBJECT
11343788 39static void debprof _((OP*o));
76e3520e 40#endif
a0d0e21e 41
42int
35ff7856 43runops_debug(void)
44{
45#ifdef DEBUGGING
11343788 46 dTHR;
79072805 47 if (!op) {
48 warn("NULL OP IN RUN");
a0d0e21e 49 return 0;
79072805 50 }
a0d0e21e 51
79072805 52 do {
53 if (debug) {
54 if (watchaddr != 0 && *watchaddr != watchok)
760ac839 55 PerlIO_printf(Perl_debug_log, "WARNING: %lx changed from %lx to %lx\n",
a0d0e21e 56 (long)watchaddr, (long)watchok, (long)*watchaddr);
79072805 57 DEBUG_s(debstack());
58 DEBUG_t(debop(op));
a0d0e21e 59 DEBUG_P(debprof(op));
79072805 60 }
76e3520e 61 } while ( op = (CALLOP->op_ppaddr)(ARGS) );
fd18d308 62
63 TAINT_NOT;
a0d0e21e 64 return 0;
35ff7856 65#else
66 return runops_standard();
67#endif /* DEBUGGING */
79072805 68}
69
79072805 70I32
8ac85365 71debop(OP *o)
79072805 72{
35ff7856 73#ifdef DEBUGGING
79072805 74 SV *sv;
11343788 75 deb("%s", op_name[o->op_type]);
76 switch (o->op_type) {
79072805 77 case OP_CONST:
5dc0d613 78 PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOPo->op_sv));
79072805 79 break;
80 case OP_GVSV:
81 case OP_GV:
11343788 82 if (cGVOPo->op_gv) {
79072805 83 sv = NEWSV(0,0);
5dc0d613 84 gv_fullname3(sv, cGVOPo->op_gv, Nullch);
760ac839 85 PerlIO_printf(Perl_debug_log, "(%s)", SvPV(sv, na));
8990e307 86 SvREFCNT_dec(sv);
79072805 87 }
88 else
760ac839 89 PerlIO_printf(Perl_debug_log, "(NULL)");
79072805 90 break;
a0d0e21e 91 default:
92 break;
79072805 93 }
760ac839 94 PerlIO_printf(Perl_debug_log, "\n");
35ff7856 95#endif /* DEBUGGING */
79072805 96 return 0;
97}
98
99void
8ac85365 100watch(char **addr)
79072805 101{
35ff7856 102#ifdef DEBUGGING
79072805 103 watchaddr = addr;
104 watchok = *addr;
760ac839 105 PerlIO_printf(Perl_debug_log, "WATCHING, %lx is currently %lx\n",
a0d0e21e 106 (long)watchaddr, (long)watchok);
35ff7856 107#endif /* DEBUGGING */
79072805 108}
a0d0e21e 109
76e3520e 110STATIC void
8ac85365 111debprof(OP *o)
a0d0e21e 112{
35ff7856 113#ifdef DEBUGGING
a0d0e21e 114 if (!profiledata)
115 New(000, profiledata, MAXO, U32);
11343788 116 ++profiledata[o->op_type];
35ff7856 117#endif /* DEBUGGING */
a0d0e21e 118}
119
120void
8ac85365 121debprofdump(void)
a0d0e21e 122{
35ff7856 123#ifdef DEBUGGING
9607fc9c 124 unsigned i;
a0d0e21e 125 if (!profiledata)
126 return;
127 for (i = 0; i < MAXO; i++) {
128 if (profiledata[i])
9607fc9c 129 PerlIO_printf(Perl_debug_log,
130 "%u\t%lu\n", i, (unsigned long)profiledata[i]);
a0d0e21e 131 }
22239a37 132#endif /* DEBUGGING */
35ff7856 133}