Commit | Line | Data |
a0d0e21e |
1 | /* run.c |
2 | * |
4eb8286e |
3 | * Copyright (c) 1991-1999, 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" |
864dbfa3 |
11 | #define PERL_IN_RUN_C |
79072805 |
12 | #include "perl.h" |
13 | |
a0d0e21e |
14 | /* |
15 | * "Away now, Shadowfax! Run, greatheart, run as you have never run before! |
16 | * Now we are come to the lands where you were foaled, and every stone you |
17 | * know. Run now! Hope is in speed!" --Gandalf |
18 | */ |
19 | |
a0d0e21e |
20 | int |
864dbfa3 |
21 | Perl_runops_standard(pTHX) |
17c3b450 |
22 | { |
11343788 |
23 | dTHR; |
a0d0e21e |
24 | |
cd39f2b6 |
25 | while ( PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX) ) { |
26 | #ifdef MACOS_TRADITIONAL |
27 | MACPERL_DO_ASYNC_TASKS(); |
28 | #endif |
29 | } |
fd18d308 |
30 | |
31 | TAINT_NOT; |
a0d0e21e |
32 | return 0; |
79072805 |
33 | } |
34 | |
a0d0e21e |
35 | int |
864dbfa3 |
36 | Perl_runops_debug(pTHX) |
35ff7856 |
37 | { |
38 | #ifdef DEBUGGING |
11343788 |
39 | dTHR; |
f248d071 |
40 | if (!PL_op) { |
41 | if (ckWARN_d(WARN_DEBUGGING)) |
42 | Perl_warner(aTHX_ WARN_DEBUGGING, "NULL OP IN RUN"); |
a0d0e21e |
43 | return 0; |
79072805 |
44 | } |
a0d0e21e |
45 | |
79072805 |
46 | do { |
cd39f2b6 |
47 | #ifdef MACOS_TRADITIONAL |
48 | MACPERL_DO_ASYNC_TASKS(); |
49 | #endif |
3280af22 |
50 | if (PL_debug) { |
22c35a8c |
51 | if (PL_watchaddr != 0 && *PL_watchaddr != PL_watchok) |
b900a521 |
52 | PerlIO_printf(Perl_debug_log, |
53 | "WARNING: %"UVxf" changed from %"UVxf" to %"UVxf"\n", |
54 | PTR2UV(PL_watchaddr), PTR2UV(PL_watchok), (UV)*PL_watchaddr); |
79072805 |
55 | DEBUG_s(debstack()); |
533c011a |
56 | DEBUG_t(debop(PL_op)); |
57 | DEBUG_P(debprof(PL_op)); |
79072805 |
58 | } |
fc0dc3b3 |
59 | } while ( PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX) ); |
fd18d308 |
60 | |
61 | TAINT_NOT; |
a0d0e21e |
62 | return 0; |
35ff7856 |
63 | #else |
64 | return runops_standard(); |
17c3b450 |
65 | #endif /* DEBUGGING */ |
79072805 |
66 | } |
67 | |
79072805 |
68 | I32 |
864dbfa3 |
69 | Perl_debop(pTHX_ OP *o) |
79072805 |
70 | { |
35ff7856 |
71 | #ifdef DEBUGGING |
79072805 |
72 | SV *sv; |
2d8e6c8d |
73 | STRLEN n_a; |
cea2e8a9 |
74 | Perl_deb(aTHX_ "%s", PL_op_name[o->op_type]); |
11343788 |
75 | switch (o->op_type) { |
79072805 |
76 | case OP_CONST: |
5dc0d613 |
77 | PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOPo->op_sv)); |
79072805 |
78 | break; |
79 | case OP_GVSV: |
80 | case OP_GV: |
7934575e |
81 | if (cSVOPo->op_sv) { |
79072805 |
82 | sv = NEWSV(0,0); |
7934575e |
83 | gv_fullname3(sv, (GV*)cSVOPo->op_sv, Nullch); |
2d8e6c8d |
84 | PerlIO_printf(Perl_debug_log, "(%s)", SvPV(sv, n_a)); |
8990e307 |
85 | SvREFCNT_dec(sv); |
79072805 |
86 | } |
87 | else |
760ac839 |
88 | PerlIO_printf(Perl_debug_log, "(NULL)"); |
79072805 |
89 | break; |
a0d0e21e |
90 | default: |
91 | break; |
79072805 |
92 | } |
760ac839 |
93 | PerlIO_printf(Perl_debug_log, "\n"); |
17c3b450 |
94 | #endif /* DEBUGGING */ |
79072805 |
95 | return 0; |
96 | } |
97 | |
98 | void |
864dbfa3 |
99 | Perl_watch(pTHX_ char **addr) |
79072805 |
100 | { |
35ff7856 |
101 | #ifdef DEBUGGING |
22c35a8c |
102 | dTHR; |
103 | PL_watchaddr = addr; |
104 | PL_watchok = *addr; |
b900a521 |
105 | PerlIO_printf(Perl_debug_log, "WATCHING, %"UVxf" is currently %"UVxf"\n", |
106 | PTR2UV(PL_watchaddr), PTR2UV(PL_watchok)); |
17c3b450 |
107 | #endif /* DEBUGGING */ |
79072805 |
108 | } |
a0d0e21e |
109 | |
76e3520e |
110 | STATIC void |
cea2e8a9 |
111 | S_debprof(pTHX_ OP *o) |
a0d0e21e |
112 | { |
35ff7856 |
113 | #ifdef DEBUGGING |
3280af22 |
114 | if (!PL_profiledata) |
115 | Newz(000, PL_profiledata, MAXO, U32); |
116 | ++PL_profiledata[o->op_type]; |
35ff7856 |
117 | #endif /* DEBUGGING */ |
a0d0e21e |
118 | } |
119 | |
120 | void |
864dbfa3 |
121 | Perl_debprofdump(pTHX) |
a0d0e21e |
122 | { |
35ff7856 |
123 | #ifdef DEBUGGING |
9607fc9c |
124 | unsigned i; |
3280af22 |
125 | if (!PL_profiledata) |
a0d0e21e |
126 | return; |
127 | for (i = 0; i < MAXO; i++) { |
3280af22 |
128 | if (PL_profiledata[i]) |
9607fc9c |
129 | PerlIO_printf(Perl_debug_log, |
3280af22 |
130 | "%5lu %s\n", (unsigned long)PL_profiledata[i], |
22c35a8c |
131 | PL_op_name[i]); |
a0d0e21e |
132 | } |
17c3b450 |
133 | #endif /* DEBUGGING */ |
35ff7856 |
134 | } |