File Coverage

blib/lib/Devel/Debug/DBGp.pm
Criterion Covered Total %
statement 6 9 66.6
branch 0 2 0.0
condition n/a
subroutine 2 3 66.6
pod 0 1 0.0
total 8 15 53.3


line stmt bran cond sub pod time code
1             package Devel::Debug::DBGp;
2              
3             =head1 NAME
4              
5             Devel::Debug::DBGp - Perl DBGp debugger (derived from Komodo remote debugging helper)
6              
7             =head1 SYNOPSIS
8              
9             From the command line:
10              
11             DBGP_OPTS="RemotePort=localhost:9000" perl -I/path/to/lib/dbgp-helper -d myscript.pl
12              
13             From an helper module:
14              
15             unshift @INC, Devel::Debug::DBGp->debugger_path;
16             $ENV{DBGP_OPTS} = "RemotePort=localhost:9000";
17             require 'perl5db.pl';
18              
19             For L applications see L.
20              
21             =head1 DESCRIPTION
22              
23             A modified version of ActiveState's Komodo remote debugging helper. It
24             aims to be a compliant implementation of the L
25             protocol|http://xdebug.org/docs-dbgp.php> by default, but with the
26             option of emulating Xdebug-specific quirks, for compatibility with
27             existing clients that assume Xdebug behaviour.
28              
29             When debugging, the debugger running inside the application
30             establishes a connection to an external DBGp client (typically a GUI
31             program) that allows to inspect the program state from the outside.
32              
33             This implementation has been tested with L,
34             L
35             and L.
36              
37             Note that it might not work with Komodo itself (by accident, I don't
38             own a copy to test compatibility, bug reports welcome).
39              
40             =head1 ENVIRONMENT VARIABLES
41              
42             =head2 PERLDB_OPTS
43              
44             Space-separated list of debugger options:
45              
46             =over 4
47              
48             =item RemotePort
49              
50             PERLDB_OPTS="... RemotePort=hostname:port ..."
51              
52             Host/port to which the debugger connects, alternative to
53             C.
54              
55             =item RemotePath
56              
57             PERLDB_OPTS="... RemotePath=/path/to/unix/socket ..."
58              
59             Unix-domain socket path to which the debugger connects, alternative to
60             C.
61              
62             =item LogFile
63              
64             PERLDB_OPTS="... LogFile=/path/to/file ..."
65              
66             If set, debugging information for the debugger itself is appended to
67             the specified path.
68              
69             =item Alarm, Async
70              
71             PERLDB_OPTS="... Alarm=1 ..."
72             PERLDB_OPTS="... Async=1 ..."
73              
74             Periodically check for C commands sent by the debugger (this
75             uses L internally).
76              
77             =item RecursionCheckDepth
78              
79             PERLDB_OPTS="... RecursionCheckDepth=N ..."
80              
81             Break into the debugger when recursion level reaches the specified
82             value.
83              
84             =item Xdebug
85              
86             PERLDB_OPTS="... Xdebug=[0,1] ..."
87             PERLDB_OPTS="... Xdebug=opt1,opt2,... ..."
88              
89             Set one or more Xdebug compatibility options:
90              
91             =over 4
92              
93             =item send_position_after_stepping
94              
95             Whether to include an C<< >> tag in step command
96             response specifying the current file name and line number.
97              
98             =item property_without_value_tag
99              
100             Emit the value of scalar properties directly inside the C<<
101             >> tag, without a C<< >> wrapper.
102              
103             =item nested_properties_in_context
104              
105             Return up to C levels for properties in the C
106             response, rather than returning just the root value and letting the
107             debugger drill down if needed.
108              
109             =item temporary_breakpoint_state
110              
111             Return temporary breakpoint state as C instead of returning it
112             as C.
113              
114             =back
115              
116             =item ConnectAtStart
117              
118             PERLDB_OPTS="... ConnectAtStart=[1|0] ..."
119              
120             Defaults to C<1>; whether the debugger program should connect to the
121             DBGp client early during startup.
122              
123             When set to C<0>, use L to initiate the connection.
124              
125             =item KeepRunning
126              
127             PERLDB_OPTS="... KeepRunning=[0|1] ..."
128              
129             Defaults to C<0>; whether the debugged program should keep running
130             with debugging disabled if the DBGp client drops the connection.
131              
132             =back
133              
134             =head2 RemotePort
135              
136             Equivalent to adding C to C.
137              
138             =head2 DEBUGGER_APPID
139              
140             If set, it is returned as the C attribute of the C
141             message (defaults to L otherwise.
142              
143             =head2 DBGP_IDEKEY
144              
145             If set, it is returned as the C attribute of the C message.
146              
147             =head2 DBGP_COOKIE
148              
149             If set, it is returned as the C attribute of the C message.
150              
151             =head2 HOST_HTTP
152              
153             If set, overrides the value of the C attribute in the C message.
154              
155             =head2 DBGP_PERL_IGNORE_PADWALKER
156              
157             If set to a true value, does not use L to get the list of
158             local variables, but uses a combination of L and C.
159              
160             =head2 DBGP_PURE_PERL, DBGP_XS_ONLY
161              
162             The default is to try to load an XS helper for the debugger, and fall
163             back to the pure-Perl implementation if loading the XS helper fails
164             (or the helper has not been built). Setting C or
165             C allows to explicitly choose one or the other.
166              
167             =head1 FUNCTIONS
168              
169             There is no need to use any of the functions below unless you are
170             writing an higher-level interface to the debugger (for example
171             L).
172              
173             =head2 connectOrReconnect
174              
175             DB::connectOrReconnect();
176              
177             Connects to the debugger client (closes the current connection if any).
178              
179             If the debugger client is not listening at the specified endpoint,
180             debugging is disabled (via L) and execution continues
181             normally.
182              
183             =head2 isConnected
184              
185             my $connected = DB::isConnected();
186              
187             Whether the debugger is connected to a client.
188              
189             =head2 disable
190              
191             DB::disable();
192              
193             Disables debugging. The debugged program should run at nearly normal
194             speec with debugging disabled..
195              
196             =head2 enable
197              
198             DB::enable();
199              
200             Re-enables debugging after a L call.
201              
202             =head2 disconnect
203              
204             DB::disconnect();
205              
206             Disconnects from the debugger client.
207              
208             =cut
209              
210 1     1   561 use strict;
  1         1  
  1         23  
211 1     1   4 use warnings;
  1         1  
  1         95  
212              
213             our $VERSION = '0.18';
214              
215             sub debugger_path {
216 0     0 0   for my $dir (@INC) {
217 0 0         return "$dir/dbgp-helper"
218             if -f "$dir/dbgp-helper/perl5db.pl"
219             }
220              
221 0           die "Unable to find debugger library 'dbgp-helper' in \@INC (@INC)";
222             }
223              
224             1;
225              
226             __END__