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