Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / man3 / Devel::Peek.3
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Devel::Peek 3"
132.TH Devel::Peek 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134Devel::Peek \- A data debugging tool for the XS programmer
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 5
138\& use Devel::Peek;
139\& Dump( $a );
140\& Dump( $a, 5 );
141\& DumpArray( 5, $a, $b, ... );
142\& mstat "Point 5";
143.Ve
144.PP
145.Vb 1
146\& use Devel::Peek ':opd=st';
147.Ve
148.SH "DESCRIPTION"
149.IX Header "DESCRIPTION"
150Devel::Peek contains functions which allows raw Perl datatypes to be
151manipulated from a Perl script. This is used by those who do \s-1XS\s0 programming
152to check that the data they are sending from C to Perl looks as they think
153it should look. The trick, then, is to know what the raw datatype is
154supposed to look like when it gets to Perl. This document offers some tips
155and hints to describe good and bad raw data.
156.PP
157It is very possible that this document will fall far short of being useful
158to the casual reader. The reader is expected to understand the material in
159the first few sections of perlguts.
160.PP
161Devel::Peek supplies a \f(CW\*(C`Dump()\*(C'\fR function which can dump a raw Perl
162datatype, and \f(CW\*(C`mstat("marker")\*(C'\fR function to report on memory usage
163(if perl is compiled with corresponding option). The function
164\&\fIDeadCode()\fR provides statistics on the data \*(L"frozen\*(R" into inactive
165\&\f(CW\*(C`CV\*(C'\fR. Devel::Peek also supplies \f(CW\*(C`SvREFCNT()\*(C'\fR, \f(CW\*(C`SvREFCNT_inc()\*(C'\fR, and
166\&\f(CW\*(C`SvREFCNT_dec()\*(C'\fR which can query, increment, and decrement reference
167counts on SVs. This document will take a passive, and safe, approach
168to data debugging and for that it will describe only the \f(CW\*(C`Dump()\*(C'\fR
169function.
170.PP
171Function \f(CW\*(C`DumpArray()\*(C'\fR allows dumping of multiple values (useful when you
172need to analyze returns of functions).
173.PP
174The global variable \f(CW$Devel::Peek::pv_limit\fR can be set to limit the
175number of character printed in various string values. Setting it to 0
176means no limit.
177.PP
178If \f(CW\*(C`use Devel::Peek\*(C'\fR directive has a \f(CW\*(C`:opd=FLAGS\*(C'\fR argument,
179this switches on debugging of opcode dispatch. \f(CW\*(C`FLAGS\*(C'\fR should be a
180combination of \f(CW\*(C`s\*(C'\fR, \f(CW\*(C`t\*(C'\fR, and \f(CW\*(C`P\*(C'\fR (see \fB\-D\fR flags in perlrun).
181\&\f(CW\*(C`:opd\*(C'\fR is a shortcut for \f(CW\*(C`:opd=st\*(C'\fR.
182.Sh "Runtime debugging"
183.IX Subsection "Runtime debugging"
184\&\f(CW\*(C`CvGV($cv)\*(C'\fR return one of the globs associated to a subroutine reference \f(CW$cv\fR.
185.PP
186\&\fIdebug_flags()\fR returns a string representation of \f(CW$^D\fR (similar to
187what is allowed for \fB\-D\fR flag). When called with a numeric argument,
188sets $^D to the corresponding value. When called with an argument of
189the form \f(CW"flags\-flags"\fR, set on/off bits of \f(CW$^D\fR corresponding to
190letters before/after \f(CW\*(C`\-\*(C'\fR. (The returned value is for \f(CW$^D\fR before
191the modification.)
192.PP
193\&\fIrunops_debug()\fR returns true if the current \fIopcode dispatcher\fR is the
194debugging one. When called with an argument, switches to debugging or
195non-debugging dispatcher depending on the argument (active for
196newly-entered subs/etc only). (The returned value is for the dispatcher before the modification.)
197.Sh "Memory footprint debugging"
198.IX Subsection "Memory footprint debugging"
199When perl is compiled with support for memory footprint debugging
200(default with Perl's \fImalloc()\fR), Devel::Peek provides an access to this \s-1API\s0.
201.PP
202Use \fImstat()\fR function to emit a memory state statistic to the terminal.
203For more information on the format of output of \fImstat()\fR see
204"Using \f(CW$ENV{PERL_DEBUG_MSTATS}\fR" in perldebguts.
205.PP
206Three additional functions allow access to this statistic from Perl.
207First, use \f(CW\*(C`mstats_fillhash(%hash)\*(C'\fR to get the information contained
208in the output of \fImstat()\fR into \f(CW%hash\fR. The field of this hash are
209.PP
210.Vb 2
211\& minbucket nbuckets sbrk_good sbrk_slack sbrked_remains sbrks start_slack
212\& topbucket topbucket_ev topbucket_odd total total_chain total_sbrk totfree
213.Ve
214.PP
215Two additional fields \f(CW\*(C`free\*(C'\fR, \f(CW\*(C`used\*(C'\fR contain array references which
216provide per-bucket count of free and used chunks. Two other fields
217\&\f(CW\*(C`mem_size\*(C'\fR, \f(CW\*(C`available_size\*(C'\fR contain array references which provide
218the information about the allocated size and usable size of chunks in
219each bucket. Again, see "Using \f(CW$ENV{PERL_DEBUG_MSTATS}\fR" in perldebguts
220for details.
221.PP
222Keep in mind that only the first several \*(L"odd\-numbered\*(R" buckets are
223used, so the information on size of the \*(L"odd\-numbered\*(R" buckets which are
224not used is probably meaningless.
225.PP
226The information in
227.PP
228.Vb 1
229\& mem_size available_size minbucket nbuckets
230.Ve
231.PP
232is the property of a particular build of perl, and does not depend on
233the current process. If you do not provide the optional argument to
234the functions \fImstats_fillhash()\fR, \fIfill_mstats()\fR, \fImstats2hash()\fR, then
235the information in fields \f(CW\*(C`mem_size\*(C'\fR, \f(CW\*(C`available_size\*(C'\fR is not
236updated.
237.PP
238\&\f(CW\*(C`fill_mstats($buf)\*(C'\fR is a much cheaper call (both speedwise and
239memory\-wise) which collects the statistic into \f(CW$buf\fR in
240machine-readable form. At a later moment you may need to call
241\&\f(CW\*(C`mstats2hash($buf, %hash)\*(C'\fR to use this information to fill \f(CW%hash\fR.
242.PP
243All three APIs \f(CW\*(C`fill_mstats($buf)\*(C'\fR, \f(CW\*(C`mstats_fillhash(%hash)\*(C'\fR, and
244\&\f(CW\*(C`mstats2hash($buf, %hash)\*(C'\fR are designed to allocate no memory if used
245\&\fIthe second time\fR on the same \f(CW$buf\fR and/or \f(CW%hash\fR.
246.PP
247So, if you want to collect memory info in a cycle, you may call
248.PP
249.Vb 3
250\& $#buf = 999;
251\& fill_mstats($_) for @buf;
252\& mstats_fillhash(%report, 1); # Static info too
253.Ve
254.PP
255.Vb 8
256\& foreach (@buf) {
257\& # Do something...
258\& fill_mstats $_; # Collect statistic
259\& }
260\& foreach (@buf) {
261\& mstats2hash($_, %report); # Preserve static info
262\& # Do something with %report
263\& }
264.Ve
265.SH "EXAMPLES"
266.IX Header "EXAMPLES"
267The following examples don't attempt to show everything as that would be a
268monumental task, and, frankly, we don't want this manpage to be an internals
269document for Perl. The examples do demonstrate some basics of the raw Perl
270datatypes, and should suffice to get most determined people on their way.
271There are no guidewires or safety nets, nor blazed trails, so be prepared to
272travel alone from this point and on and, if at all possible, don't fall into
273the quicksand (it's bad for business).
274.PP
275Oh, one final bit of advice: take perlguts with you. When you return we
276expect to see it well\-thumbed.
277.Sh "A simple scalar string"
278.IX Subsection "A simple scalar string"
279Let's begin by looking a simple scalar which is holding a string.
280.PP
281.Vb 3
282\& use Devel::Peek;
283\& $a = "hello";
284\& Dump $a;
285.Ve
286.PP
287The output:
288.PP
289.Vb 7
290\& SV = PVIV(0xbc288)
291\& REFCNT = 1
292\& FLAGS = (POK,pPOK)
293\& IV = 0
294\& PV = 0xb2048 "hello"\e0
295\& CUR = 5
296\& LEN = 6
297.Ve
298.PP
299This says \f(CW$a\fR is an \s-1SV\s0, a scalar. The scalar is a \s-1PVIV\s0, a string.
300Its reference count is 1. It has the \f(CW\*(C`POK\*(C'\fR flag set, meaning its
301current \s-1PV\s0 field is valid. Because \s-1POK\s0 is set we look at the \s-1PV\s0 item
302to see what is in the scalar. The \e0 at the end indicate that this
303\&\s-1PV\s0 is properly NUL\-terminated.
304If the \s-1FLAGS\s0 had been \s-1IOK\s0 we would look
305at the \s-1IV\s0 item. \s-1CUR\s0 indicates the number of characters in the \s-1PV\s0.
306\&\s-1LEN\s0 indicates the number of bytes requested for the \s-1PV\s0 (one more than
307\&\s-1CUR\s0, in this case, because \s-1LEN\s0 includes an extra byte for the
308end-of-string marker).
309.Sh "A simple scalar number"
310.IX Subsection "A simple scalar number"
311If the scalar contains a number the raw \s-1SV\s0 will be leaner.
312.PP
313.Vb 3
314\& use Devel::Peek;
315\& $a = 42;
316\& Dump $a;
317.Ve
318.PP
319The output:
320.PP
321.Vb 4
322\& SV = IV(0xbc818)
323\& REFCNT = 1
324\& FLAGS = (IOK,pIOK)
325\& IV = 42
326.Ve
327.PP
328This says \f(CW$a\fR is an \s-1SV\s0, a scalar. The scalar is an \s-1IV\s0, a number. Its
329reference count is 1. It has the \f(CW\*(C`IOK\*(C'\fR flag set, meaning it is currently
330being evaluated as a number. Because \s-1IOK\s0 is set we look at the \s-1IV\s0 item to
331see what is in the scalar.
332.Sh "A simple scalar with an extra reference"
333.IX Subsection "A simple scalar with an extra reference"
334If the scalar from the previous example had an extra reference:
335.PP
336.Vb 4
337\& use Devel::Peek;
338\& $a = 42;
339\& $b = \e$a;
340\& Dump $a;
341.Ve
342.PP
343The output:
344.PP
345.Vb 4
346\& SV = IV(0xbe860)
347\& REFCNT = 2
348\& FLAGS = (IOK,pIOK)
349\& IV = 42
350.Ve
351.PP
352Notice that this example differs from the previous example only in its
353reference count. Compare this to the next example, where we dump \f(CW$b\fR
354instead of \f(CW$a\fR.
355.Sh "A reference to a simple scalar"
356.IX Subsection "A reference to a simple scalar"
357This shows what a reference looks like when it references a simple scalar.
358.PP
359.Vb 4
360\& use Devel::Peek;
361\& $a = 42;
362\& $b = \e$a;
363\& Dump $b;
364.Ve
365.PP
366The output:
367.PP
368.Vb 8
369\& SV = RV(0xf041c)
370\& REFCNT = 1
371\& FLAGS = (ROK)
372\& RV = 0xbab08
373\& SV = IV(0xbe860)
374\& REFCNT = 2
375\& FLAGS = (IOK,pIOK)
376\& IV = 42
377.Ve
378.PP
379Starting from the top, this says \f(CW$b\fR is an \s-1SV\s0. The scalar is an \s-1RV\s0, a
380reference. It has the \f(CW\*(C`ROK\*(C'\fR flag set, meaning it is a reference. Because
381\&\s-1ROK\s0 is set we have an \s-1RV\s0 item rather than an \s-1IV\s0 or \s-1PV\s0. Notice that Dump
382follows the reference and shows us what \f(CW$b\fR was referencing. We see the
383same \f(CW$a\fR that we found in the previous example.
384.PP
385Note that the value of \f(CW\*(C`RV\*(C'\fR coincides with the numbers we see when we
386stringify \f(CW$b\fR. The addresses inside \s-1\fIRV\s0()\fR and \s-1\fIIV\s0()\fR are addresses of
387\&\f(CW\*(C`X***\*(C'\fR structure which holds the current state of an \f(CW\*(C`SV\*(C'\fR. This
388address may change during lifetime of an \s-1SV\s0.
389.Sh "A reference to an array"
390.IX Subsection "A reference to an array"
391This shows what a reference to an array looks like.
392.PP
393.Vb 3
394\& use Devel::Peek;
395\& $a = [42];
396\& Dump $a;
397.Ve
398.PP
399The output:
400.PP
401.Vb 20
402\& SV = RV(0xf041c)
403\& REFCNT = 1
404\& FLAGS = (ROK)
405\& RV = 0xb2850
406\& SV = PVAV(0xbd448)
407\& REFCNT = 1
408\& FLAGS = ()
409\& IV = 0
410\& NV = 0
411\& ARRAY = 0xb2048
412\& ALLOC = 0xb2048
413\& FILL = 0
414\& MAX = 0
415\& ARYLEN = 0x0
416\& FLAGS = (REAL)
417\& Elt No. 0 0xb5658
418\& SV = IV(0xbe860)
419\& REFCNT = 1
420\& FLAGS = (IOK,pIOK)
421\& IV = 42
422.Ve
423.PP
424This says \f(CW$a\fR is an \s-1SV\s0 and that it is an \s-1RV\s0. That \s-1RV\s0 points to
425another \s-1SV\s0 which is a \s-1PVAV\s0, an array. The array has one element,
426element zero, which is another \s-1SV\s0. The field \f(CW\*(C`FILL\*(C'\fR above indicates
427the last element in the array, similar to \f(CW\*(C`$#$a\*(C'\fR.
428.PP
429If \f(CW$a\fR pointed to an array of two elements then we would see the
430following.
431.PP
432.Vb 3
433\& use Devel::Peek 'Dump';
434\& $a = [42,24];
435\& Dump $a;
436.Ve
437.PP
438The output:
439.PP
440.Vb 25
441\& SV = RV(0xf041c)
442\& REFCNT = 1
443\& FLAGS = (ROK)
444\& RV = 0xb2850
445\& SV = PVAV(0xbd448)
446\& REFCNT = 1
447\& FLAGS = ()
448\& IV = 0
449\& NV = 0
450\& ARRAY = 0xb2048
451\& ALLOC = 0xb2048
452\& FILL = 0
453\& MAX = 0
454\& ARYLEN = 0x0
455\& FLAGS = (REAL)
456\& Elt No. 0 0xb5658
457\& SV = IV(0xbe860)
458\& REFCNT = 1
459\& FLAGS = (IOK,pIOK)
460\& IV = 42
461\& Elt No. 1 0xb5680
462\& SV = IV(0xbe818)
463\& REFCNT = 1
464\& FLAGS = (IOK,pIOK)
465\& IV = 24
466.Ve
467.PP
468Note that \f(CW\*(C`Dump\*(C'\fR will not report \fIall\fR the elements in the array,
469only several first (depending on how deep it already went into the
470report tree).
471.Sh "A reference to a hash"
472.IX Subsection "A reference to a hash"
473The following shows the raw form of a reference to a hash.
474.PP
475.Vb 3
476\& use Devel::Peek;
477\& $a = {hello=>42};
478\& Dump $a;
479.Ve
480.PP
481The output:
482.PP
483.Vb 21
484\& SV = RV(0x8177858) at 0x816a618
485\& REFCNT = 1
486\& FLAGS = (ROK)
487\& RV = 0x814fc10
488\& SV = PVHV(0x8167768) at 0x814fc10
489\& REFCNT = 1
490\& FLAGS = (SHAREKEYS)
491\& IV = 1
492\& NV = 0
493\& ARRAY = 0x816c5b8 (0:7, 1:1)
494\& hash quality = 100.0%
495\& KEYS = 1
496\& FILL = 1
497\& MAX = 7
498\& RITER = -1
499\& EITER = 0x0
500\& Elt "hello" HASH = 0xc8fd181b
501\& SV = IV(0x816c030) at 0x814fcf4
502\& REFCNT = 1
503\& FLAGS = (IOK,pIOK)
504\& IV = 42
505.Ve
506.PP
507This shows \f(CW$a\fR is a reference pointing to an \s-1SV\s0. That \s-1SV\s0 is a \s-1PVHV\s0, a
508hash. Fields \s-1RITER\s0 and \s-1EITER\s0 are used by \f(CW\*(C`each\*(C'\fR.
509.PP
510The \*(L"quality\*(R" of a hash is defined as the total number of comparisons needed
511to access every element once, relative to the expected number needed for a
512random hash. The value can go over 100%.
513.PP
514The total number of comparisons is equal to the sum of the squares of the
515number of entries in each bucket. For a random hash of \f(CW\*(C`<n\*(C'\fR> keys into
516\&\f(CW\*(C`<k\*(C'\fR> buckets, the expected value is:
517.PP
518.Vb 1
519\& n + n(n-1)/2k
520.Ve
521.Sh "Dumping a large array or hash"
522.IX Subsection "Dumping a large array or hash"
523The \f(CW\*(C`Dump()\*(C'\fR function, by default, dumps up to 4 elements from a
524toplevel array or hash. This number can be increased by supplying a
525second argument to the function.
526.PP
527.Vb 3
528\& use Devel::Peek;
529\& $a = [10,11,12,13,14];
530\& Dump $a;
531.Ve
532.PP
533Notice that \f(CW\*(C`Dump()\*(C'\fR prints only elements 10 through 13 in the above code.
534The following code will print all of the elements.
535.PP
536.Vb 3
537\& use Devel::Peek 'Dump';
538\& $a = [10,11,12,13,14];
539\& Dump $a, 5;
540.Ve
541.Sh "A reference to an \s-1SV\s0 which holds a C pointer"
542.IX Subsection "A reference to an SV which holds a C pointer"
543This is what you really need to know as an \s-1XS\s0 programmer, of course. When
544an \s-1XSUB\s0 returns a pointer to a C structure that pointer is stored in an \s-1SV\s0
545and a reference to that \s-1SV\s0 is placed on the \s-1XSUB\s0 stack. So the output from
546an \s-1XSUB\s0 which uses something like the T_PTROBJ map might look something like
547this:
548.PP
549.Vb 11
550\& SV = RV(0xf381c)
551\& REFCNT = 1
552\& FLAGS = (ROK)
553\& RV = 0xb8ad8
554\& SV = PVMG(0xbb3c8)
555\& REFCNT = 1
556\& FLAGS = (OBJECT,IOK,pIOK)
557\& IV = 729160
558\& NV = 0
559\& PV = 0
560\& STASH = 0xc1d10 "CookBookB::Opaque"
561.Ve
562.PP
563This shows that we have an \s-1SV\s0 which is an \s-1RV\s0. That \s-1RV\s0 points at another
564\&\s-1SV\s0. In this case that second \s-1SV\s0 is a \s-1PVMG\s0, a blessed scalar. Because it is
565blessed it has the \f(CW\*(C`OBJECT\*(C'\fR flag set. Note that an \s-1SV\s0 which holds a C
566pointer also has the \f(CW\*(C`IOK\*(C'\fR flag set. The \f(CW\*(C`STASH\*(C'\fR is set to the package
567name which this \s-1SV\s0 was blessed into.
568.PP
569The output from an \s-1XSUB\s0 which uses something like the T_PTRREF map, which
570doesn't bless the object, might look something like this:
571.PP
572.Vb 10
573\& SV = RV(0xf381c)
574\& REFCNT = 1
575\& FLAGS = (ROK)
576\& RV = 0xb8ad8
577\& SV = PVMG(0xbb3c8)
578\& REFCNT = 1
579\& FLAGS = (IOK,pIOK)
580\& IV = 729160
581\& NV = 0
582\& PV = 0
583.Ve
584.Sh "A reference to a subroutine"
585.IX Subsection "A reference to a subroutine"
586Looks like this:
587.PP
588.Vb 18
589\& SV = RV(0x798ec)
590\& REFCNT = 1
591\& FLAGS = (TEMP,ROK)
592\& RV = 0x1d453c
593\& SV = PVCV(0x1c768c)
594\& REFCNT = 2
595\& FLAGS = ()
596\& IV = 0
597\& NV = 0
598\& COMP_STASH = 0x31068 "main"
599\& START = 0xb20e0
600\& ROOT = 0xbece0
601\& XSUB = 0x0
602\& XSUBANY = 0
603\& GVGV::GV = 0x1d44e8 "MY" :: "top_targets"
604\& FILE = "(eval 5)"
605\& DEPTH = 0
606\& PADLIST = 0x1c9338
607.Ve
608.PP
609This shows that
610.IP "\(bu" 4
611the subroutine is not an \s-1XSUB\s0 (since \f(CW\*(C`START\*(C'\fR and \f(CW\*(C`ROOT\*(C'\fR are
612non\-zero, and \f(CW\*(C`XSUB\*(C'\fR is zero);
613.IP "\(bu" 4
614that it was compiled in the package \f(CW\*(C`main\*(C'\fR;
615.IP "\(bu" 4
616under the name \f(CW\*(C`MY::top_targets\*(C'\fR;
617.IP "\(bu" 4
618inside a 5th eval in the program;
619.IP "\(bu" 4
620it is not currently executed (see \f(CW\*(C`DEPTH\*(C'\fR);
621.IP "\(bu" 4
622it has no prototype (\f(CW\*(C`PROTOTYPE\*(C'\fR field is missing).
623.SH "EXPORTS"
624.IX Header "EXPORTS"
625\&\f(CW\*(C`Dump\*(C'\fR, \f(CW\*(C`mstat\*(C'\fR, \f(CW\*(C`DeadCode\*(C'\fR, \f(CW\*(C`DumpArray\*(C'\fR, \f(CW\*(C`DumpWithOP\*(C'\fR and
626\&\f(CW\*(C`DumpProg\*(C'\fR, \f(CW\*(C`fill_mstats\*(C'\fR, \f(CW\*(C`mstats_fillhash\*(C'\fR, \f(CW\*(C`mstats2hash\*(C'\fR by
627default. Additionally available \f(CW\*(C`SvREFCNT\*(C'\fR, \f(CW\*(C`SvREFCNT_inc\*(C'\fR and
628\&\f(CW\*(C`SvREFCNT_dec\*(C'\fR.
629.SH "BUGS"
630.IX Header "BUGS"
631Readers have been known to skip important parts of perlguts, causing much
632frustration for all.
633.SH "AUTHOR"
634.IX Header "AUTHOR"
635Ilya Zakharevich ilya@math.ohio\-state.edu
636.PP
637Copyright (c) 1995\-98 Ilya Zakharevich. All rights reserved.
638This program is free software; you can redistribute it and/or
639modify it under the same terms as Perl itself.
640.PP
641Author of this software makes no claim whatsoever about suitability,
642reliability, edability, editability or usability of this product, and
643should not be kept liable for any damage resulting from the use of
644it. If you can use it, you are in luck, if not, I should not be kept
645responsible. Keep a handy copy of your backup tape at hand.
646.SH "SEE ALSO"
647.IX Header "SEE ALSO"
648perlguts, and perlguts, again.