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