This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ExtUtils-Embed upgrade
[perl5.git] / run.c
... / ...
CommitLineData
1/* run.c
2 *
3 * Copyright (c) 1991-1997, Larry Wall
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
10#include "EXTERN.h"
11#include "perl.h"
12
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
19dEXT char **watchaddr = 0;
20dEXT char *watchok;
21
22#ifndef DEBUGGING
23
24int
25runops() {
26 SAVEI32(runlevel);
27 runlevel++;
28
29 while ( op = (*op->op_ppaddr)() ) ;
30
31 TAINT_NOT;
32 return 0;
33}
34
35#else
36
37static void debprof _((OP*op));
38
39int
40runops() {
41 if (!op) {
42 warn("NULL OP IN RUN");
43 return 0;
44 }
45
46 SAVEI32(runlevel);
47 runlevel++;
48
49 do {
50 if (debug) {
51 if (watchaddr != 0 && *watchaddr != watchok)
52 PerlIO_printf(Perl_debug_log, "WARNING: %lx changed from %lx to %lx\n",
53 (long)watchaddr, (long)watchok, (long)*watchaddr);
54 DEBUG_s(debstack());
55 DEBUG_t(debop(op));
56 DEBUG_P(debprof(op));
57 }
58 } while ( op = (*op->op_ppaddr)() );
59
60 TAINT_NOT;
61 return 0;
62}
63
64I32
65debop(op)
66OP *op;
67{
68 SV *sv;
69 deb("%s", op_name[op->op_type]);
70 switch (op->op_type) {
71 case OP_CONST:
72 PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOP->op_sv));
73 break;
74 case OP_GVSV:
75 case OP_GV:
76 if (cGVOP->op_gv) {
77 sv = NEWSV(0,0);
78 gv_fullname3(sv, cGVOP->op_gv, Nullch);
79 PerlIO_printf(Perl_debug_log, "(%s)", SvPV(sv, na));
80 SvREFCNT_dec(sv);
81 }
82 else
83 PerlIO_printf(Perl_debug_log, "(NULL)");
84 break;
85 default:
86 break;
87 }
88 PerlIO_printf(Perl_debug_log, "\n");
89 return 0;
90}
91
92void
93watch(addr)
94char **addr;
95{
96 watchaddr = addr;
97 watchok = *addr;
98 PerlIO_printf(Perl_debug_log, "WATCHING, %lx is currently %lx\n",
99 (long)watchaddr, (long)watchok);
100}
101
102static void
103debprof(op)
104OP* op;
105{
106 if (!profiledata)
107 New(000, profiledata, MAXO, U32);
108 ++profiledata[op->op_type];
109}
110
111void
112debprofdump()
113{
114 unsigned i;
115 if (!profiledata)
116 return;
117 for (i = 0; i < MAXO; i++) {
118 if (profiledata[i])
119 PerlIO_printf(Perl_debug_log,
120 "%u\t%lu\n", i, (unsigned long)profiledata[i]);
121 }
122}
123
124#endif
125