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