File Coverage

blib/lib/Devel/bt.pm
Criterion Covered Total %
statement 17 23 73.9
branch 0 4 0.0
condition 0 3 0.0
subroutine 7 9 77.7
pod 0 2 0.0
total 24 41 58.5


line stmt bran cond sub pod time code
1 1     1   34608 use strict;
  1         3  
  1         37  
2 1     1   5 use warnings;
  1         1  
  1         56  
3              
4             package Devel::bt;
5             BEGIN {
6 1     1   32 $Devel::bt::AUTHORITY = 'cpan:FLORA';
7             }
8             {
9             $Devel::bt::VERSION = '0.06';
10             }
11             # ABSTRACT: Automatic gdb backtraces on errors
12              
13              
14 1     1   10 use XSLoader;
  1         2  
  1         28  
15 1     1   5 use Carp 'croak';
  1         2  
  1         48  
16 1     1   876 use File::Which 'which';
  1         1062  
  1         187  
17              
18             XSLoader::load(
19             __PACKAGE__,
20             # we need to be careful not to touch $VERSION at compile time, otherwise
21             # DynaLoader will assume it's set and check against it, which will cause
22             # fail when being run in the checkout without dzil having set the actual
23             # $VERSION
24             exists $Devel::bt::{VERSION} ? ${ $Devel::bt::{VERSION} } : (),
25             );
26              
27 0     0 0 0 sub DB::DB { }
28              
29 1     1 0 12 sub find_gdb { which 'gdb' }
30              
31             sub import {
32 0     0     my ($class, %args) = @_;
33              
34 0 0         my $gdb = exists $args{gdb} ? $args{gdb} : $class->find_gdb();
35 0 0 0       croak 'Unable to locate gdb binary'
36             unless defined $gdb && -x $gdb;
37              
38 0           register_segv_handler($gdb, $^X);
39 0           return;
40             }
41              
42             1;
43              
44             __END__