blib/lib/Apache/DB.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 63 CC 4 SCAR 13.9
CC
4
Cov
0%
BEGIN
6.0
init
6.0
handler
6.0
CRAP 4.0
1 package # hide the package from the PAUSE indexer
2 Apache::DB;
3  
4 use 5.005;
5 use strict;
6 use DynaLoader ();
7  
8 BEGIN {
9 use constant MP2 => eval {
10 exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2
11 };
12 die "mod_perl is required to run this module: $@" if $@;
13 }
14  
15 {
16 no strict;
17 @ISA = qw(DynaLoader);
18 $VERSION = '0.18';
19 __PACKAGE__->bootstrap($VERSION);
20 }
21  
22 $Apache::Registry::MarkLine = 0;
23  
24 sub init {
25 if(init_debugger()) {
26 warn "[notice] Apache::DB initialized in child $$\n";
27 }
28  
29 1;
30 }
31  
32 use Data::Dumper;
33 sub handler {
34 my $r = shift;
35  
36 init();
37  
38 {
39 local $@;
40 my $loaded_db;
41  
42 if ($ENV{PERL5DB}) {
43 (my $directive = $ENV{PERL5DB})
44 =~ s/^\s*BEGIN\s*{\s*(.*)\s*}\z/$1/s;
45 $directive =~ s/^require\b/do/;
46 $loaded_db = eval($directive);
47 }
48 }
49  
50 $DB::state[0]{single} = !$DB::options{ NonStop };
51 warn "Debugger state " .Dumper \@DB::state;
52 warn "Debugger options " .Dumper \%DB::options;
53 return 0;
54 }
55  
56 1;
57 __END__
58  
59 =head1 NAME
60  
61 Apache::DB - Run the interactive Perl debugger under mod_perl
62  
63 =head1 SYNOPSIS
64  
65 <Location /perl>
66 PerlFixupHandler +Apache::DB
67  
68 SetHandler perl-script
69 PerlHandler +Apache::Registry
70 Options +ExecCGI
71 </Location>
72  
73 =head1 DESCRIPTION
74  
75 Perl ships with a very useful interactive debugger, however, it does not run
76 "out-of-the-box" in the Apache/mod_perl environment. Apache::DB makes a few
77 adjustments so the two will cooperate.
78  
79 =head1 FUNCTIONS
80  
81 =over 4
82  
83 =item init
84  
85 This function initializes the Perl debugger hooks without actually
86 starting the interactive debugger. In order to debug a certain piece
87 of code, this function must be called before the code you wish debug
88 is compiled. For example, if you want to insert debugging symbols
89 into code that is compiled at server startup, but do not care to debug
90 until request time, call this function from a PerlRequire'd file:
91  
92 #where db.pl is simply:
93 # use Apache::DB ();
94 # Apache::DB->init;
95 PerlRequire conf/db.pl
96  
97 #where modules are loaded
98 PerlRequire conf/init.pl
99  
100 If you are using mod_perl 2.0 you will need to use the following
101 as your db.pl:
102  
103 use APR::Pool ();
104 use Apache::DB ();
105 Apache::DB->init();
106  
107 =item handler
108  
109 This function will start the interactive debugger. It will invoke
110 I<Apache::DB::init> if needed. Example configuration:
111  
112 <Location /my-handler>
113 PerlFixupHandler Apache::DB
114 SetHandler perl-script
115 PerlHandler My::handler
116 </Location>
117  
118 =back
119  
120 =head1 SELinux
121  
122 Security-enhanced Linux (SELinux) is a mandatory access control system
123 many linux distrobutions are implementing. This new security scheme
124 can assist you with protecting a server, but it doesn't come without
125 its own set of issues. Debugging applications running on a box with
126 SELinux on it takes a couple of extra steps and unfortunately the
127 instructions that follow have only been tested on RedHat/Fedora.
128  
129 1) You need to edit/create the file "local.te" and add the following:
130  
131 if (httpd_tty_comm) {
132 allow { httpd_t } admin_tty_type:chr_file { ioctl getattr }; }
133  
134 2) Reload your security policy.
135  
136 3) Run the command "setsebool httpd_tty_comm true".
137  
138 You should be aware as you debug applications on a system with SELinux
139 your code may very well be correct, but the system policy is denying your
140 actions.
141  
142 =head1 CAVEATS
143  
144 =over 4
145  
146 =item -X
147  
148 The server must be started with the C<-X> to use Apache::DB.
149  
150 =item filename/line info
151  
152 The filename of Apache::Registry scripts is not displayed.
153  
154 =back
155  
156 =head1 SEE ALSO
157  
158 perldebug(1)
159  
160 =head1 AUTHOR
161  
162 Originally written by Doug MacEachern
163  
164 Currently maintained by Dirk Lindner <lze@cpan.org>
165  
166  
167 =head1 LICENSE
168  
169 This module is distributed under the same terms as Perl itself.
170