| 1 | # vim: ts=8 sw=4 expandtab: | ||||||||||||||||||||||||||||||||
| 2 | ########################################################## | ||||||||||||||||||||||||||||||||
| 3 | # This script is part of the Devel::NYTProf distribution | ||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||
| 5 | # Copyright, contact and other information can be found | ||||||||||||||||||||||||||||||||
| 6 | # at the bottom of this file, or by going to: | ||||||||||||||||||||||||||||||||
| 7 | # http://metacpan.org/release/Devel-NYTProf/ | ||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||
| 9 | ########################################################### | ||||||||||||||||||||||||||||||||
| 10 | package Devel::NYTProf::Core; | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 706 | ▶ | use XSLoader; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 706 | our $VERSION = '6.16'; # increment with XS changes too | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 705 | XSLoader::load('Devel::NYTProf', $VERSION); | |||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | # Fudging for https://rt.cpan.org/Ticket/Display.html?id=82256 | ||||||||||||||||||||||||||||||||
| 20 | 705 | ▶ | $Devel::NYTProf::StrEvalTestPad = ($] <= 5.017004) ? ";\n" : ""; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 705 | ▶ | if (my $NYTPROF = $ENV{NYTPROF}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 23 | 654 | for my $optval ( $NYTPROF =~ /((?:[^\\:]+|\\.)+)/g) { | |||||||||||||||||||||||||||||||
| 24 | 5872 | my ($opt, $val) = $optval =~ /^((?:[^\\=]+|\\.)+)=((?:[^\\=]+|\\.)+)\z/; | |||||||||||||||||||||||||||||||
| 25 | 5872 | s/\\(.)/$1/g for $opt, $val; | |||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 5872 | ▶ | if ($opt eq 'sigexit') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 28 | # Intercept sudden process exit caused by signals | ||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my @sigs = ($val eq '1') ? qw(INT HUP PIPE BUS SEGV) : split(/,/, $val); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $SIG{uc $_} = sub { DB::finish_profile(); exit 1; } for @sigs; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||
| 31 | 0 | next; # no need to tell the XS code about this | |||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 5872 | ▶ | if ($opt eq 'posix_exit') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 35 | # Intercept sudden process exit caused by POSIX::_exit() call. | ||||||||||||||||||||||||||||||||
| 36 | # Should only be needed if subs=0. We delay till after profiling | ||||||||||||||||||||||||||||||||
| 37 | # has probably started to minimize the effect on the profile. | ||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | eval q{ INIT { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$val && (eval " INIT {\n require POSIX;\n my \$orig = \\&POSIX::_exit;\n local \$^W = 0; # avoid sub redef warning\n *POSIX::_exit = sub { DB::finish_profile(); \$orig->(\@_) };\n } 1 " || die())
eval " INIT {\n require POSIX;\n my \$orig = \\&POSIX::_exit;\n local \$^W = 0; # avoid sub redef warning\n *POSIX::_exit = sub { DB::finish_profile(); \$orig->(\@_) };\n } 1 " or die
MC/DC0%0/2
$val && (eval " INIT {\n require POSIX;\n my \$orig = \\&POSIX::_exit;\n local \$^W = 0; # avoid sub redef warning\n *POSIX::_exit = sub { DB::finish_profile(); \$orig->(\@_) };\n } 1 " || die())
$val
eval " INIT {\n require POSIX;\n my \$orig = \\&POSIX::_exit;\n local \$^W = 0; # avoid sub redef warning\n *POSIX::_exit = sub { DB::finish_profile(); \$orig->(\@_) };\n } 1 "
Truth table0%0/3
A && B
A= $valB= eval " INIT {\n require POSIX;\n my \$orig = \\&POSIX::_exit;\n local \$^W = 0; # avoid sub redef warning\n *POSIX::_exit = sub { DB::finish_profile(); \$orig->(\@_) };\n } 1 "
| |||||||||||||||||||||||||||||||||
| 39 | require POSIX; | ||||||||||||||||||||||||||||||||
| 40 | my $orig = \&POSIX::_exit; | ||||||||||||||||||||||||||||||||
| 41 | local $^W = 0; # avoid sub redef warning | ||||||||||||||||||||||||||||||||
| 42 | *POSIX::_exit = sub { DB::finish_profile(); $orig->(@_) }; | ||||||||||||||||||||||||||||||||
| 43 | } 1 } or die if $val; | ||||||||||||||||||||||||||||||||
| 44 | 0 | next; # no need to tell the XS code about this | |||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 5872 | DB::set_option($opt, $val); | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 705 | 1; | |||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||||||