xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/pod/perldebguts.pod (revision 0:68f95e015346)
1*0Sstevel@tonic-gate=head1 NAME
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateperldebguts - Guts of Perl debugging
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gate=head1 DESCRIPTION
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gateThis is not the perldebug(1) manpage, which tells you how to use
8*0Sstevel@tonic-gatethe debugger.  This manpage describes low-level details concerning
9*0Sstevel@tonic-gatethe debugger's internals, which range from difficult to impossible
10*0Sstevel@tonic-gateto understand for anyone who isn't incredibly intimate with Perl's guts.
11*0Sstevel@tonic-gateCaveat lector.
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate=head1 Debugger Internals
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gatePerl has special debugging hooks at compile-time and run-time used
16*0Sstevel@tonic-gateto create debugging environments.  These hooks are not to be confused
17*0Sstevel@tonic-gatewith the I<perl -Dxxx> command described in L<perlrun>, which is
18*0Sstevel@tonic-gateusable only if a special Perl is built per the instructions in the
19*0Sstevel@tonic-gateF<INSTALL> podpage in the Perl source tree.
20*0Sstevel@tonic-gate
21*0Sstevel@tonic-gateFor example, whenever you call Perl's built-in C<caller> function
22*0Sstevel@tonic-gatefrom the package C<DB>, the arguments that the corresponding stack
23*0Sstevel@tonic-gateframe was called with are copied to the C<@DB::args> array.  These
24*0Sstevel@tonic-gatemechanisms are enabled by calling Perl with the B<-d> switch.
25*0Sstevel@tonic-gateSpecifically, the following additional features are enabled
26*0Sstevel@tonic-gate(cf. L<perlvar/$^P>):
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gate=over 4
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate=item *
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gatePerl inserts the contents of C<$ENV{PERL5DB}> (or C<BEGIN {require
33*0Sstevel@tonic-gate'perl5db.pl'}> if not present) before the first line of your program.
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate=item *
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gateEach array C<@{"_<$filename"}> holds the lines of $filename for a
38*0Sstevel@tonic-gatefile compiled by Perl.  The same is also true for C<eval>ed strings
39*0Sstevel@tonic-gatethat contain subroutines, or which are currently being executed.
40*0Sstevel@tonic-gateThe $filename for C<eval>ed strings looks like C<(eval 34)>.
41*0Sstevel@tonic-gateCode assertions in regexes look like C<(re_eval 19)>.
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gateValues in this array are magical in numeric context: they compare
44*0Sstevel@tonic-gateequal to zero only if the line is not breakable.
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate=item *
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gateEach hash C<%{"_<$filename"}> contains breakpoints and actions keyed
49*0Sstevel@tonic-gateby line number.  Individual entries (as opposed to the whole hash)
50*0Sstevel@tonic-gateare settable.  Perl only cares about Boolean true here, although
51*0Sstevel@tonic-gatethe values used by F<perl5db.pl> have the form
52*0Sstevel@tonic-gateC<"$break_condition\0$action">.
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gateThe same holds for evaluated strings that contain subroutines, or
55*0Sstevel@tonic-gatewhich are currently being executed.  The $filename for C<eval>ed strings
56*0Sstevel@tonic-gatelooks like C<(eval 34)> or  C<(re_eval 19)>.
57*0Sstevel@tonic-gate
58*0Sstevel@tonic-gate=item *
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gateEach scalar C<${"_<$filename"}> contains C<"_<$filename">.  This is
61*0Sstevel@tonic-gatealso the case for evaluated strings that contain subroutines, or
62*0Sstevel@tonic-gatewhich are currently being executed.  The $filename for C<eval>ed
63*0Sstevel@tonic-gatestrings looks like C<(eval 34)> or C<(re_eval 19)>.
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gate=item *
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gateAfter each C<require>d file is compiled, but before it is executed,
68*0Sstevel@tonic-gateC<DB::postponed(*{"_<$filename"})> is called if the subroutine
69*0Sstevel@tonic-gateC<DB::postponed> exists.  Here, the $filename is the expanded name of
70*0Sstevel@tonic-gatethe C<require>d file, as found in the values of %INC.
71*0Sstevel@tonic-gate
72*0Sstevel@tonic-gate=item *
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gateAfter each subroutine C<subname> is compiled, the existence of
75*0Sstevel@tonic-gateC<$DB::postponed{subname}> is checked.  If this key exists,
76*0Sstevel@tonic-gateC<DB::postponed(subname)> is called if the C<DB::postponed> subroutine
77*0Sstevel@tonic-gatealso exists.
78*0Sstevel@tonic-gate
79*0Sstevel@tonic-gate=item *
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gateA hash C<%DB::sub> is maintained, whose keys are subroutine names
82*0Sstevel@tonic-gateand whose values have the form C<filename:startline-endline>.
83*0Sstevel@tonic-gateC<filename> has the form C<(eval 34)> for subroutines defined inside
84*0Sstevel@tonic-gateC<eval>s, or C<(re_eval 19)> for those within regex code assertions.
85*0Sstevel@tonic-gate
86*0Sstevel@tonic-gate=item *
87*0Sstevel@tonic-gate
88*0Sstevel@tonic-gateWhen the execution of your program reaches a point that can hold a
89*0Sstevel@tonic-gatebreakpoint, the C<DB::DB()> subroutine is called if any of the variables
90*0Sstevel@tonic-gateC<$DB::trace>, C<$DB::single>, or C<$DB::signal> is true.  These variables
91*0Sstevel@tonic-gateare not C<local>izable.  This feature is disabled when executing
92*0Sstevel@tonic-gateinside C<DB::DB()>, including functions called from it
93*0Sstevel@tonic-gateunless C<< $^D & (1<<30) >> is true.
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gate=item *
96*0Sstevel@tonic-gate
97*0Sstevel@tonic-gateWhen execution of the program reaches a subroutine call, a call to
98*0Sstevel@tonic-gateC<&DB::sub>(I<args>) is made instead, with C<$DB::sub> holding the
99*0Sstevel@tonic-gatename of the called subroutine. (This doesn't happen if the subroutine
100*0Sstevel@tonic-gatewas compiled in the C<DB> package.)
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gate=back
103*0Sstevel@tonic-gate
104*0Sstevel@tonic-gateNote that if C<&DB::sub> needs external data for it to work, no
105*0Sstevel@tonic-gatesubroutine call is possible without it. As an example, the standard
106*0Sstevel@tonic-gatedebugger's C<&DB::sub> depends on the C<$DB::deep> variable
107*0Sstevel@tonic-gate(it defines how many levels of recursion deep into the debugger you can go
108*0Sstevel@tonic-gatebefore a mandatory break).  If C<$DB::deep> is not defined, subroutine
109*0Sstevel@tonic-gatecalls are not possible, even though C<&DB::sub> exists.
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gate=head2 Writing Your Own Debugger
112*0Sstevel@tonic-gate
113*0Sstevel@tonic-gate=head3 Environment Variables
114*0Sstevel@tonic-gate
115*0Sstevel@tonic-gateThe C<PERL5DB> environment variable can be used to define a debugger.
116*0Sstevel@tonic-gateFor example, the minimal "working" debugger (it actually doesn't do anything)
117*0Sstevel@tonic-gateconsists of one line:
118*0Sstevel@tonic-gate
119*0Sstevel@tonic-gate  sub DB::DB {}
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gateIt can easily be defined like this:
122*0Sstevel@tonic-gate
123*0Sstevel@tonic-gate  $ PERL5DB="sub DB::DB {}" perl -d your-script
124*0Sstevel@tonic-gate
125*0Sstevel@tonic-gateAnother brief debugger, slightly more useful, can be created
126*0Sstevel@tonic-gatewith only the line:
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gate  sub DB::DB {print ++$i; scalar <STDIN>}
129*0Sstevel@tonic-gate
130*0Sstevel@tonic-gateThis debugger prints a number which increments for each statement
131*0Sstevel@tonic-gateencountered and waits for you to hit a newline before continuing
132*0Sstevel@tonic-gateto the next statement.
133*0Sstevel@tonic-gate
134*0Sstevel@tonic-gateThe following debugger is actually useful:
135*0Sstevel@tonic-gate
136*0Sstevel@tonic-gate  {
137*0Sstevel@tonic-gate    package DB;
138*0Sstevel@tonic-gate    sub DB  {}
139*0Sstevel@tonic-gate    sub sub {print ++$i, " $sub\n"; &$sub}
140*0Sstevel@tonic-gate  }
141*0Sstevel@tonic-gate
142*0Sstevel@tonic-gateIt prints the sequence number of each subroutine call and the name of the
143*0Sstevel@tonic-gatecalled subroutine.  Note that C<&DB::sub> is being compiled into the
144*0Sstevel@tonic-gatepackage C<DB> through the use of the C<package> directive.
145*0Sstevel@tonic-gate
146*0Sstevel@tonic-gateWhen it starts, the debugger reads your rc file (F<./.perldb> or
147*0Sstevel@tonic-gateF<~/.perldb> under Unix), which can set important options.
148*0Sstevel@tonic-gate(A subroutine (C<&afterinit>) can be defined here as well; it is executed
149*0Sstevel@tonic-gateafter the debugger completes its own initialization.)
150*0Sstevel@tonic-gate
151*0Sstevel@tonic-gateAfter the rc file is read, the debugger reads the PERLDB_OPTS
152*0Sstevel@tonic-gateenvironment variable and uses it to set debugger options. The
153*0Sstevel@tonic-gatecontents of this variable are treated as if they were the argument
154*0Sstevel@tonic-gateof an C<o ...> debugger command (q.v. in L<perldebug/Options>).
155*0Sstevel@tonic-gate
156*0Sstevel@tonic-gate=head3 Debugger internal variables
157*0Sstevel@tonic-gateIn addition to the file and subroutine-related variables mentioned above,
158*0Sstevel@tonic-gatethe debugger also maintains various magical internal variables.
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gate=over 4
161*0Sstevel@tonic-gate
162*0Sstevel@tonic-gate=item *
163*0Sstevel@tonic-gate
164*0Sstevel@tonic-gateC<@DB::dbline> is an alias for C<@{"::_<current_file"}>, which
165*0Sstevel@tonic-gateholds the lines of the currently-selected file (compiled by Perl), either
166*0Sstevel@tonic-gateexplicitly chosen with the debugger's C<f> command, or implicitly by flow
167*0Sstevel@tonic-gateof execution.
168*0Sstevel@tonic-gate
169*0Sstevel@tonic-gateValues in this array are magical in numeric context: they compare
170*0Sstevel@tonic-gateequal to zero only if the line is not breakable.
171*0Sstevel@tonic-gate
172*0Sstevel@tonic-gate=item *
173*0Sstevel@tonic-gate
174*0Sstevel@tonic-gateC<%DB::dbline>, is an alias for C<%{"::_<current_file"}>, which
175*0Sstevel@tonic-gatecontains breakpoints and actions keyed by line number in
176*0Sstevel@tonic-gatethe currently-selected file, either explicitly chosen with the
177*0Sstevel@tonic-gatedebugger's C<f> command, or implicitly by flow of execution.
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gateAs previously noted, individual entries (as opposed to the whole hash)
180*0Sstevel@tonic-gateare settable.  Perl only cares about Boolean true here, although
181*0Sstevel@tonic-gatethe values used by F<perl5db.pl> have the form
182*0Sstevel@tonic-gateC<"$break_condition\0$action">.
183*0Sstevel@tonic-gate
184*0Sstevel@tonic-gate=back
185*0Sstevel@tonic-gate
186*0Sstevel@tonic-gate=head3 Debugger customization functions
187*0Sstevel@tonic-gate
188*0Sstevel@tonic-gateSome functions are provided to simplify customization.
189*0Sstevel@tonic-gate
190*0Sstevel@tonic-gate=over 4
191*0Sstevel@tonic-gate
192*0Sstevel@tonic-gate=item *
193*0Sstevel@tonic-gate
194*0Sstevel@tonic-gateSee L<perldebug/"Options"> for description of options parsed by
195*0Sstevel@tonic-gateC<DB::parse_options(string)> parses debugger options; see
196*0Sstevel@tonic-gateL<pperldebug/Options> for a description of options recognized.
197*0Sstevel@tonic-gate
198*0Sstevel@tonic-gate=item *
199*0Sstevel@tonic-gate
200*0Sstevel@tonic-gateC<DB::dump_trace(skip[,count])> skips the specified number of frames
201*0Sstevel@tonic-gateand returns a list containing information about the calling frames (all
202*0Sstevel@tonic-gateof them, if C<count> is missing).  Each entry is reference to a hash
203*0Sstevel@tonic-gatewith keys C<context> (either C<.>, C<$>, or C<@>), C<sub> (subroutine
204*0Sstevel@tonic-gatename, or info about C<eval>), C<args> (C<undef> or a reference to
205*0Sstevel@tonic-gatean array), C<file>, and C<line>.
206*0Sstevel@tonic-gate
207*0Sstevel@tonic-gate=item *
208*0Sstevel@tonic-gate
209*0Sstevel@tonic-gateC<DB::print_trace(FH, skip[, count[, short]])> prints
210*0Sstevel@tonic-gateformatted info about caller frames.  The last two functions may be
211*0Sstevel@tonic-gateconvenient as arguments to C<< < >>, C<< << >> commands.
212*0Sstevel@tonic-gate
213*0Sstevel@tonic-gate=back
214*0Sstevel@tonic-gate
215*0Sstevel@tonic-gateNote that any variables and functions that are not documented in
216*0Sstevel@tonic-gatethis manpages (or in L<perldebug>) are considered for internal
217*0Sstevel@tonic-gateuse only, and as such are subject to change without notice.
218*0Sstevel@tonic-gate
219*0Sstevel@tonic-gate=head1 Frame Listing Output Examples
220*0Sstevel@tonic-gate
221*0Sstevel@tonic-gateThe C<frame> option can be used to control the output of frame
222*0Sstevel@tonic-gateinformation.  For example, contrast this expression trace:
223*0Sstevel@tonic-gate
224*0Sstevel@tonic-gate $ perl -de 42
225*0Sstevel@tonic-gate Stack dump during die enabled outside of evals.
226*0Sstevel@tonic-gate
227*0Sstevel@tonic-gate Loading DB routines from perl5db.pl patch level 0.94
228*0Sstevel@tonic-gate Emacs support available.
229*0Sstevel@tonic-gate
230*0Sstevel@tonic-gate Enter h or `h h' for help.
231*0Sstevel@tonic-gate
232*0Sstevel@tonic-gate main::(-e:1):   0
233*0Sstevel@tonic-gate   DB<1> sub foo { 14 }
234*0Sstevel@tonic-gate
235*0Sstevel@tonic-gate   DB<2> sub bar { 3 }
236*0Sstevel@tonic-gate
237*0Sstevel@tonic-gate   DB<3> t print foo() * bar()
238*0Sstevel@tonic-gate main::((eval 172):3):   print foo() + bar();
239*0Sstevel@tonic-gate main::foo((eval 168):2):
240*0Sstevel@tonic-gate main::bar((eval 170):2):
241*0Sstevel@tonic-gate 42
242*0Sstevel@tonic-gate
243*0Sstevel@tonic-gatewith this one, once the C<o>ption C<frame=2> has been set:
244*0Sstevel@tonic-gate
245*0Sstevel@tonic-gate   DB<4> o f=2
246*0Sstevel@tonic-gate                frame = '2'
247*0Sstevel@tonic-gate   DB<5> t print foo() * bar()
248*0Sstevel@tonic-gate 3:      foo() * bar()
249*0Sstevel@tonic-gate entering main::foo
250*0Sstevel@tonic-gate  2:     sub foo { 14 };
251*0Sstevel@tonic-gate exited main::foo
252*0Sstevel@tonic-gate entering main::bar
253*0Sstevel@tonic-gate  2:     sub bar { 3 };
254*0Sstevel@tonic-gate exited main::bar
255*0Sstevel@tonic-gate 42
256*0Sstevel@tonic-gate
257*0Sstevel@tonic-gateBy way of demonstration, we present below a laborious listing
258*0Sstevel@tonic-gateresulting from setting your C<PERLDB_OPTS> environment variable to
259*0Sstevel@tonic-gatethe value C<f=n N>, and running I<perl -d -V> from the command line.
260*0Sstevel@tonic-gateExamples use various values of C<n> are shown to give you a feel
261*0Sstevel@tonic-gatefor the difference between settings.  Long those it may be, this
262*0Sstevel@tonic-gateis not a complete listing, but only excerpts.
263*0Sstevel@tonic-gate
264*0Sstevel@tonic-gate=over 4
265*0Sstevel@tonic-gate
266*0Sstevel@tonic-gate=item 1
267*0Sstevel@tonic-gate
268*0Sstevel@tonic-gate  entering main::BEGIN
269*0Sstevel@tonic-gate   entering Config::BEGIN
270*0Sstevel@tonic-gate    Package lib/Exporter.pm.
271*0Sstevel@tonic-gate    Package lib/Carp.pm.
272*0Sstevel@tonic-gate   Package lib/Config.pm.
273*0Sstevel@tonic-gate   entering Config::TIEHASH
274*0Sstevel@tonic-gate   entering Exporter::import
275*0Sstevel@tonic-gate    entering Exporter::export
276*0Sstevel@tonic-gate  entering Config::myconfig
277*0Sstevel@tonic-gate   entering Config::FETCH
278*0Sstevel@tonic-gate   entering Config::FETCH
279*0Sstevel@tonic-gate   entering Config::FETCH
280*0Sstevel@tonic-gate   entering Config::FETCH
281*0Sstevel@tonic-gate
282*0Sstevel@tonic-gate=item 2
283*0Sstevel@tonic-gate
284*0Sstevel@tonic-gate  entering main::BEGIN
285*0Sstevel@tonic-gate   entering Config::BEGIN
286*0Sstevel@tonic-gate    Package lib/Exporter.pm.
287*0Sstevel@tonic-gate    Package lib/Carp.pm.
288*0Sstevel@tonic-gate   exited Config::BEGIN
289*0Sstevel@tonic-gate   Package lib/Config.pm.
290*0Sstevel@tonic-gate   entering Config::TIEHASH
291*0Sstevel@tonic-gate   exited Config::TIEHASH
292*0Sstevel@tonic-gate   entering Exporter::import
293*0Sstevel@tonic-gate    entering Exporter::export
294*0Sstevel@tonic-gate    exited Exporter::export
295*0Sstevel@tonic-gate   exited Exporter::import
296*0Sstevel@tonic-gate  exited main::BEGIN
297*0Sstevel@tonic-gate  entering Config::myconfig
298*0Sstevel@tonic-gate   entering Config::FETCH
299*0Sstevel@tonic-gate   exited Config::FETCH
300*0Sstevel@tonic-gate   entering Config::FETCH
301*0Sstevel@tonic-gate   exited Config::FETCH
302*0Sstevel@tonic-gate   entering Config::FETCH
303*0Sstevel@tonic-gate
304*0Sstevel@tonic-gate=item 4
305*0Sstevel@tonic-gate
306*0Sstevel@tonic-gate  in  $=main::BEGIN() from /dev/null:0
307*0Sstevel@tonic-gate   in  $=Config::BEGIN() from lib/Config.pm:2
308*0Sstevel@tonic-gate    Package lib/Exporter.pm.
309*0Sstevel@tonic-gate    Package lib/Carp.pm.
310*0Sstevel@tonic-gate   Package lib/Config.pm.
311*0Sstevel@tonic-gate   in  $=Config::TIEHASH('Config') from lib/Config.pm:644
312*0Sstevel@tonic-gate   in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
313*0Sstevel@tonic-gate    in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from li
314*0Sstevel@tonic-gate  in  @=Config::myconfig() from /dev/null:0
315*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
316*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
317*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'PERL_VERSION') from lib/Config.pm:574
318*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'PERL_SUBVERSION') from lib/Config.pm:574
319*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'osname') from lib/Config.pm:574
320*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'osvers') from lib/Config.pm:574
321*0Sstevel@tonic-gate
322*0Sstevel@tonic-gate=item 6
323*0Sstevel@tonic-gate
324*0Sstevel@tonic-gate  in  $=main::BEGIN() from /dev/null:0
325*0Sstevel@tonic-gate   in  $=Config::BEGIN() from lib/Config.pm:2
326*0Sstevel@tonic-gate    Package lib/Exporter.pm.
327*0Sstevel@tonic-gate    Package lib/Carp.pm.
328*0Sstevel@tonic-gate   out $=Config::BEGIN() from lib/Config.pm:0
329*0Sstevel@tonic-gate   Package lib/Config.pm.
330*0Sstevel@tonic-gate   in  $=Config::TIEHASH('Config') from lib/Config.pm:644
331*0Sstevel@tonic-gate   out $=Config::TIEHASH('Config') from lib/Config.pm:644
332*0Sstevel@tonic-gate   in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
333*0Sstevel@tonic-gate    in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/
334*0Sstevel@tonic-gate    out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/
335*0Sstevel@tonic-gate   out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
336*0Sstevel@tonic-gate  out $=main::BEGIN() from /dev/null:0
337*0Sstevel@tonic-gate  in  @=Config::myconfig() from /dev/null:0
338*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
339*0Sstevel@tonic-gate   out $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
340*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
341*0Sstevel@tonic-gate   out $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
342*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'PERL_VERSION') from lib/Config.pm:574
343*0Sstevel@tonic-gate   out $=Config::FETCH(ref(Config), 'PERL_VERSION') from lib/Config.pm:574
344*0Sstevel@tonic-gate   in  $=Config::FETCH(ref(Config), 'PERL_SUBVERSION') from lib/Config.pm:574
345*0Sstevel@tonic-gate
346*0Sstevel@tonic-gate=item 14
347*0Sstevel@tonic-gate
348*0Sstevel@tonic-gate  in  $=main::BEGIN() from /dev/null:0
349*0Sstevel@tonic-gate   in  $=Config::BEGIN() from lib/Config.pm:2
350*0Sstevel@tonic-gate    Package lib/Exporter.pm.
351*0Sstevel@tonic-gate    Package lib/Carp.pm.
352*0Sstevel@tonic-gate   out $=Config::BEGIN() from lib/Config.pm:0
353*0Sstevel@tonic-gate   Package lib/Config.pm.
354*0Sstevel@tonic-gate   in  $=Config::TIEHASH('Config') from lib/Config.pm:644
355*0Sstevel@tonic-gate   out $=Config::TIEHASH('Config') from lib/Config.pm:644
356*0Sstevel@tonic-gate   in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
357*0Sstevel@tonic-gate    in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/E
358*0Sstevel@tonic-gate    out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/E
359*0Sstevel@tonic-gate   out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
360*0Sstevel@tonic-gate  out $=main::BEGIN() from /dev/null:0
361*0Sstevel@tonic-gate  in  @=Config::myconfig() from /dev/null:0
362*0Sstevel@tonic-gate   in  $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574
363*0Sstevel@tonic-gate   out $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574
364*0Sstevel@tonic-gate   in  $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574
365*0Sstevel@tonic-gate   out $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574
366*0Sstevel@tonic-gate
367*0Sstevel@tonic-gate=item 30
368*0Sstevel@tonic-gate
369*0Sstevel@tonic-gate  in  $=CODE(0x15eca4)() from /dev/null:0
370*0Sstevel@tonic-gate   in  $=CODE(0x182528)() from lib/Config.pm:2
371*0Sstevel@tonic-gate    Package lib/Exporter.pm.
372*0Sstevel@tonic-gate   out $=CODE(0x182528)() from lib/Config.pm:0
373*0Sstevel@tonic-gate   scalar context return from CODE(0x182528): undef
374*0Sstevel@tonic-gate   Package lib/Config.pm.
375*0Sstevel@tonic-gate   in  $=Config::TIEHASH('Config') from lib/Config.pm:628
376*0Sstevel@tonic-gate   out $=Config::TIEHASH('Config') from lib/Config.pm:628
377*0Sstevel@tonic-gate   scalar context return from Config::TIEHASH:   empty hash
378*0Sstevel@tonic-gate   in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
379*0Sstevel@tonic-gate    in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/Exporter.pm:171
380*0Sstevel@tonic-gate    out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/Exporter.pm:171
381*0Sstevel@tonic-gate    scalar context return from Exporter::export: ''
382*0Sstevel@tonic-gate   out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
383*0Sstevel@tonic-gate   scalar context return from Exporter::import: ''
384*0Sstevel@tonic-gate
385*0Sstevel@tonic-gate=back
386*0Sstevel@tonic-gate
387*0Sstevel@tonic-gateIn all cases shown above, the line indentation shows the call tree.
388*0Sstevel@tonic-gateIf bit 2 of C<frame> is set, a line is printed on exit from a
389*0Sstevel@tonic-gatesubroutine as well.  If bit 4 is set, the arguments are printed
390*0Sstevel@tonic-gatealong with the caller info.  If bit 8 is set, the arguments are
391*0Sstevel@tonic-gateprinted even if they are tied or references.  If bit 16 is set, the
392*0Sstevel@tonic-gatereturn value is printed, too.
393*0Sstevel@tonic-gate
394*0Sstevel@tonic-gateWhen a package is compiled, a line like this
395*0Sstevel@tonic-gate
396*0Sstevel@tonic-gate    Package lib/Carp.pm.
397*0Sstevel@tonic-gate
398*0Sstevel@tonic-gateis printed with proper indentation.
399*0Sstevel@tonic-gate
400*0Sstevel@tonic-gate=head1 Debugging regular expressions
401*0Sstevel@tonic-gate
402*0Sstevel@tonic-gateThere are two ways to enable debugging output for regular expressions.
403*0Sstevel@tonic-gate
404*0Sstevel@tonic-gateIf your perl is compiled with C<-DDEBUGGING>, you may use the
405*0Sstevel@tonic-gateB<-Dr> flag on the command line.
406*0Sstevel@tonic-gate
407*0Sstevel@tonic-gateOtherwise, one can C<use re 'debug'>, which has effects at
408*0Sstevel@tonic-gatecompile time and run time.  It is not lexically scoped.
409*0Sstevel@tonic-gate
410*0Sstevel@tonic-gate=head2 Compile-time output
411*0Sstevel@tonic-gate
412*0Sstevel@tonic-gateThe debugging output at compile time looks like this:
413*0Sstevel@tonic-gate
414*0Sstevel@tonic-gate  Compiling REx `[bc]d(ef*g)+h[ij]k$'
415*0Sstevel@tonic-gate  size 45 Got 364 bytes for offset annotations.
416*0Sstevel@tonic-gate  first at 1
417*0Sstevel@tonic-gate  rarest char g at 0
418*0Sstevel@tonic-gate  rarest char d at 0
419*0Sstevel@tonic-gate     1: ANYOF[bc](12)
420*0Sstevel@tonic-gate    12: EXACT <d>(14)
421*0Sstevel@tonic-gate    14: CURLYX[0] {1,32767}(28)
422*0Sstevel@tonic-gate    16:   OPEN1(18)
423*0Sstevel@tonic-gate    18:     EXACT <e>(20)
424*0Sstevel@tonic-gate    20:     STAR(23)
425*0Sstevel@tonic-gate    21:       EXACT <f>(0)
426*0Sstevel@tonic-gate    23:     EXACT <g>(25)
427*0Sstevel@tonic-gate    25:   CLOSE1(27)
428*0Sstevel@tonic-gate    27:   WHILEM[1/1](0)
429*0Sstevel@tonic-gate    28: NOTHING(29)
430*0Sstevel@tonic-gate    29: EXACT <h>(31)
431*0Sstevel@tonic-gate    31: ANYOF[ij](42)
432*0Sstevel@tonic-gate    42: EXACT <k>(44)
433*0Sstevel@tonic-gate    44: EOL(45)
434*0Sstevel@tonic-gate    45: END(0)
435*0Sstevel@tonic-gate  anchored `de' at 1 floating `gh' at 3..2147483647 (checking floating)
436*0Sstevel@tonic-gate        stclass `ANYOF[bc]' minlen 7
437*0Sstevel@tonic-gate  Offsets: [45]
438*0Sstevel@tonic-gate  	1[4] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 5[1]
439*0Sstevel@tonic-gate  	0[0] 12[1] 0[0] 6[1] 0[0] 7[1] 0[0] 9[1] 8[1] 0[0] 10[1] 0[0]
440*0Sstevel@tonic-gate  	11[1] 0[0] 12[0] 12[0] 13[1] 0[0] 14[4] 0[0] 0[0] 0[0] 0[0]
441*0Sstevel@tonic-gate  	0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 18[1] 0[0] 19[1] 20[0]
442*0Sstevel@tonic-gate  Omitting $` $& $' support.
443*0Sstevel@tonic-gate
444*0Sstevel@tonic-gateThe first line shows the pre-compiled form of the regex.  The second
445*0Sstevel@tonic-gateshows the size of the compiled form (in arbitrary units, usually
446*0Sstevel@tonic-gate4-byte words) and the total number of bytes allocated for the
447*0Sstevel@tonic-gateoffset/length table, usually 4+C<size>*8.  The next line shows the
448*0Sstevel@tonic-gatelabel I<id> of the first node that does a match.
449*0Sstevel@tonic-gate
450*0Sstevel@tonic-gateThe
451*0Sstevel@tonic-gate
452*0Sstevel@tonic-gate  anchored `de' at 1 floating `gh' at 3..2147483647 (checking floating)
453*0Sstevel@tonic-gate        stclass `ANYOF[bc]' minlen 7
454*0Sstevel@tonic-gate
455*0Sstevel@tonic-gateline (split into two lines above) contains optimizer
456*0Sstevel@tonic-gateinformation.  In the example shown, the optimizer found that the match
457*0Sstevel@tonic-gateshould contain a substring C<de> at offset 1, plus substring C<gh>
458*0Sstevel@tonic-gateat some offset between 3 and infinity.  Moreover, when checking for
459*0Sstevel@tonic-gatethese substrings (to abandon impossible matches quickly), Perl will check
460*0Sstevel@tonic-gatefor the substring C<gh> before checking for the substring C<de>.  The
461*0Sstevel@tonic-gateoptimizer may also use the knowledge that the match starts (at the
462*0Sstevel@tonic-gateC<first> I<id>) with a character class, and no string
463*0Sstevel@tonic-gateshorter than 7 characters can possibly match.
464*0Sstevel@tonic-gate
465*0Sstevel@tonic-gateThe fields of interest which may appear in this line are
466*0Sstevel@tonic-gate
467*0Sstevel@tonic-gate=over 4
468*0Sstevel@tonic-gate
469*0Sstevel@tonic-gate=item C<anchored> I<STRING> C<at> I<POS>
470*0Sstevel@tonic-gate
471*0Sstevel@tonic-gate=item C<floating> I<STRING> C<at> I<POS1..POS2>
472*0Sstevel@tonic-gate
473*0Sstevel@tonic-gateSee above.
474*0Sstevel@tonic-gate
475*0Sstevel@tonic-gate=item C<matching floating/anchored>
476*0Sstevel@tonic-gate
477*0Sstevel@tonic-gateWhich substring to check first.
478*0Sstevel@tonic-gate
479*0Sstevel@tonic-gate=item C<minlen>
480*0Sstevel@tonic-gate
481*0Sstevel@tonic-gateThe minimal length of the match.
482*0Sstevel@tonic-gate
483*0Sstevel@tonic-gate=item C<stclass> I<TYPE>
484*0Sstevel@tonic-gate
485*0Sstevel@tonic-gateType of first matching node.
486*0Sstevel@tonic-gate
487*0Sstevel@tonic-gate=item C<noscan>
488*0Sstevel@tonic-gate
489*0Sstevel@tonic-gateDon't scan for the found substrings.
490*0Sstevel@tonic-gate
491*0Sstevel@tonic-gate=item C<isall>
492*0Sstevel@tonic-gate
493*0Sstevel@tonic-gateMeans that the optimizer information is all that the regular
494*0Sstevel@tonic-gateexpression contains, and thus one does not need to enter the regex engine at
495*0Sstevel@tonic-gateall.
496*0Sstevel@tonic-gate
497*0Sstevel@tonic-gate=item C<GPOS>
498*0Sstevel@tonic-gate
499*0Sstevel@tonic-gateSet if the pattern contains C<\G>.
500*0Sstevel@tonic-gate
501*0Sstevel@tonic-gate=item C<plus>
502*0Sstevel@tonic-gate
503*0Sstevel@tonic-gateSet if the pattern starts with a repeated char (as in C<x+y>).
504*0Sstevel@tonic-gate
505*0Sstevel@tonic-gate=item C<implicit>
506*0Sstevel@tonic-gate
507*0Sstevel@tonic-gateSet if the pattern starts with C<.*>.
508*0Sstevel@tonic-gate
509*0Sstevel@tonic-gate=item C<with eval>
510*0Sstevel@tonic-gate
511*0Sstevel@tonic-gateSet if the pattern contain eval-groups, such as C<(?{ code })> and
512*0Sstevel@tonic-gateC<(??{ code })>.
513*0Sstevel@tonic-gate
514*0Sstevel@tonic-gate=item C<anchored(TYPE)>
515*0Sstevel@tonic-gate
516*0Sstevel@tonic-gateIf the pattern may match only at a handful of places, (with C<TYPE>
517*0Sstevel@tonic-gatebeing C<BOL>, C<MBOL>, or C<GPOS>.  See the table below.
518*0Sstevel@tonic-gate
519*0Sstevel@tonic-gate=back
520*0Sstevel@tonic-gate
521*0Sstevel@tonic-gateIf a substring is known to match at end-of-line only, it may be
522*0Sstevel@tonic-gatefollowed by C<$>, as in C<floating `k'$>.
523*0Sstevel@tonic-gate
524*0Sstevel@tonic-gateThe optimizer-specific information is used to avoid entering (a slow) regex
525*0Sstevel@tonic-gateengine on strings that will not definitely match.  If the C<isall> flag
526*0Sstevel@tonic-gateis set, a call to the regex engine may be avoided even when the optimizer
527*0Sstevel@tonic-gatefound an appropriate place for the match.
528*0Sstevel@tonic-gate
529*0Sstevel@tonic-gateAbove the optimizer section is the list of I<nodes> of the compiled
530*0Sstevel@tonic-gateform of the regex.  Each line has format
531*0Sstevel@tonic-gate
532*0Sstevel@tonic-gateC<   >I<id>: I<TYPE> I<OPTIONAL-INFO> (I<next-id>)
533*0Sstevel@tonic-gate
534*0Sstevel@tonic-gate=head2 Types of nodes
535*0Sstevel@tonic-gate
536*0Sstevel@tonic-gateHere are the possible types, with short descriptions:
537*0Sstevel@tonic-gate
538*0Sstevel@tonic-gate    # TYPE arg-description [num-args] [longjump-len] DESCRIPTION
539*0Sstevel@tonic-gate
540*0Sstevel@tonic-gate    # Exit points
541*0Sstevel@tonic-gate    END		no	End of program.
542*0Sstevel@tonic-gate    SUCCEED	no	Return from a subroutine, basically.
543*0Sstevel@tonic-gate
544*0Sstevel@tonic-gate    # Anchors:
545*0Sstevel@tonic-gate    BOL		no	Match "" at beginning of line.
546*0Sstevel@tonic-gate    MBOL	no	Same, assuming multiline.
547*0Sstevel@tonic-gate    SBOL	no	Same, assuming singleline.
548*0Sstevel@tonic-gate    EOS		no	Match "" at end of string.
549*0Sstevel@tonic-gate    EOL		no	Match "" at end of line.
550*0Sstevel@tonic-gate    MEOL	no	Same, assuming multiline.
551*0Sstevel@tonic-gate    SEOL	no	Same, assuming singleline.
552*0Sstevel@tonic-gate    BOUND	no	Match "" at any word boundary
553*0Sstevel@tonic-gate    BOUNDL	no	Match "" at any word boundary
554*0Sstevel@tonic-gate    NBOUND	no	Match "" at any word non-boundary
555*0Sstevel@tonic-gate    NBOUNDL	no	Match "" at any word non-boundary
556*0Sstevel@tonic-gate    GPOS	no	Matches where last m//g left off.
557*0Sstevel@tonic-gate
558*0Sstevel@tonic-gate    # [Special] alternatives
559*0Sstevel@tonic-gate    ANY		no	Match any one character (except newline).
560*0Sstevel@tonic-gate    SANY	no	Match any one character.
561*0Sstevel@tonic-gate    ANYOF	sv	Match character in (or not in) this class.
562*0Sstevel@tonic-gate    ALNUM	no	Match any alphanumeric character
563*0Sstevel@tonic-gate    ALNUML	no	Match any alphanumeric char in locale
564*0Sstevel@tonic-gate    NALNUM	no	Match any non-alphanumeric character
565*0Sstevel@tonic-gate    NALNUML	no	Match any non-alphanumeric char in locale
566*0Sstevel@tonic-gate    SPACE	no	Match any whitespace character
567*0Sstevel@tonic-gate    SPACEL	no	Match any whitespace char in locale
568*0Sstevel@tonic-gate    NSPACE	no	Match any non-whitespace character
569*0Sstevel@tonic-gate    NSPACEL	no	Match any non-whitespace char in locale
570*0Sstevel@tonic-gate    DIGIT	no	Match any numeric character
571*0Sstevel@tonic-gate    NDIGIT	no	Match any non-numeric character
572*0Sstevel@tonic-gate
573*0Sstevel@tonic-gate    # BRANCH	The set of branches constituting a single choice are hooked
574*0Sstevel@tonic-gate    #		together with their "next" pointers, since precedence prevents
575*0Sstevel@tonic-gate    #		anything being concatenated to any individual branch.  The
576*0Sstevel@tonic-gate    #		"next" pointer of the last BRANCH in a choice points to the
577*0Sstevel@tonic-gate    #		thing following the whole choice.  This is also where the
578*0Sstevel@tonic-gate    #		final "next" pointer of each individual branch points; each
579*0Sstevel@tonic-gate    #		branch starts with the operand node of a BRANCH node.
580*0Sstevel@tonic-gate    #
581*0Sstevel@tonic-gate    BRANCH	node	Match this alternative, or the next...
582*0Sstevel@tonic-gate
583*0Sstevel@tonic-gate    # BACK	Normal "next" pointers all implicitly point forward; BACK
584*0Sstevel@tonic-gate    #		exists to make loop structures possible.
585*0Sstevel@tonic-gate    # not used
586*0Sstevel@tonic-gate    BACK	no	Match "", "next" ptr points backward.
587*0Sstevel@tonic-gate
588*0Sstevel@tonic-gate    # Literals
589*0Sstevel@tonic-gate    EXACT	sv	Match this string (preceded by length).
590*0Sstevel@tonic-gate    EXACTF	sv	Match this string, folded (prec. by length).
591*0Sstevel@tonic-gate    EXACTFL	sv	Match this string, folded in locale (w/len).
592*0Sstevel@tonic-gate
593*0Sstevel@tonic-gate    # Do nothing
594*0Sstevel@tonic-gate    NOTHING	no	Match empty string.
595*0Sstevel@tonic-gate    # A variant of above which delimits a group, thus stops optimizations
596*0Sstevel@tonic-gate    TAIL	no	Match empty string. Can jump here from outside.
597*0Sstevel@tonic-gate
598*0Sstevel@tonic-gate    # STAR,PLUS	'?', and complex '*' and '+', are implemented as circular
599*0Sstevel@tonic-gate    #		BRANCH structures using BACK.  Simple cases (one character
600*0Sstevel@tonic-gate    #		per match) are implemented with STAR and PLUS for speed
601*0Sstevel@tonic-gate    #		and to minimize recursive plunges.
602*0Sstevel@tonic-gate    #
603*0Sstevel@tonic-gate    STAR	node	Match this (simple) thing 0 or more times.
604*0Sstevel@tonic-gate    PLUS	node	Match this (simple) thing 1 or more times.
605*0Sstevel@tonic-gate
606*0Sstevel@tonic-gate    CURLY	sv 2	Match this simple thing {n,m} times.
607*0Sstevel@tonic-gate    CURLYN	no 2	Match next-after-this simple thing
608*0Sstevel@tonic-gate    #			{n,m} times, set parens.
609*0Sstevel@tonic-gate    CURLYM	no 2	Match this medium-complex thing {n,m} times.
610*0Sstevel@tonic-gate    CURLYX	sv 2	Match this complex thing {n,m} times.
611*0Sstevel@tonic-gate
612*0Sstevel@tonic-gate    # This terminator creates a loop structure for CURLYX
613*0Sstevel@tonic-gate    WHILEM	no	Do curly processing and see if rest matches.
614*0Sstevel@tonic-gate
615*0Sstevel@tonic-gate    # OPEN,CLOSE,GROUPP	...are numbered at compile time.
616*0Sstevel@tonic-gate    OPEN	num 1	Mark this point in input as start of #n.
617*0Sstevel@tonic-gate    CLOSE	num 1	Analogous to OPEN.
618*0Sstevel@tonic-gate
619*0Sstevel@tonic-gate    REF		num 1	Match some already matched string
620*0Sstevel@tonic-gate    REFF	num 1	Match already matched string, folded
621*0Sstevel@tonic-gate    REFFL	num 1	Match already matched string, folded in loc.
622*0Sstevel@tonic-gate
623*0Sstevel@tonic-gate    # grouping assertions
624*0Sstevel@tonic-gate    IFMATCH	off 1 2	Succeeds if the following matches.
625*0Sstevel@tonic-gate    UNLESSM	off 1 2	Fails if the following matches.
626*0Sstevel@tonic-gate    SUSPEND	off 1 1	"Independent" sub-regex.
627*0Sstevel@tonic-gate    IFTHEN	off 1 1	Switch, should be preceded by switcher .
628*0Sstevel@tonic-gate    GROUPP	num 1	Whether the group matched.
629*0Sstevel@tonic-gate
630*0Sstevel@tonic-gate    # Support for long regex
631*0Sstevel@tonic-gate    LONGJMP	off 1 1	Jump far away.
632*0Sstevel@tonic-gate    BRANCHJ	off 1 1	BRANCH with long offset.
633*0Sstevel@tonic-gate
634*0Sstevel@tonic-gate    # The heavy worker
635*0Sstevel@tonic-gate    EVAL	evl 1	Execute some Perl code.
636*0Sstevel@tonic-gate
637*0Sstevel@tonic-gate    # Modifiers
638*0Sstevel@tonic-gate    MINMOD	no	Next operator is not greedy.
639*0Sstevel@tonic-gate    LOGICAL	no	Next opcode should set the flag only.
640*0Sstevel@tonic-gate
641*0Sstevel@tonic-gate    # This is not used yet
642*0Sstevel@tonic-gate    RENUM	off 1 1	Group with independently numbered parens.
643*0Sstevel@tonic-gate
644*0Sstevel@tonic-gate    # This is not really a node, but an optimized away piece of a "long" node.
645*0Sstevel@tonic-gate    # To simplify debugging output, we mark it as if it were a node
646*0Sstevel@tonic-gate    OPTIMIZED	off	Placeholder for dump.
647*0Sstevel@tonic-gate
648*0Sstevel@tonic-gate=for unprinted-credits
649*0Sstevel@tonic-gateNext section M-J. Dominus (mjd-perl-patch+@plover.com) 20010421
650*0Sstevel@tonic-gate
651*0Sstevel@tonic-gateFollowing the optimizer information is a dump of the offset/length
652*0Sstevel@tonic-gatetable, here split across several lines:
653*0Sstevel@tonic-gate
654*0Sstevel@tonic-gate  Offsets: [45]
655*0Sstevel@tonic-gate  	1[4] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 5[1]
656*0Sstevel@tonic-gate  	0[0] 12[1] 0[0] 6[1] 0[0] 7[1] 0[0] 9[1] 8[1] 0[0] 10[1] 0[0]
657*0Sstevel@tonic-gate  	11[1] 0[0] 12[0] 12[0] 13[1] 0[0] 14[4] 0[0] 0[0] 0[0] 0[0]
658*0Sstevel@tonic-gate  	0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 18[1] 0[0] 19[1] 20[0]
659*0Sstevel@tonic-gate
660*0Sstevel@tonic-gateThe first line here indicates that the offset/length table contains 45
661*0Sstevel@tonic-gateentries.  Each entry is a pair of integers, denoted by C<offset[length]>.
662*0Sstevel@tonic-gateEntries are numbered starting with 1, so entry #1 here is C<1[4]> and
663*0Sstevel@tonic-gateentry #12 is C<5[1]>.  C<1[4]> indicates that the node labeled C<1:>
664*0Sstevel@tonic-gate(the C<1: ANYOF[bc]>) begins at character position 1 in the
665*0Sstevel@tonic-gatepre-compiled form of the regex, and has a length of 4 characters.
666*0Sstevel@tonic-gateC<5[1]> in position 12
667*0Sstevel@tonic-gateindicates that the node labeled C<12:>
668*0Sstevel@tonic-gate(the C<< 12: EXACT <d> >>) begins at character position 5 in the
669*0Sstevel@tonic-gatepre-compiled form of the regex, and has a length of 1 character.
670*0Sstevel@tonic-gateC<12[1]> in position 14
671*0Sstevel@tonic-gateindicates that the node labeled C<14:>
672*0Sstevel@tonic-gate(the C<< 14: CURLYX[0] {1,32767} >>) begins at character position 12 in the
673*0Sstevel@tonic-gatepre-compiled form of the regex, and has a length of 1 character---that
674*0Sstevel@tonic-gateis, it corresponds to the C<+> symbol in the precompiled regex.
675*0Sstevel@tonic-gate
676*0Sstevel@tonic-gateC<0[0]> items indicate that there is no corresponding node.
677*0Sstevel@tonic-gate
678*0Sstevel@tonic-gate=head2 Run-time output
679*0Sstevel@tonic-gate
680*0Sstevel@tonic-gateFirst of all, when doing a match, one may get no run-time output even
681*0Sstevel@tonic-gateif debugging is enabled.  This means that the regex engine was never
682*0Sstevel@tonic-gateentered and that all of the job was therefore done by the optimizer.
683*0Sstevel@tonic-gate
684*0Sstevel@tonic-gateIf the regex engine was entered, the output may look like this:
685*0Sstevel@tonic-gate
686*0Sstevel@tonic-gate  Matching `[bc]d(ef*g)+h[ij]k$' against `abcdefg__gh__'
687*0Sstevel@tonic-gate    Setting an EVAL scope, savestack=3
688*0Sstevel@tonic-gate     2 <ab> <cdefg__gh_>    |  1: ANYOF
689*0Sstevel@tonic-gate     3 <abc> <defg__gh_>    | 11: EXACT <d>
690*0Sstevel@tonic-gate     4 <abcd> <efg__gh_>    | 13: CURLYX {1,32767}
691*0Sstevel@tonic-gate     4 <abcd> <efg__gh_>    | 26:   WHILEM
692*0Sstevel@tonic-gate				0 out of 1..32767  cc=effff31c
693*0Sstevel@tonic-gate     4 <abcd> <efg__gh_>    | 15:     OPEN1
694*0Sstevel@tonic-gate     4 <abcd> <efg__gh_>    | 17:     EXACT <e>
695*0Sstevel@tonic-gate     5 <abcde> <fg__gh_>    | 19:     STAR
696*0Sstevel@tonic-gate			     EXACT <f> can match 1 times out of 32767...
697*0Sstevel@tonic-gate    Setting an EVAL scope, savestack=3
698*0Sstevel@tonic-gate     6 <bcdef> <g__gh__>    | 22:       EXACT <g>
699*0Sstevel@tonic-gate     7 <bcdefg> <__gh__>    | 24:       CLOSE1
700*0Sstevel@tonic-gate     7 <bcdefg> <__gh__>    | 26:       WHILEM
701*0Sstevel@tonic-gate				    1 out of 1..32767  cc=effff31c
702*0Sstevel@tonic-gate    Setting an EVAL scope, savestack=12
703*0Sstevel@tonic-gate     7 <bcdefg> <__gh__>    | 15:         OPEN1
704*0Sstevel@tonic-gate     7 <bcdefg> <__gh__>    | 17:         EXACT <e>
705*0Sstevel@tonic-gate       restoring \1 to 4(4)..7
706*0Sstevel@tonic-gate				    failed, try continuation...
707*0Sstevel@tonic-gate     7 <bcdefg> <__gh__>    | 27:         NOTHING
708*0Sstevel@tonic-gate     7 <bcdefg> <__gh__>    | 28:         EXACT <h>
709*0Sstevel@tonic-gate				    failed...
710*0Sstevel@tonic-gate				failed...
711*0Sstevel@tonic-gate
712*0Sstevel@tonic-gateThe most significant information in the output is about the particular I<node>
713*0Sstevel@tonic-gateof the compiled regex that is currently being tested against the target string.
714*0Sstevel@tonic-gateThe format of these lines is
715*0Sstevel@tonic-gate
716*0Sstevel@tonic-gateC<    >I<STRING-OFFSET> <I<PRE-STRING>> <I<POST-STRING>>   |I<ID>:  I<TYPE>
717*0Sstevel@tonic-gate
718*0Sstevel@tonic-gateThe I<TYPE> info is indented with respect to the backtracking level.
719*0Sstevel@tonic-gateOther incidental information appears interspersed within.
720*0Sstevel@tonic-gate
721*0Sstevel@tonic-gate=head1 Debugging Perl memory usage
722*0Sstevel@tonic-gate
723*0Sstevel@tonic-gatePerl is a profligate wastrel when it comes to memory use.  There
724*0Sstevel@tonic-gateis a saying that to estimate memory usage of Perl, assume a reasonable
725*0Sstevel@tonic-gatealgorithm for memory allocation, multiply that estimate by 10, and
726*0Sstevel@tonic-gatewhile you still may miss the mark, at least you won't be quite so
727*0Sstevel@tonic-gateastonished.  This is not absolutely true, but may provide a good
728*0Sstevel@tonic-gategrasp of what happens.
729*0Sstevel@tonic-gate
730*0Sstevel@tonic-gateAssume that an integer cannot take less than 20 bytes of memory, a
731*0Sstevel@tonic-gatefloat cannot take less than 24 bytes, a string cannot take less
732*0Sstevel@tonic-gatethan 32 bytes (all these examples assume 32-bit architectures, the
733*0Sstevel@tonic-gateresult are quite a bit worse on 64-bit architectures).  If a variable
734*0Sstevel@tonic-gateis accessed in two of three different ways (which require an integer,
735*0Sstevel@tonic-gatea float, or a string), the memory footprint may increase yet another
736*0Sstevel@tonic-gate20 bytes.  A sloppy malloc(3) implementation can inflate these
737*0Sstevel@tonic-gatenumbers dramatically.
738*0Sstevel@tonic-gate
739*0Sstevel@tonic-gateOn the opposite end of the scale, a declaration like
740*0Sstevel@tonic-gate
741*0Sstevel@tonic-gate  sub foo;
742*0Sstevel@tonic-gate
743*0Sstevel@tonic-gatemay take up to 500 bytes of memory, depending on which release of Perl
744*0Sstevel@tonic-gateyou're running.
745*0Sstevel@tonic-gate
746*0Sstevel@tonic-gateAnecdotal estimates of source-to-compiled code bloat suggest an
747*0Sstevel@tonic-gateeightfold increase.  This means that the compiled form of reasonable
748*0Sstevel@tonic-gate(normally commented, properly indented etc.) code will take
749*0Sstevel@tonic-gateabout eight times more space in memory than the code took
750*0Sstevel@tonic-gateon disk.
751*0Sstevel@tonic-gate
752*0Sstevel@tonic-gateThe B<-DL> command-line switch is obsolete since circa Perl 5.6.0
753*0Sstevel@tonic-gate(it was available only if Perl was built with C<-DDEBUGGING>).
754*0Sstevel@tonic-gateThe switch was used to track Perl's memory allocations and possible
755*0Sstevel@tonic-gatememory leaks.  These days the use of malloc debugging tools like
756*0Sstevel@tonic-gateF<Purify> or F<valgrind> is suggested instead.
757*0Sstevel@tonic-gate
758*0Sstevel@tonic-gateOne way to find out how much memory is being used by Perl data
759*0Sstevel@tonic-gatestructures is to install the Devel::Size module from CPAN: it gives
760*0Sstevel@tonic-gateyou the minimum number of bytes required to store a particular data
761*0Sstevel@tonic-gatestructure.  Please be mindful of the difference between the size()
762*0Sstevel@tonic-gateand total_size().
763*0Sstevel@tonic-gate
764*0Sstevel@tonic-gateIf Perl has been compiled using Perl's malloc you can analyze Perl
765*0Sstevel@tonic-gatememory usage by setting the $ENV{PERL_DEBUG_MSTATS}.
766*0Sstevel@tonic-gate
767*0Sstevel@tonic-gate=head2 Using C<$ENV{PERL_DEBUG_MSTATS}>
768*0Sstevel@tonic-gate
769*0Sstevel@tonic-gateIf your perl is using Perl's malloc() and was compiled with the
770*0Sstevel@tonic-gatenecessary switches (this is the default), then it will print memory
771*0Sstevel@tonic-gateusage statistics after compiling your code when C<< $ENV{PERL_DEBUG_MSTATS}
772*0Sstevel@tonic-gate> 1 >>, and before termination of the program when C<<
773*0Sstevel@tonic-gate$ENV{PERL_DEBUG_MSTATS} >= 1 >>.  The report format is similar to
774*0Sstevel@tonic-gatethe following example:
775*0Sstevel@tonic-gate
776*0Sstevel@tonic-gate  $ PERL_DEBUG_MSTATS=2 perl -e "require Carp"
777*0Sstevel@tonic-gate  Memory allocation statistics after compilation: (buckets 4(4)..8188(8192)
778*0Sstevel@tonic-gate     14216 free:   130   117    28     7     9   0   2     2   1 0 0
779*0Sstevel@tonic-gate		437    61    36     0     5
780*0Sstevel@tonic-gate     60924 used:   125   137   161    55     7   8   6    16   2 0 1
781*0Sstevel@tonic-gate		 74   109   304    84    20
782*0Sstevel@tonic-gate  Total sbrk(): 77824/21:119. Odd ends: pad+heads+chain+tail: 0+636+0+2048.
783*0Sstevel@tonic-gate  Memory allocation statistics after execution:   (buckets 4(4)..8188(8192)
784*0Sstevel@tonic-gate     30888 free:   245    78    85    13     6   2   1     3   2 0 1
785*0Sstevel@tonic-gate		315   162    39    42    11
786*0Sstevel@tonic-gate    175816 used:   265   176  1112   111    26  22  11    27   2 1 1
787*0Sstevel@tonic-gate		196   178  1066   798    39
788*0Sstevel@tonic-gate  Total sbrk(): 215040/47:145. Odd ends: pad+heads+chain+tail: 0+2192+0+6144.
789*0Sstevel@tonic-gate
790*0Sstevel@tonic-gateIt is possible to ask for such a statistic at arbitrary points in
791*0Sstevel@tonic-gateyour execution using the mstat() function out of the standard
792*0Sstevel@tonic-gateDevel::Peek module.
793*0Sstevel@tonic-gate
794*0Sstevel@tonic-gateHere is some explanation of that format:
795*0Sstevel@tonic-gate
796*0Sstevel@tonic-gate=over 4
797*0Sstevel@tonic-gate
798*0Sstevel@tonic-gate=item C<buckets SMALLEST(APPROX)..GREATEST(APPROX)>
799*0Sstevel@tonic-gate
800*0Sstevel@tonic-gatePerl's malloc() uses bucketed allocations.  Every request is rounded
801*0Sstevel@tonic-gateup to the closest bucket size available, and a bucket is taken from
802*0Sstevel@tonic-gatethe pool of buckets of that size.
803*0Sstevel@tonic-gate
804*0Sstevel@tonic-gateThe line above describes the limits of buckets currently in use.
805*0Sstevel@tonic-gateEach bucket has two sizes: memory footprint and the maximal size
806*0Sstevel@tonic-gateof user data that can fit into this bucket.  Suppose in the above
807*0Sstevel@tonic-gateexample that the smallest bucket were size 4.  The biggest bucket
808*0Sstevel@tonic-gatewould have usable size 8188, and the memory footprint would be 8192.
809*0Sstevel@tonic-gate
810*0Sstevel@tonic-gateIn a Perl built for debugging, some buckets may have negative usable
811*0Sstevel@tonic-gatesize.  This means that these buckets cannot (and will not) be used.
812*0Sstevel@tonic-gateFor larger buckets, the memory footprint may be one page greater
813*0Sstevel@tonic-gatethan a power of 2.  If so, case the corresponding power of two is
814*0Sstevel@tonic-gateprinted in the C<APPROX> field above.
815*0Sstevel@tonic-gate
816*0Sstevel@tonic-gate=item Free/Used
817*0Sstevel@tonic-gate
818*0Sstevel@tonic-gateThe 1 or 2 rows of numbers following that correspond to the number
819*0Sstevel@tonic-gateof buckets of each size between C<SMALLEST> and C<GREATEST>.  In
820*0Sstevel@tonic-gatethe first row, the sizes (memory footprints) of buckets are powers
821*0Sstevel@tonic-gateof two--or possibly one page greater.  In the second row, if present,
822*0Sstevel@tonic-gatethe memory footprints of the buckets are between the memory footprints
823*0Sstevel@tonic-gateof two buckets "above".
824*0Sstevel@tonic-gate
825*0Sstevel@tonic-gateFor example, suppose under the previous example, the memory footprints
826*0Sstevel@tonic-gatewere
827*0Sstevel@tonic-gate
828*0Sstevel@tonic-gate     free:    8     16    32    64    128  256 512 1024 2048 4096 8192
829*0Sstevel@tonic-gate	   4     12    24    48    80
830*0Sstevel@tonic-gate
831*0Sstevel@tonic-gateWith non-C<DEBUGGING> perl, the buckets starting from C<128> have
832*0Sstevel@tonic-gatea 4-byte overhead, and thus an 8192-long bucket may take up to
833*0Sstevel@tonic-gate8188-byte allocations.
834*0Sstevel@tonic-gate
835*0Sstevel@tonic-gate=item C<Total sbrk(): SBRKed/SBRKs:CONTINUOUS>
836*0Sstevel@tonic-gate
837*0Sstevel@tonic-gateThe first two fields give the total amount of memory perl sbrk(2)ed
838*0Sstevel@tonic-gate(ess-broken? :-) and number of sbrk(2)s used.  The third number is
839*0Sstevel@tonic-gatewhat perl thinks about continuity of returned chunks.  So long as
840*0Sstevel@tonic-gatethis number is positive, malloc() will assume that it is probable
841*0Sstevel@tonic-gatethat sbrk(2) will provide continuous memory.
842*0Sstevel@tonic-gate
843*0Sstevel@tonic-gateMemory allocated by external libraries is not counted.
844*0Sstevel@tonic-gate
845*0Sstevel@tonic-gate=item C<pad: 0>
846*0Sstevel@tonic-gate
847*0Sstevel@tonic-gateThe amount of sbrk(2)ed memory needed to keep buckets aligned.
848*0Sstevel@tonic-gate
849*0Sstevel@tonic-gate=item C<heads: 2192>
850*0Sstevel@tonic-gate
851*0Sstevel@tonic-gateAlthough memory overhead of bigger buckets is kept inside the bucket, for
852*0Sstevel@tonic-gatesmaller buckets, it is kept in separate areas.  This field gives the
853*0Sstevel@tonic-gatetotal size of these areas.
854*0Sstevel@tonic-gate
855*0Sstevel@tonic-gate=item C<chain: 0>
856*0Sstevel@tonic-gate
857*0Sstevel@tonic-gatemalloc() may want to subdivide a bigger bucket into smaller buckets.
858*0Sstevel@tonic-gateIf only a part of the deceased bucket is left unsubdivided, the rest
859*0Sstevel@tonic-gateis kept as an element of a linked list.  This field gives the total
860*0Sstevel@tonic-gatesize of these chunks.
861*0Sstevel@tonic-gate
862*0Sstevel@tonic-gate=item C<tail: 6144>
863*0Sstevel@tonic-gate
864*0Sstevel@tonic-gateTo minimize the number of sbrk(2)s, malloc() asks for more memory.  This
865*0Sstevel@tonic-gatefield gives the size of the yet unused part, which is sbrk(2)ed, but
866*0Sstevel@tonic-gatenever touched.
867*0Sstevel@tonic-gate
868*0Sstevel@tonic-gate=back
869*0Sstevel@tonic-gate
870*0Sstevel@tonic-gate=head2 Example of using B<-DL> switch
871*0Sstevel@tonic-gate
872*0Sstevel@tonic-gate(Note that -DL is obsolete since circa 5.6.0, and even before that
873*0Sstevel@tonic-gatePerl needed to be compiled with -DDEBUGGING.)
874*0Sstevel@tonic-gate
875*0Sstevel@tonic-gateBelow we show how to analyse memory usage by
876*0Sstevel@tonic-gate
877*0Sstevel@tonic-gate  do 'lib/auto/POSIX/autosplit.ix';
878*0Sstevel@tonic-gate
879*0Sstevel@tonic-gateThe file in question contains a header and 146 lines similar to
880*0Sstevel@tonic-gate
881*0Sstevel@tonic-gate  sub getcwd;
882*0Sstevel@tonic-gate
883*0Sstevel@tonic-gateB<WARNING>: The discussion below supposes 32-bit architecture.  In
884*0Sstevel@tonic-gatenewer releases of Perl, memory usage of the constructs discussed
885*0Sstevel@tonic-gatehere is greatly improved, but the story discussed below is a real-life
886*0Sstevel@tonic-gatestory.  This story is mercilessly terse, and assumes rather more than cursory
887*0Sstevel@tonic-gateknowledge of Perl internals.  Type space to continue, `q' to quit.
888*0Sstevel@tonic-gate(Actually, you just want to skip to the next section.)
889*0Sstevel@tonic-gate
890*0Sstevel@tonic-gateHere is the itemized list of Perl allocations performed during parsing
891*0Sstevel@tonic-gateof this file:
892*0Sstevel@tonic-gate
893*0Sstevel@tonic-gate !!! "after" at test.pl line 3.
894*0Sstevel@tonic-gate    Id  subtot   4   8  12  16  20  24  28  32  36  40  48  56  64  72  80 80+
895*0Sstevel@tonic-gate  0 02   13752   .   .   .   . 294   .   .   .   .   .   .   .   .   .   .   4
896*0Sstevel@tonic-gate  0 54    5545   .   .   8 124  16   .   .   .   1   1   .   .   .   .   .   3
897*0Sstevel@tonic-gate  5 05      32   .   .   .   .   .   .   .   1   .   .   .   .   .   .   .   .
898*0Sstevel@tonic-gate  6 02    7152   .   .   .   .   .   .   .   .   .   . 149   .   .   .   .   .
899*0Sstevel@tonic-gate  7 02    3600   .   .   .   .   . 150   .   .   .   .   .   .   .   .   .   .
900*0Sstevel@tonic-gate  7 03      64   .  -1   .   1   .   .   2   .   .   .   .   .   .   .   .   .
901*0Sstevel@tonic-gate  7 04    7056   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   7
902*0Sstevel@tonic-gate  7 17   38404   .   .   .   .   .   .   .   1   .   . 442 149   .   . 147   .
903*0Sstevel@tonic-gate  9 03    2078  17 249  32   .   .   .   .   2   .   .   .   .   .   .   .   .
904*0Sstevel@tonic-gate
905*0Sstevel@tonic-gate
906*0Sstevel@tonic-gateTo see this list, insert two C<warn('!...')> statements around the call:
907*0Sstevel@tonic-gate
908*0Sstevel@tonic-gate  warn('!');
909*0Sstevel@tonic-gate  do 'lib/auto/POSIX/autosplit.ix';
910*0Sstevel@tonic-gate  warn('!!! "after"');
911*0Sstevel@tonic-gate
912*0Sstevel@tonic-gateand run it with Perl's B<-DL> option.  The first warn() will print
913*0Sstevel@tonic-gatememory allocation info before parsing the file and will memorize
914*0Sstevel@tonic-gatethe statistics at this point (we ignore what it prints).  The second
915*0Sstevel@tonic-gatewarn() prints increments with respect to these memorized data.  This
916*0Sstevel@tonic-gateis the printout shown above.
917*0Sstevel@tonic-gate
918*0Sstevel@tonic-gateDifferent I<Id>s on the left correspond to different subsystems of
919*0Sstevel@tonic-gatethe perl interpreter.  They are just the first argument given to
920*0Sstevel@tonic-gatethe perl memory allocation API named New().  To find what C<9 03>
921*0Sstevel@tonic-gatemeans, just B<grep> the perl source for C<903>.  You'll find it in
922*0Sstevel@tonic-gateF<util.c>, function savepvn().  (I know, you wonder why we told you
923*0Sstevel@tonic-gateto B<grep> and then gave away the answer.  That's because grepping
924*0Sstevel@tonic-gatethe source is good for the soul.)  This function is used to store
925*0Sstevel@tonic-gatea copy of an existing chunk of memory.  Using a C debugger, one can
926*0Sstevel@tonic-gatesee that the function was called either directly from gv_init() or
927*0Sstevel@tonic-gatevia sv_magic(), and that gv_init() is called from gv_fetchpv()--which
928*0Sstevel@tonic-gatewas itself called from newSUB().  Please stop to catch your breath now.
929*0Sstevel@tonic-gate
930*0Sstevel@tonic-gateB<NOTE>: To reach this point in the debugger and skip the calls to
931*0Sstevel@tonic-gatesavepvn() during the compilation of the main program, you should
932*0Sstevel@tonic-gateset a C breakpoint
933*0Sstevel@tonic-gatein Perl_warn(), continue until this point is reached, and I<then> set
934*0Sstevel@tonic-gatea C breakpoint in Perl_savepvn().  Note that you may need to skip a
935*0Sstevel@tonic-gatehandful of Perl_savepvn() calls that do not correspond to mass production
936*0Sstevel@tonic-gateof CVs (there are more C<903> allocations than 146 similar lines of
937*0Sstevel@tonic-gateF<lib/auto/POSIX/autosplit.ix>).  Note also that C<Perl_> prefixes are
938*0Sstevel@tonic-gateadded by macroization code in perl header files to avoid conflicts
939*0Sstevel@tonic-gatewith external libraries.
940*0Sstevel@tonic-gate
941*0Sstevel@tonic-gateAnyway, we see that C<903> ids correspond to creation of globs, twice
942*0Sstevel@tonic-gateper glob - for glob name, and glob stringification magic.
943*0Sstevel@tonic-gate
944*0Sstevel@tonic-gateHere are explanations for other I<Id>s above:
945*0Sstevel@tonic-gate
946*0Sstevel@tonic-gate=over 4
947*0Sstevel@tonic-gate
948*0Sstevel@tonic-gate=item C<717>
949*0Sstevel@tonic-gate
950*0Sstevel@tonic-gateCreates bigger C<XPV*> structures.  In the case above, it
951*0Sstevel@tonic-gatecreates 3 C<AV>s per subroutine, one for a list of lexical variable
952*0Sstevel@tonic-gatenames, one for a scratchpad (which contains lexical variables and
953*0Sstevel@tonic-gateC<targets>), and one for the array of scratchpads needed for
954*0Sstevel@tonic-gaterecursion.
955*0Sstevel@tonic-gate
956*0Sstevel@tonic-gateIt also creates a C<GV> and a C<CV> per subroutine, all called from
957*0Sstevel@tonic-gatestart_subparse().
958*0Sstevel@tonic-gate
959*0Sstevel@tonic-gate=item C<002>
960*0Sstevel@tonic-gate
961*0Sstevel@tonic-gateCreates a C array corresponding to the C<AV> of scratchpads and the
962*0Sstevel@tonic-gatescratchpad itself.  The first fake entry of this scratchpad is
963*0Sstevel@tonic-gatecreated though the subroutine itself is not defined yet.
964*0Sstevel@tonic-gate
965*0Sstevel@tonic-gateIt also creates C arrays to keep data for the stash.  This is one HV,
966*0Sstevel@tonic-gatebut it grows; thus, there are 4 big allocations: the big chunks are not
967*0Sstevel@tonic-gatefreed, but are kept as additional arenas for C<SV> allocations.
968*0Sstevel@tonic-gate
969*0Sstevel@tonic-gate=item C<054>
970*0Sstevel@tonic-gate
971*0Sstevel@tonic-gateCreates a C<HEK> for the name of the glob for the subroutine.  This
972*0Sstevel@tonic-gatename is a key in a I<stash>.
973*0Sstevel@tonic-gate
974*0Sstevel@tonic-gateBig allocations with this I<Id> correspond to allocations of new
975*0Sstevel@tonic-gatearenas to keep C<HE>.
976*0Sstevel@tonic-gate
977*0Sstevel@tonic-gate=item C<602>
978*0Sstevel@tonic-gate
979*0Sstevel@tonic-gateCreates a C<GP> for the glob for the subroutine.
980*0Sstevel@tonic-gate
981*0Sstevel@tonic-gate=item C<702>
982*0Sstevel@tonic-gate
983*0Sstevel@tonic-gateCreates the C<MAGIC> for the glob for the subroutine.
984*0Sstevel@tonic-gate
985*0Sstevel@tonic-gate=item C<704>
986*0Sstevel@tonic-gate
987*0Sstevel@tonic-gateCreates I<arenas> which keep SVs.
988*0Sstevel@tonic-gate
989*0Sstevel@tonic-gate=back
990*0Sstevel@tonic-gate
991*0Sstevel@tonic-gate=head2 B<-DL> details
992*0Sstevel@tonic-gate
993*0Sstevel@tonic-gateIf Perl is run with B<-DL> option, then warn()s that start with `!'
994*0Sstevel@tonic-gatebehave specially.  They print a list of I<categories> of memory
995*0Sstevel@tonic-gateallocations, and statistics of allocations of different sizes for
996*0Sstevel@tonic-gatethese categories.
997*0Sstevel@tonic-gate
998*0Sstevel@tonic-gateIf warn() string starts with
999*0Sstevel@tonic-gate
1000*0Sstevel@tonic-gate=over 4
1001*0Sstevel@tonic-gate
1002*0Sstevel@tonic-gate=item C<!!!>
1003*0Sstevel@tonic-gate
1004*0Sstevel@tonic-gateprint changed categories only, print the differences in counts of allocations.
1005*0Sstevel@tonic-gate
1006*0Sstevel@tonic-gate=item C<!!>
1007*0Sstevel@tonic-gate
1008*0Sstevel@tonic-gateprint grown categories only; print the absolute values of counts, and totals.
1009*0Sstevel@tonic-gate
1010*0Sstevel@tonic-gate=item C<!>
1011*0Sstevel@tonic-gate
1012*0Sstevel@tonic-gateprint nonempty categories, print the absolute values of counts and totals.
1013*0Sstevel@tonic-gate
1014*0Sstevel@tonic-gate=back
1015*0Sstevel@tonic-gate
1016*0Sstevel@tonic-gate=head2 Limitations of B<-DL> statistics
1017*0Sstevel@tonic-gate
1018*0Sstevel@tonic-gateIf an extension or external library does not use the Perl API to
1019*0Sstevel@tonic-gateallocate memory, such allocations are not counted.
1020*0Sstevel@tonic-gate
1021*0Sstevel@tonic-gate=head1 SEE ALSO
1022*0Sstevel@tonic-gate
1023*0Sstevel@tonic-gateL<perldebug>,
1024*0Sstevel@tonic-gateL<perlguts>,
1025*0Sstevel@tonic-gateL<perlrun>
1026*0Sstevel@tonic-gateL<re>,
1027*0Sstevel@tonic-gateand
1028*0Sstevel@tonic-gateL<Devel::DProf>.
1029