blib/lib/Devel/DebugHooks/TraceCall.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 16 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 46 CC 2 SCAR 12.8
CC
2
Cov
0%
log_call
6.0
BEGIN
2.0
import
2.0
CRAP 3.6
1 package Devel::DebugHooks::TraceCall;
2  
3 our @ISA;
4  
5 BEGIN {
6 @DB::options{ qw/ w s / } = ( 1, 1 );
7 push @ISA, 'Devel::DebugHooks';
8 }
9  
10  
11  
12 sub import {
13 my $class = shift;
14  
15 $class->SUPER::import( @_ );
16 }
17  
18  
19 my $flow_fh;
20 sub log_call {
21 $flow_fh or open $flow_fh, '>dbg_flow.txt';
22  
23 my( $from, $to ) = @{ DB::state( 'stack' ) }[ -2, -1 ];
24  
25 my $extra = '';
26 $extra = "$to->{ file }:$to->{ line }:" if $to->{ sub } =~ /^CODE/;
27  
28 $from = $from &&( $from->{ sub } // $from->{ package }.'::' ) // '';
29 $to = $to && $to->{ sub } // '';
30 print $flow_fh "$from -> $extra$to\n";
31  
32  
33 1;
34 }
35  
36  
37  
38 use Devel::DebugHooks();
39  
40  
41  
42 my $handler = DB::reg( 'call', 'TraceCall' );
43 $$handler->{ context } = $DB::dbg;
44 $$handler->{ code } = \&log_call;
45  
46  
47 1;