Stats.xs

filter: Statementstmt 86.6% 26 / 30 Branchbran 43.7% 7 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 71.7% 33 / 46 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/B/Stats/Minus.pm ↑ Summary
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5  
6 /* CPAN #28912: MSWin32 and AIX as only platforms do not export PERL_CORE functions,
7 such as Perl_debop
8 so disable this feature. cygwin gcc-3 --export-all-symbols was non-strict, gcc-4 is.
9 POSIX with export PERL_DL_NONLAZY=1 also fails. This is checked in Makefile.PL
10 but cannot be solved for clients adding it.
11 */
12 #if !defined (DISABLE_PERL_CORE_EXPORTED) && \
13 (defined(WIN32) || \
14 defined(_MSC_VER) || defined(__MINGW32_VERSION) || \
15 (defined(__CYGWIN__) && (__GNUC__ > 3)) || defined(AIX))
16 # define DISABLE_PERL_CORE_EXPORTED
17 #endif
18 #if PERL_VERSION < 7
19 # define DEBUG_v(x) DEBUG_t(x)
20 #endif
21  
22 STATIC U32 opcount[MAXO];
23  
24 /* From B::C */
25 STATIC int
26 4464 my_runops(pTHX)
27 {
28 4464 int ignore = 0;
29 #if 0
30 /* ignore all ops from our subs */
31 HV* ign_stash = get_hv( "B::Stats::", 0 );
32 if (!CopSTASH_eq(PL_curcop, PL_debstash)) {
33 OP *o = PL_op;
34 HV *stash = NULL;
35 /* from Perl_debop */
36 switch (o->op_type) {
37 case OP_CONST:
38 /* With ITHREADS, consts are stored in the pad, and the right pad
39 * may not be active here, so check.
40 * Looks like only during compiling the pads are illegal.
41 */
42 #ifdef USE_ITHREADS
43 if ((((SVOP*)o)->op_sv) || !IN_PERL_COMPILETIME)
44 #endif
45 stash = GvSTASH(cSVOPo_sv);
46 break;
47 case OP_GVSV:
48 case OP_GV:
49 if (cGVOPo_gv) {
50 stash = GvSTASH(cGVOPo_gv);
51 }
52 break;
53 default:
54 break;
55 }
56 ignore = stash == ign_stash;
57 }
58 #endif
59  
60 DEBUG_v(Perl_deb(aTHX_ "Entering new RUNOPS level (B::Stats)\n"));
61 do {
62 #if (PERL_VERSION < 13) || ((PERL_VERSION == 13) && (PERL_SUBVERSION < 2))
63 PERL_ASYNC_CHECK();
64 #endif
65 551936 ▶ if (PL_debug) {
Branch: 1 branch
BranchTrueFalseTotal
if (PL_debug) { 0 551936 551936
66 0 ▶ if (PL_watchaddr && (*PL_watchaddr != PL_watchok))
Branch: 2 branches
BranchTrueFalseTotal
if (PL_watchaddr && (*PL_watchaddr != PL_watchok)) 0 0 0
if (PL_watchaddr && (*PL_watchaddr != PL_watchok)) 0 0 0
67 0 PerlIO_printf(Perl_debug_log,
68 "WARNING: %"UVxf" changed from %"UVxf" to %"UVxf"\n",
69 PTR2UV(PL_watchaddr), PTR2UV(PL_watchok),
70 0 PTR2UV(*PL_watchaddr));
71 #if !defined(DISABLE_PERL_CORE_EXPORTED) && defined(DEBUGGING)
72 # if (PERL_VERSION > 7)
73 if (DEBUG_s_TEST_) debstack();
74 if (DEBUG_t_TEST_) debop(PL_op);
75 # else
76 DEBUG_s(debstack());
77 DEBUG_t(debop(PL_op));
78 # endif
79 #endif
80 }
81 551936 ▶ if (!ignore) {
Branch: 1 branch
BranchTrueFalseTotal
if (!ignore) { 551936 0 551936
82 551936 opcount[PL_op->op_type]++;
83 #if defined(DEBUGGING) && PERL_VERSION > 7
84 if (DEBUG_v_TEST_) {
85 # ifndef DISABLE_PERL_CORE_EXPORTED
86 debop(PL_op);
87 # endif
88 PerlIO_printf(Perl_debug_log, "Counted %d for %s\n",
89 opcount[PL_op->op_type]+1, PL_op_name[PL_op->op_type]);
90 }
91 #endif
92 }
93 551936 ▶ } while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX)));
Branch: 1 branch
BranchTrueFalseTotal
} while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX))); 547472 4440 551912
94 DEBUG_v(Perl_deb(aTHX_ "leaving RUNOPS level (B::Stats)\n"));
95  
96 4440 TAINT_NOT;
97 4440 return 0;
98 }
99  
100 void
101 14 reset_rcount() {
102 #if 1
103 14 memset(opcount, 0, sizeof(opcount));
104 #else
105 register int i;
106 for (i=0; i < MAXO; i++) {
107 opcount[i] = 0;
108 }
109 #endif
110 14 }
111 /* returns an SV ref to AV with caller now owning the SV ref */
112 SV *
113 6 rcount_all(pTHX) {
114 AV * av;
115 int i;
116 6 av = newAV();
117 2580 ▶ for (i=0; i < MAXO; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i < MAXO; i++) { 2574 6 2580
118 2574 av_store(av, i, newSViv(opcount[i]));
119 }
120 6 return newRV_noinc((SV*)av);
121 }
122  
123 MODULE = B::Stats PACKAGE = B::Stats
124  
125 PROTOTYPES: DISABLE
126  
127 U32
128 rcount(opcode)
129 IV opcode
130 CODE:
131 0 ▶ RETVAL = opcount[opcode];
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = opcount[opcode]; 0 0 0
132 OUTPUT:
133 RETVAL
134  
135 SV *
136 rcount_all()
137 C_ARGS:
138 aTHX
139  
140 void
141 reset_rcount()
142  
143 void
144 _xs_collect_env()
145 CODE:
146 /* walk stashes in C and store in %B_env before B is loaded,
147 to be able to detect if our testfunc loads B and its 14 deps itself.
148 */
149  
150 void
151 END(...)
152 PREINIT:
153 SV * sv;
154 PPCODE:
155 6 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 6 6
156 6 PUSHs(sv_2mortal(rcount_all(aTHX)));
157 6 PUTBACK;
158 6 call_pv("B::Stats::_end", G_VOID);
159 3 return; /* skip implicity PUTBACK */
160  
161 void
162 INIT(...)
163 PPCODE:
164 6 PUTBACK;
165 6 reset_rcount();
166 6 return; /* skip implicity PUTBACK */
167  
168 BOOT:
169 {
170 8 reset_rcount();
171 8 PL_runops = my_runops;
172 }
« blib/lib/B/Stats/Minus.pm ↑ Summary