LeakTrace.xs

filter: Statementstmt 97.5% 197 / 202 Branchbran 81.8% 149 / 182 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 90.1% 346 / 384 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Test/LeakTrace/Script.pm ↑ Summary
1 #define PERL_NO_GET_CONTEXT /* I want efficiency. */
2 #include <EXTERN.h>
3 #include <perl.h>
4 #define NO_XSLOCKS /* use exception handling macros */
5 #include <XSUB.h>
6  
7 #define NEED_newSVpvn_flags /* newSVpvs_flags depends on */
8 #include "ppport.h"
9  
10 #include "ptr_table.h"
11  
12 #ifndef SvIS_FREED
13 #define SvIS_FREED(sv) (SvFLAGS(sv) == SVTYPEMASK)
14 #endif
15  
16 #ifndef SvPADSTALE
17 #define SvPADSTALE(sv) (SvPADMY(sv) && SvREFCNT(sv) == 1)
18 #endif /* !SvPADSTALE */
19  
20 #define IS_STALE(sv) (SvIS_FREED(sv) || SvPADSTALE(sv))
21  
22 #define PteKey(pte) ((SV*)pte->oldval)
23 #define PteVal(pte) ((stateinfo*)pte->newval)
24  
25 #define REPORT_DISABLED 0x00
26 #define REPORT_ENABLED 0x01
27 #define REPORT_SV_DUMP 0x02
28 #define REPORT_SOURCE_LINES 0x04
29 #define REPORT_SILENT 0x08
30  
31 #define MY_CXT_KEY "Test::LeakTrace::_guts" XS_VERSION
32 typedef struct{
33 bool enabled;
34 bool need_stateinfo;
35  
36 char* file;
37 I32 filelen;
38 I32 line;
39  
40 PTR_TBL_t* usedsv_reg;
41 PTR_TBL_t* newsv_reg;
42  
43 } my_cxt_t;
44 START_MY_CXT;
45  
46 typedef struct stateinfo stateinfo;
47 struct stateinfo{
48 SV* sv;
49  
50 char* file;
51 I32 filelen;
52 I32 line;
53  
54 stateinfo* next;
55 };
56  
57 /* START_ARENA_VISIT and END_ARENA_VISIT macros are originated from S_visit() in sv.c.
58 They are used to scan the sv arena.
59 */
60 #define START_ARENA_VISIT STMT_START{ \
61 SV* sva; \
62 for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)){ \
63 const SV * const svend = &sva[SvREFCNT(sva)]; \
64 register SV* sv; \
65 for (sv = sva + 1; sv < svend; ++sv){ \
66 if (!IS_STALE(sv))
67  
68 #define END_ARENA_VISIT \
69 } /* end for(1) */ \
70 } /* end for(2) */ \
71 } STMT_END
72  
73  
74 /* START_PTR_TABLE_VISIT and END_PTR_TABLE_VISIT macros are originatred from ptr_table_clear() in sv.c */
75 #define START_PTR_TABLE_VISIT(tbl) STMT_START{ \
76 assert(tbl); \
77 if (tbl->tbl_items) { \
78 PTR_TBL_ENT_t * const * const array = tbl->tbl_ary; \
79 UV riter = tbl->tbl_max; \
80 do { \
81 register PTR_TBL_ENT_t *pte = array[riter]; \
82 while (pte) { \
83 STMT_START
84  
85 #define END_PTR_TABLE_VISIT \
86 STMT_END; \
87 pte = pte->next; \
88 } \
89 } while (riter--); \
90 } /* end if(ptr_table->tbl_items) */ \
91 } STMT_END
92  
93  
94 static UV
95 34 count_sv_in_arena(pTHX) {
96 34 UV count = 0;
97 2854334 ▶ START_ARENA_VISIT {
Branch: 4 branches
BranchTrueFalseTotal
START_ARENA_VISIT { 2830454 7056 2837510
START_ARENA_VISIT { 2499014 331440 2830454
START_ARENA_VISIT { 2837510 16790 2854300
START_ARENA_VISIT { 16790 34 16824
98 2499014 count++;
99 } END_ARENA_VISIT;
100 34 return count;
101 }
102  
103 #define ptr_table_free_val(tbl) my_ptr_table_free_val(aTHX_ tbl)
104 static void
105 29 my_ptr_table_free_val(pTHX_ PTR_TBL_t * const tbl){
106 15780 ▶ START_PTR_TABLE_VISIT(tbl) {
Branch: 2 branches
BranchTrueFalseTotal
START_PTR_TABLE_VISIT(tbl) { 29 0 29
START_PTR_TABLE_VISIT(tbl) { 932 14848 15780
107 932 Safefree(PteVal(pte)->file);
108 932 Safefree(pte->newval);
109 932 pte->newval = NULL;
110 15780 ▶ } END_PTR_TABLE_VISIT;
Branch: 1 branch
BranchTrueFalseTotal
} END_PTR_TABLE_VISIT; 14819 29 14848
111 29 }
112  
113  
114 static void
115 1221 set_stateinfo(pTHX_ pMY_CXT_ COP* const cop){
116 const char* file;
117 I32 filelen;
118  
119 assert(cop);
120  
121 1221 ▶ file = CopFILE(cop);
Branch: 1 branch
BranchTrueFalseTotal
file = CopFILE(cop); 1221 0 1221
122 assert(file);
123  
124 1221 filelen = strlen(file);
125 1221 ▶ if(filelen > MY_CXT.filelen) Renew(MY_CXT.file, filelen+1, char);
Branch: 1 branch
BranchTrueFalseTotal
if(filelen > MY_CXT.filelen) Renew(MY_CXT.file, filelen+1, char); 122 1099 1221
126 1221 Copy(file, MY_CXT.file, filelen+1, char);
127 1221 MY_CXT.filelen = filelen;
128  
129 1221 MY_CXT.line = (I32)CopLINE(cop);
130 1221 }
131  
132 static void
133 1257 unmark_all(pTHX_ pMY_CXT){
134 671152 ▶ START_PTR_TABLE_VISIT(MY_CXT.newsv_reg) {
Branch: 2 branches
BranchTrueFalseTotal
START_PTR_TABLE_VISIT(MY_CXT.newsv_reg) { 1140 117 1257
START_PTR_TABLE_VISIT(MY_CXT.newsv_reg) { 87355 583680 671035
135 87355 ▶ if(IS_STALE(PteKey(pte))){
Branch: 2 branches
BranchTrueFalseTotal
if(IS_STALE(PteKey(pte))){ 82295 5060 87355
if(IS_STALE(PteKey(pte))){ 16170 66125 82295
136 21230 PteVal(pte)->sv = NULL; /* unmark */
137 }
138 671035 ▶ } END_PTR_TABLE_VISIT;
Branch: 1 branch
BranchTrueFalseTotal
} END_PTR_TABLE_VISIT; 582540 1140 583680
139 1257 }
140  
141 static void
142 1257 mark_all(pTHX_ pMY_CXT){
143 assert(MY_CXT.usedsv_reg);
144 assert(MY_CXT.newsv_reg);
145  
146 1257 unmark_all(aTHX_ aMY_CXT);
147  
148 /* mark SVs as "new" with statement info */
149 105738027 ▶ START_ARENA_VISIT {
Branch: 4 branches
BranchTrueFalseTotal
START_ARENA_VISIT { 104886714 228075 105114789
START_ARENA_VISIT { 92616015 12270699 104886714
START_ARENA_VISIT { 105114789 621981 105736770
START_ARENA_VISIT { 621981 1257 623238
150 92616015 ▶ if(!ptr_table_fetch(MY_CXT.usedsv_reg, sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(!ptr_table_fetch(MY_CXT.usedsv_reg, sv)){ 67057 92548958 92616015
151 67057 stateinfo* si = (stateinfo*)ptr_table_fetch(MY_CXT.newsv_reg, sv);
152  
153 67057 ▶ if(si){
Branch: 1 branch
BranchTrueFalseTotal
if(si){ 66125 932 67057
154 66125 ▶ if(si->sv){
Branch: 1 branch
BranchTrueFalseTotal
if(si->sv){ 65791 334 66125
155 /* already marked */
156 65791 continue;
157 }
158 /* unmarked */
159 }
160 else{
161 /* not marked */
162 932 Newxz(si, 1, stateinfo);
163 932 ptr_table_store(MY_CXT.newsv_reg, sv, si);
164 }
165 /* sv_dump(sv); // */
166 1266 si->sv = sv; /* mark */
167  
168 1266 ▶ if(MY_CXT.need_stateinfo){
Branch: 1 branch
BranchTrueFalseTotal
if(MY_CXT.need_stateinfo){ 1218 48 1266
169 1218 ▶ if(MY_CXT.filelen > si->filelen) Renew(si->file, MY_CXT.filelen+1, char);
Branch: 1 branch
BranchTrueFalseTotal
if(MY_CXT.filelen > si->filelen) Renew(si->file, MY_CXT.filelen+1, char); 986 232 1218
170 1218 Copy(MY_CXT.file, si->file, MY_CXT.filelen+1, char);
171 1218 si->filelen = MY_CXT.filelen;
172 1218 si->line = MY_CXT.line;
173 }
174 }
175 } END_ARENA_VISIT;
176 1257 }
177  
178 static int
179 10995 leaktrace_runops(pTHX){
180 dVAR;
181 dMY_CXT;
182 10995 COP* last_cop = PL_curcop;
183  
184 89508952 ▶ while((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX))) {
Branch: 1 branch
BranchTrueFalseTotal
while((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX))) { 89497957 10776 89508733
185 89497957 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 89497957 89497957
186  
187 89497957 ▶ if(!MY_CXT.need_stateinfo) continue;
Branch: 1 branch
BranchTrueFalseTotal
if(!MY_CXT.need_stateinfo) continue; 89492507 5450 89497957
188  
189 #if 0
190 PerlIO_printf(Perl_debug_log, "#run [%s] %s %d\n",
191 OP_NAME(PL_op),
192 CopFILE(PL_curcop),
193 (int)CopLINE(PL_curcop));
194 #endif
195  
196 5450 ▶ if(last_cop != PL_curcop){
Branch: 1 branch
BranchTrueFalseTotal
if(last_cop != PL_curcop){ 1208 4242 5450
197 1208 mark_all(aTHX_ aMY_CXT);
198 1208 last_cop = PL_curcop;
199 1208 set_stateinfo(aTHX_ aMY_CXT_ last_cop);
200 }
201 }
202  
203 10776 ▶ if(MY_CXT.enabled){
Branch: 1 branch
BranchTrueFalseTotal
if(MY_CXT.enabled){ 20 10756 10776
204 20 mark_all(aTHX_ aMY_CXT);
205 }
206  
207 10776 TAINT_NOT;
208 10776 return 0;
209 }
210  
211  
212 static stateinfo*
213 29 make_leakedsv_list(pTHX_ pMY_CXT_ IV* const countp){
214 29 stateinfo* leaked = NULL;
215 29 IV count = 0;
216  
217  
218 2437999 ▶ START_ARENA_VISIT{
Branch: 4 branches
BranchTrueFalseTotal
START_ARENA_VISIT{ 2418265 5364 2423629
START_ARENA_VISIT{ 2135065 283200 2418265
START_ARENA_VISIT{ 2423629 14341 2437970
START_ARENA_VISIT{ 14341 29 14370
219 2135065 stateinfo* const si = (stateinfo*)ptr_table_fetch(MY_CXT.newsv_reg, sv);
220  
221 2135065 ▶ if(si && si->sv){
Branch: 2 branches
BranchTrueFalseTotal
if(si && si->sv){ 403 2134662 2135065
if(si && si->sv){ 403 0 403
222 403 count++;
223 403 si->next = leaked; /* make a link */
224 403 leaked = si;
225 }
226 } END_ARENA_VISIT;
227  
228 29 *countp = count;
229  
230 29 return leaked;
231 }
232  
233 static void
234 5 callback_each_leaked(pTHX_ stateinfo* leaked, SV* const callback){
235 26 ▶ while(leaked){
Branch: 1 branch
BranchTrueFalseTotal
while(leaked){ 24 2 26
236 24 dSP;
237 I32 n;
238  
239 24 ▶ if(IS_STALE(leaked->sv)){ /* NOTE: it is possible when the callback releases some SVs. */
Branch: 2 branches
BranchTrueFalseTotal
if(IS_STALE(leaked->sv)){ /* NOTE: it is possible when the callback releases some SVs. */ 24 0 24
if(IS_STALE(leaked->sv)){ /* NOTE: it is possible when the callback releases some SVs. */ 0 24 24
240 0 leaked = leaked->next;
241 0 continue;
242 }
243  
244 24 ENTER;
245 24 SAVETMPS;
246  
247 24 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 24 24
248  
249 24 ▶ EXTEND(SP, 3);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 3); 0 24 24
250 24 ▶ mXPUSHs(newRV_inc(leaked->sv));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_inc(leaked->sv)); 0 24 24
251  
252 24 mPUSHp(leaked->file, leaked->filelen); /* can be empty */
253 24 mPUSHi(leaked->line); /* can be zero */
254  
255 24 PUTBACK;
256  
257 24 n = call_sv(callback, G_VOID);
258  
259 21 SPAGAIN;
260 21 ▶ while(n--) (void)POPs;
Branch: 1 branch
BranchTrueFalseTotal
while(n--) (void)POPs; 0 21 21
261 21 PUTBACK;
262  
263 21 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 21 0 21
264 21 LEAVE;
265  
266 21 leaked = leaked->next;
267 }
268 2 }
269  
270 static void
271 22 print_lines_around(pTHX_ PerlIO* const ofp, const char* const file, I32 const lineno){
272 22 PerlIO* const ifp = PerlIO_open(file, "r");
273 22 ▶ SV* const sv = DEFSV;
Branch: 1 branch
BranchTrueFalseTotal
SV* const sv = DEFSV; 22 0 22
274 22 int i = 0;
275 22 ▶ if(ifp){
Branch: 1 branch
BranchTrueFalseTotal
if(ifp){ 22 0 22
276 928 ▶ while(sv_gets(sv, ifp, FALSE)){
Branch: 1 branch
BranchTrueFalseTotal
while(sv_gets(sv, ifp, FALSE)){ 928 0 928
277 928 i++;
278  
279 928 ▶ if( i >= (lineno-1) ){
Branch: 1 branch
BranchTrueFalseTotal
if( i >= (lineno-1) ){ 66 862 928
280 66 PerlIO_printf(ofp, "%4d:%"SVf, (int)i, sv);
281  
282 66 ▶ if( i >= (lineno+1) ){
Branch: 1 branch
BranchTrueFalseTotal
if( i >= (lineno+1) ){ 22 44 66
283 22 break;
284 }
285 }
286 }
287 22 PerlIO_close(ifp);
288 }
289 22 }
290  
291 static void
292 8 report_each_leaked(pTHX_ stateinfo* leaked, int const reporting_mode){
293 8 ▶ PerlIO* const logfp = Perl_error_log;
Branch: 4 branches
BranchTrueFalseTotal
PerlIO* const logfp = Perl_error_log; 8 0 8
PerlIO* const logfp = Perl_error_log; 8 0 8
PerlIO* const logfp = Perl_error_log; 8 0 8
PerlIO* const logfp = Perl_error_log; 8 0 8
294  
295 8 ▶ if(reporting_mode & REPORT_SOURCE_LINES){
Branch: 1 branch
BranchTrueFalseTotal
if(reporting_mode & REPORT_SOURCE_LINES){ 5 3 8
296 5 ENTER;
297 5 SAVETMPS;
298  
299 /*
300 local $/ = "\n"
301 local $_;
302 */
303 5 SAVESPTR(PL_rs);
304 5 SAVE_DEFSV;
305  
306 5 PL_rs = newSVpvs_flags("\n", SVs_TEMP);
307 5 ▶ DEFSV = sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
DEFSV = sv_newmortal(); 5 0 5
308 }
309  
310 116 ▶ while(leaked){
Branch: 1 branch
BranchTrueFalseTotal
while(leaked){ 108 8 116
311 assert(!IS_STALE(leaked->sv));
312  
313 108 ▶ if(leaked->filelen){
Branch: 1 branch
BranchTrueFalseTotal
if(leaked->filelen){ 108 0 108
314 108 PerlIO_printf(logfp, "leaked %s(0x%p) from %s line %d.\n",
315 108 sv_reftype(leaked->sv, FALSE),
316 leaked->sv,
317 108 leaked->file, (int)leaked->line);
318  
319 108 ▶ if(leaked->line && (reporting_mode & REPORT_SOURCE_LINES)){
Branch: 2 branches
BranchTrueFalseTotal
if(leaked->line && (reporting_mode & REPORT_SOURCE_LINES)){ 108 0 108
if(leaked->line && (reporting_mode & REPORT_SOURCE_LINES)){ 22 86 108
320 22 print_lines_around(aTHX_ logfp, leaked->file, leaked->line);
321 }
322 }
323  
324 108 ▶ if(reporting_mode & REPORT_SV_DUMP){
Branch: 1 branch
BranchTrueFalseTotal
if(reporting_mode & REPORT_SV_DUMP){ 22 86 108
325 22 do_sv_dump(
326 0, /* level */
327 logfp,
328 leaked->sv,
329 0, /* nest */
330 4, /* maxnest */
331 FALSE, /* dumpops */
332 0 /* pvlim */
333 );
334 }
335 108 leaked = leaked->next;
336 }
337  
338 8 ▶ if(reporting_mode & REPORT_SOURCE_LINES){
Branch: 1 branch
BranchTrueFalseTotal
if(reporting_mode & REPORT_SOURCE_LINES){ 5 3 8
339 5 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 5 0 5
340 5 LEAVE;
341 }
342 8 }
343  
344  
345 MODULE = Test::LeakTrace PACKAGE = Test::LeakTrace
346  
347 PROTOTYPES: DISABLE
348  
349 BOOT:
350 {
351 MY_CXT_INIT;
352 13 set_stateinfo(aTHX_ aMY_CXT_ PL_curcop); /* only to prevent core dumps with Devel::Cover */
353 13 PL_runops = leaktrace_runops;
354 }
355  
356 void
357 CLONE(...)
358 CODE:
359 MY_CXT_CLONE;
360 0 Zero(&MY_CXT, 1, my_cxt_t);
361 PERL_UNUSED_VAR(items);
362  
363 void
364 END(...)
365 CODE:
366 dMY_CXT;
367 // release resources for valgrind
368 13 Safefree(MY_CXT.file);
369 13 MY_CXT.file = NULL;
370 PERL_UNUSED_VAR(items);
371  
372 void
373 _start(bool need_stateinfo)
374 PREINIT:
375 dMY_CXT;
376 CODE:
377 31 ▶ if(MY_CXT.enabled){
Branch: 1 branch
BranchTrueFalseTotal
if(MY_CXT.enabled){ 2 29 31
378 2 Perl_croak(aTHX_ "Cannot start LeakTrace inside its scope");
379 }
380  
381 assert(MY_CXT.usedsv_reg == NULL);
382 assert(MY_CXT.newsv_reg == NULL);
383  
384 29 MY_CXT.enabled = TRUE;
385 29 MY_CXT.need_stateinfo = need_stateinfo;
386 29 MY_CXT.usedsv_reg = ptr_table_new();
387 29 MY_CXT.newsv_reg = ptr_table_new();
388  
389 2437999 ▶ START_ARENA_VISIT{
Branch: 4 branches
BranchTrueFalseTotal
START_ARENA_VISIT{ 2417825 5804 2423629
START_ARENA_VISIT{ 2134672 283153 2417825
START_ARENA_VISIT{ 2423629 14341 2437970
START_ARENA_VISIT{ 14341 29 14370
390 /* mark as "used" */
391 2134672 ptr_table_store(MY_CXT.usedsv_reg, sv, sv);
392 } END_ARENA_VISIT;
393  
394  
395 void
396 _finish(SV* mode = &PL_sv_undef)
397 PREINIT:
398 dMY_CXT;
399 29 I32 const gimme = GIMME_V;
400 29 int reporting_mode = REPORT_DISABLED;
401 IV count;
402 /* volatile to pass -Wuninitialized (longjmp) */
403 stateinfo* volatile leaked;
404 29 SV* volatile callback = NULL;
405 29 ▶ SV* volatile invalid_mode = NULL;
Branch: 1 branch
BranchTrueFalseTotal
SV* volatile invalid_mode = NULL; 0 29 29
406 PPCODE:
407 29 ▶ if(!MY_CXT.enabled){
Branch: 1 branch
BranchTrueFalseTotal
if(!MY_CXT.enabled){ 0 29 29
408 0 Perl_warn(aTHX_ "LeakTrace not started");
409 0 XSRETURN_EMPTY;
410 }
411  
412 29 ▶ if(SvOK(mode)){
Branch: 1 branch
BranchTrueFalseTotal
if(SvOK(mode)){ 18 11 29
413 18 ▶ if(SvROK(mode) && SvTYPE(SvRV(mode)) == SVt_PVCV){
Branch: 2 branches
BranchTrueFalseTotal
if(SvROK(mode) && SvTYPE(SvRV(mode)) == SVt_PVCV){ 5 13 18
if(SvROK(mode) && SvTYPE(SvRV(mode)) == SVt_PVCV){ 5 0 5
414 5 reporting_mode = REPORT_ENABLED;
415 5 callback = mode;
416 }
417 else{
418 13 const char* const modepv = SvPV_nolen_const(mode);
419  
420 13 ▶ if(strEQ(modepv, "-simple")){
Branch: 1 branch
BranchTrueFalseTotal
if(strEQ(modepv, "-simple")){ 2 11 13
421 2 reporting_mode = REPORT_ENABLED;
422 }
423 11 ▶ else if(strEQ(modepv, "-sv_dump")){
Branch: 1 branch
BranchTrueFalseTotal
else if(strEQ(modepv, "-sv_dump")){ 1 10 11
424 1 reporting_mode = REPORT_SV_DUMP;
425 }
426 10 ▶ else if(strEQ(modepv, "-lines")){
Branch: 1 branch
BranchTrueFalseTotal
else if(strEQ(modepv, "-lines")){ 1 9 10
427 1 reporting_mode = REPORT_SOURCE_LINES;
428 }
429 9 ▶ else if(strEQ(modepv, "-verbose")){
Branch: 1 branch
BranchTrueFalseTotal
else if(strEQ(modepv, "-verbose")){ 4 5 9
430 4 reporting_mode = REPORT_SV_DUMP | REPORT_SOURCE_LINES;
431 }
432 5 ▶ else if(strEQ(modepv, "-silent")){
Branch: 1 branch
BranchTrueFalseTotal
else if(strEQ(modepv, "-silent")){ 3 2 5
433 3 reporting_mode = REPORT_SILENT;
434 }
435 else{
436 2 reporting_mode = REPORT_SILENT;
437 2 invalid_mode = mode;
438 }
439 }
440 }
441 assert(MY_CXT.usedsv_reg);
442 assert(MY_CXT.newsv_reg);
443  
444 29 mark_all(aTHX_ aMY_CXT);
445  
446 29 MY_CXT.enabled = FALSE;
447 29 MY_CXT.need_stateinfo = FALSE;
448  
449 29 leaked = make_leakedsv_list(aTHX_ aMY_CXT_ &count);
450  
451 29 ptr_table_free(MY_CXT.usedsv_reg);
452 29 MY_CXT.usedsv_reg = NULL;
453  
454 29 ▶ if(reporting_mode){
Branch: 1 branch
BranchTrueFalseTotal
if(reporting_mode){ 18 11 29
455 18 ▶ if(callback){
Branch: 1 branch
BranchTrueFalseTotal
if(callback){ 5 13 18
456 5 dXCPT;
457 5 ▶ XCPT_TRY_START {
Branch: 1 branch
BranchTrueFalseTotal
XCPT_TRY_START { 5 3 8
458 5 callback_each_leaked(aTHX_ leaked, callback);
459 5 } XCPT_TRY_END
460  
461 5 ▶ XCPT_CATCH {
Branch: 1 branch
BranchTrueFalseTotal
XCPT_CATCH { 3 2 5
462 3 ptr_table_free_val(MY_CXT.newsv_reg);
463 3 ptr_table_free(MY_CXT.newsv_reg);
464 3 MY_CXT.newsv_reg = NULL;
465  
466 3 ▶ XCPT_RETHROW;
Branch: 2 branches
BranchTrueFalseTotal
XCPT_RETHROW; 3 0 3
XCPT_RETHROW; 0 0 0
467 }
468 }
469 13 ▶ else if(!(reporting_mode & REPORT_SILENT)){
Branch: 1 branch
BranchTrueFalseTotal
else if(!(reporting_mode & REPORT_SILENT)){ 8 5 13
470 8 report_each_leaked(aTHX_ leaked, reporting_mode);
471 }
472 }
473 11 ▶ else if(gimme == G_SCALAR){
Branch: 1 branch
BranchTrueFalseTotal
else if(gimme == G_SCALAR){ 2 9 11
474 2 ▶ mXPUSHi(count);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi(count); 0 2 2
475 }
476 9 ▶ else if(gimme == G_ARRAY){
Branch: 1 branch
BranchTrueFalseTotal
else if(gimme == G_ARRAY){ 9 0 9
477 9 ▶ EXTEND(SP, count);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, count); 9 0 9
EXTEND(SP, count); 0 9 9
478 220 ▶ while(leaked){
Branch: 1 branch
BranchTrueFalseTotal
while(leaked){ 211 9 220
479 211 SV* sv = newRV_inc(leaked->sv);
480  
481 211 ▶ if(leaked->filelen){
Branch: 1 branch
BranchTrueFalseTotal
if(leaked->filelen){ 198 13 211
482 198 AV* const av = newAV();
483  
484 198 av_push(av, sv);
485 198 av_push(av, newSVpvn(leaked->file, leaked->filelen));
486 198 av_push(av, newSViv(leaked->line));
487 198 sv = newRV_noinc((SV*)av);
488 }
489 211 mPUSHs(sv);
490  
491 211 leaked = leaked->next;
492 }
493 }
494  
495 26 ptr_table_free_val(MY_CXT.newsv_reg);
496 26 ptr_table_free(MY_CXT.newsv_reg);
497 26 MY_CXT.newsv_reg = NULL;
498  
499 26 ▶ if(invalid_mode){
Branch: 1 branch
BranchTrueFalseTotal
if(invalid_mode){ 2 24 26
500 2 Perl_croak(aTHX_ "Invalid reporting mode: %"SVf, invalid_mode);
501 }
502  
503 bool
504 _runops_installed()
505 CODE:
506 12 ▶ RETVAL = (PL_runops == leaktrace_runops);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (PL_runops == leaktrace_runops); 12 0 12
507 OUTPUT:
508 RETVAL
509  
510 UV
511 count_sv()
512 CODE:
513 34 RETVAL = count_sv_in_arena(aTHX);
514 OUTPUT:
515 RETVAL
« blib/lib/Test/LeakTrace/Script.pm ↑ Summary