| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# $Id: $ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
=head1 Name |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Acme::Debug - A handy module to identify lines of code where bugs may be found. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Acme::Debug; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
23819
|
use 5.008000; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
57
|
|
|
13
|
1
|
|
|
1
|
|
1114
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
9747
|
|
|
|
1
|
|
|
|
|
64
|
|
|
14
|
1
|
|
|
1
|
|
8
|
use File::Spec; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
17
|
|
|
15
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
34
|
|
|
16
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
97
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
748
|
|
|
19
|
|
|
|
|
|
|
$VERSION = do { my @r = (q$Revision: 1.48 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 Usage |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=over 4 |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=item perl -d -MAcme::Debug program args |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This will report only those lines of code which are buggy as the program |
|
28
|
|
|
|
|
|
|
actually executes. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=back |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Output goes to C so if you program produces much output on C |
|
33
|
|
|
|
|
|
|
for instance, you might wish to put it somewhere else: |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
perl -d -MAcme::Debug program args 1> /dev/null |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
require Exporter; |
|
40
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
41
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); # use Acme::Debug ':all'; |
|
42
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
43
|
|
|
|
|
|
|
our @EXPORT = qw( ); |
|
44
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $debug = $ENV{Acme_Debug_DEBUG} || 0; |
|
47
|
|
|
|
|
|
|
my $silent = $ENV{Acme_Debug_SILENT} || 0; |
|
48
|
|
|
|
|
|
|
my $verbose = $ENV{Acme_Debug_VERBOSE} || 0; |
|
49
|
|
|
|
|
|
|
my $bug = $ENV{Acme_Debug_REGEX} || 'b[^u]*u[^g]*g'; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# sub acme_debug = \&DB::DB; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 Environment Variables |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
These boolean variables may be set to divulge more information. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item Acme_Debug_DUMP |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Print the actual buggy lines. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#=item perl -MAcme::Debug -e 'Acme::Debug->new("program")'; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#This will parse every line of the files/s given. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub new { |
|
74
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
|
75
|
0
|
0
|
|
|
|
|
my $class = ref($proto) ? ref($proto) : $proto; |
|
76
|
0
|
|
|
|
|
|
my $self = {}; |
|
77
|
0
|
|
|
|
|
|
bless($self, $class); |
|
78
|
0
|
|
|
|
|
|
foreach my $f (@_) { |
|
79
|
0
|
0
|
|
|
|
|
next unless -f $f; |
|
80
|
0
|
|
|
|
|
|
my $l = 0; |
|
81
|
0
|
0
|
|
|
|
|
if (open(FH, "< $f")) { |
|
82
|
0
|
|
|
|
|
|
map { DB::DB($f, $l, $_), $l++ } (); |
|
|
0
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} else { |
|
84
|
0
|
|
|
|
|
|
die("unable to open file $f! $!\n"); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
|
|
|
|
|
return $self; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
package DB; |
|
93
|
1
|
|
|
1
|
|
5
|
no strict qw(refs); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
94
|
1
|
|
|
1
|
|
3
|
no warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
343
|
|
|
95
|
|
|
|
|
|
|
my $i = my $i_bugs = 0; |
|
96
|
|
|
|
|
|
|
my @bugs = (); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub DB::DB { |
|
99
|
0
|
|
|
0
|
0
|
|
$i++; |
|
100
|
0
|
|
|
|
|
|
my ($p,$f,$l) = caller; |
|
101
|
0
|
0
|
|
|
|
|
if ($f =~ /Acme.Debug.pm/) { |
|
102
|
0
|
|
|
|
|
|
$f = shift; |
|
103
|
0
|
|
|
|
|
|
$l = shift; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
0
|
|
0
|
|
|
|
my $line = @{"::_<$f"}[$l] || shift; |
|
106
|
0
|
|
|
|
|
|
my ($v, $d, $x) = File::Spec->splitpath($f); |
|
107
|
|
|
|
|
|
|
# if ($line =~ /b[^u]*u[^g]*g/mi) { |
|
108
|
0
|
0
|
|
|
|
|
if ($line =~ /$bug/mi) { |
|
109
|
0
|
|
|
|
|
|
$i_bugs++; |
|
110
|
0
|
0
|
|
|
|
|
unless ($f =~ /perl5db.pl/) { |
|
111
|
0
|
0
|
|
|
|
|
push(@bugs, ($debug?"[$i]":'')." line $l of $x: $line"); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub END { |
|
117
|
1
|
|
|
1
|
|
4
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
126
|
|
|
118
|
1
|
|
|
1
|
|
47
|
print STDERR "bug free lines: ".($i-$i_bugs)."\n"; |
|
119
|
1
|
|
|
|
|
8
|
print STDERR "BUGgy code lines: $i_bugs\n"; |
|
120
|
1
|
50
|
|
|
|
11
|
print STDERR @bugs if $verbose; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHOR |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Richard Foley, Eacme.debug@rfi.net |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright (C) 2004 by Richard Foley |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
134
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
|
135
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |