Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/man/2perl/Devel::Peek

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  | will give a
.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.\"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Devel::Peek 3"
.TH Devel::Peek 3 "2002-11-24" "perl v5.8.0" "Perl Programmers Reference Guide"
.SH "NAME"
Devel::Peek \- A data debugging tool for the XS programmer
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 5
\&        use Devel::Peek;
\&        Dump( $a );
\&        Dump( $a, 5 );
\&        DumpArray( 5, $a, $b, ... );
\&        mstat "Point 5";
.Ve
.PP
.Vb 1
\&        use Devel::Peek ':opd=st';
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Devel::Peek contains functions which allows raw Perl datatypes to be
manipulated from a Perl script.  This is used by those who do \s-1XS\s0 programming
to check that the data they are sending from C to Perl looks as they think
it should look.  The trick, then, is to know what the raw datatype is
supposed to look like when it gets to Perl.  This document offers some tips
and hints to describe good and bad raw data.
.PP
It is very possible that this document will fall far short of being useful
to the casual reader.  The reader is expected to understand the material in
the first few sections of perlguts.
.PP
Devel::Peek supplies a \f(CW\*(C`Dump()\*(C'\fR function which can dump a raw Perl
datatype, and \f(CW\*(C`mstat("marker")\*(C'\fR function to report on memory usage
(if perl is compiled with corresponding option).  The function
\&\fIDeadCode()\fR provides statistics on the data \*(L"frozen\*(R" into inactive
\&\f(CW\*(C`CV\*(C'\fR.  Devel::Peek also supplies \f(CW\*(C`SvREFCNT()\*(C'\fR, \f(CW\*(C`SvREFCNT_inc()\*(C'\fR, and
\&\f(CW\*(C`SvREFCNT_dec()\*(C'\fR which can query, increment, and decrement reference
counts on SVs.  This document will take a passive, and safe, approach
to data debugging and for that it will describe only the \f(CW\*(C`Dump()\*(C'\fR
function.
.PP
Function \f(CW\*(C`DumpArray()\*(C'\fR allows dumping of multiple values (useful when you
need to analyze returns of functions).
.PP
The global variable \f(CW$Devel::Peek::pv_limit\fR can be set to limit the
number of character printed in various string values.  Setting it to 0
means no limit.
.PP
If \f(CW\*(C`use Devel::Peek\*(C'\fR directive has a \f(CW\*(C`:opd=FLAGS\*(C'\fR argument,
this switches on debugging of opcode dispatch.  \f(CW\*(C`FLAGS\*(C'\fR should be a
combination 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).
\&\f(CW\*(C`:opd\*(C'\fR is a shortcut for \f(CW\*(C`:opd=st\*(C'\fR.
.Sh "Runtime debugging"
.IX Subsection "Runtime debugging"
\&\f(CW\*(C`CvGV($cv)\*(C'\fR return one of the globs associated to a subroutine reference \f(CW$cv\fR.
.PP
\&\fIdebug_flags()\fR returns a string representation of \f(CW$^D\fR (similar to
what is allowed for \fB\-D\fR flag).  When called with a numeric argument,
sets $^D to the corresponding value.  When called with an argument of
the form \f(CW"flags\-flags"\fR, set on/off bits of \f(CW$^D\fR corresponding to
letters before/after \f(CW\*(C`\-\*(C'\fR.  (The returned value is for \f(CW$^D\fR before
the modification.)
.PP
\&\fIrunops_debug()\fR returns true if the current \fIopcode dispatcher\fR is the
debugging one.  When called with an argument, switches to debugging or
non-debugging dispatcher depending on the argument (active for
newly-entered subs/etc only).  (The returned value is for the dispatcher before the modification.)
.Sh "Memory footprint debugging"
.IX Subsection "Memory footprint debugging"
When perl is compiled with support for memory footprint debugging
(default with Perl's \fImalloc()\fR), Devel::Peek provides an access to this \s-1API\s0.
.PP
Use \fImstat()\fR function to emit a memory state statistic to the terminal.
For more information on the format of output of \fImstat()\fR see
"Using \f(CW$ENV{PERL_DEBUG_MSTATS}\fR" in perldebguts.
.PP
Three additional functions allow access to this statistic from Perl.
First, use \f(CW\*(C`mstats_fillhash(%hash)\*(C'\fR to get the information contained
in the output of \fImstat()\fR into \f(CW%hash\fR. The field of this hash are
.PP
.Vb 2
\&  minbucket nbuckets sbrk_good sbrk_slack sbrked_remains sbrks start_slack
\&  topbucket topbucket_ev topbucket_odd total total_chain total_sbrk totfree
.Ve
.PP
Two additional fields \f(CW\*(C`free\*(C'\fR, \f(CW\*(C`used\*(C'\fR contain array references which
provide per-bucket count of free and used chunks.  Two other fields
\&\f(CW\*(C`mem_size\*(C'\fR, \f(CW\*(C`available_size\*(C'\fR contain array references which provide
the information about the allocated size and usable size of chunks in
each bucket.  Again, see "Using \f(CW$ENV{PERL_DEBUG_MSTATS}\fR" in perldebguts
for details.
.PP
Keep in mind that only the first several \*(L"odd\-numbered\*(R" buckets are
used, so the information on size of the \*(L"odd\-numbered\*(R" buckets which are
not used is probably meaningless.
.PP
The information in
.PP
.Vb 1
\& mem_size available_size minbucket nbuckets
.Ve
.PP
is the property of a particular build of perl, and does not depend on
the current process.  If you do not provide the optional argument to
the functions \fImstats_fillhash()\fR, \fIfill_mstats()\fR, \fImstats2hash()\fR, then
the information in fields \f(CW\*(C`mem_size\*(C'\fR, \f(CW\*(C`available_size\*(C'\fR is not
updated.
.PP
\&\f(CW\*(C`fill_mstats($buf)\*(C'\fR is a much cheaper call (both speedwise and
memory\-wise) which collects the statistic into \f(CW$buf\fR in
machine-readable form.  At a later moment you may need to call
\&\f(CW\*(C`mstats2hash($buf, %hash)\*(C'\fR to use this information to fill \f(CW%hash\fR.
.PP
All three APIs \f(CW\*(C`fill_mstats($buf)\*(C'\fR, \f(CW\*(C`mstats_fillhash(%hash)\*(C'\fR, and
\&\f(CW\*(C`mstats2hash($buf, %hash)\*(C'\fR are designed to allocate no memory if used
\&\fIthe second time\fR on the same \f(CW$buf\fR and/or \f(CW%hash\fR.
.PP
So, if you want to collect memory info in a cycle, you may call
.PP
.Vb 3
\&  $#buf = 999;
\&  fill_mstats($_) for @buf;
\&  mstats_fillhash(%report, 1);          # Static info too
.Ve
.PP
.Vb 8
\&  foreach (@buf) {
\&    # Do something...
\&    fill_mstats $_;                     # Collect statistic
\&  }
\&  foreach (@buf) {
\&    mstats2hash($_, %report);           # Preserve static info
\&    # Do something with %report
\&  }
.Ve
.SH "EXAMPLES"
.IX Header "EXAMPLES"
The following examples don't attempt to show everything as that would be a
monumental task, and, frankly, we don't want this manpage to be an internals
document for Perl.  The examples do demonstrate some basics of the raw Perl
datatypes, and should suffice to get most determined people on their way.
There are no guidewires or safety nets, nor blazed trails, so be prepared to
travel alone from this point and on and, if at all possible, don't fall into
the quicksand (it's bad for business).
.PP
Oh, one final bit of advice: take perlguts with you.  When you return we
expect to see it well\-thumbed.
.Sh "A simple scalar string"
.IX Subsection "A simple scalar string"
Let's begin by looking a simple scalar which is holding a string.
.PP
.Vb 3
\&        use Devel::Peek;
\&        $a = "hello";
\&        Dump $a;
.Ve
.PP
The output:
.PP
.Vb 7
\&        SV = PVIV(0xbc288)
\&          REFCNT = 1
\&          FLAGS = (POK,pPOK)
\&          IV = 0
\&          PV = 0xb2048 "hello"\e0
\&          CUR = 5
\&          LEN = 6
.Ve
.PP
This says \f(CW$a\fR is an \s-1SV\s0, a scalar.  The scalar is a \s-1PVIV\s0, a string.
Its reference count is 1.  It has the \f(CW\*(C`POK\*(C'\fR flag set, meaning its
current \s-1PV\s0 field is valid.  Because \s-1POK\s0 is set we look at the \s-1PV\s0 item
to see what is in the scalar.  The \e0 at the end indicate that this
\&\s-1PV\s0 is properly NUL\-terminated.
If the \s-1FLAGS\s0 had been \s-1IOK\s0 we would look
at the \s-1IV\s0 item.  \s-1CUR\s0 indicates the number of characters in the \s-1PV\s0.
\&\s-1LEN\s0 indicates the number of bytes requested for the \s-1PV\s0 (one more than
\&\s-1CUR\s0, in this case, because \s-1LEN\s0 includes an extra byte for the
end-of-string marker).
.Sh "A simple scalar number"
.IX Subsection "A simple scalar number"
If the scalar contains a number the raw \s-1SV\s0 will be leaner.
.PP
.Vb 3
\&        use Devel::Peek;
\&        $a = 42;
\&        Dump $a;
.Ve
.PP
The output:
.PP
.Vb 4
\&        SV = IV(0xbc818)
\&          REFCNT = 1
\&          FLAGS = (IOK,pIOK)
\&          IV = 42
.Ve
.PP
This says \f(CW$a\fR is an \s-1SV\s0, a scalar.  The scalar is an \s-1IV\s0, a number.  Its
reference count is 1.  It has the \f(CW\*(C`IOK\*(C'\fR flag set, meaning it is currently
being evaluated as a number.  Because \s-1IOK\s0 is set we look at the \s-1IV\s0 item to
see what is in the scalar.
.Sh "A simple scalar with an extra reference"
.IX Subsection "A simple scalar with an extra reference"
If the scalar from the previous example had an extra reference:
.PP
.Vb 4
\&        use Devel::Peek;
\&        $a = 42;
\&        $b = \e$a;
\&        Dump $a;
.Ve
.PP
The output:
.PP
.Vb 4
\&        SV = IV(0xbe860)
\&          REFCNT = 2
\&          FLAGS = (IOK,pIOK)
\&          IV = 42
.Ve
.PP
Notice that this example differs from the previous example only in its
reference count.  Compare this to the next example, where we dump \f(CW$b\fR
instead of \f(CW$a\fR.
.Sh "A reference to a simple scalar"
.IX Subsection "A reference to a simple scalar"
This shows what a reference looks like when it references a simple scalar.
.PP
.Vb 4
\&        use Devel::Peek;
\&        $a = 42;
\&        $b = \e$a;
\&        Dump $b;
.Ve
.PP
The output:
.PP
.Vb 8
\&        SV = RV(0xf041c)
\&          REFCNT = 1
\&          FLAGS = (ROK)
\&          RV = 0xbab08
\&        SV = IV(0xbe860)
\&          REFCNT = 2
\&          FLAGS = (IOK,pIOK)
\&          IV = 42
.Ve
.PP
Starting from the top, this says \f(CW$b\fR is an \s-1SV\s0.  The scalar is an \s-1RV\s0, a
reference.  It has the \f(CW\*(C`ROK\*(C'\fR flag set, meaning it is a reference.  Because
\&\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
follows the reference and shows us what \f(CW$b\fR was referencing.  We see the
same \f(CW$a\fR that we found in the previous example.
.PP
Note that the value of \f(CW\*(C`RV\*(C'\fR coincides with the numbers we see when we
stringify \f(CW$b\fR. The addresses inside \s-1\fIRV\s0()\fR and \s-1\fIIV\s0()\fR are addresses of
\&\f(CW\*(C`X***\*(C'\fR structure which holds the current state of an \f(CW\*(C`SV\*(C'\fR. This
address may change during lifetime of an \s-1SV\s0.
.Sh "A reference to an array"
.IX Subsection "A reference to an array"
This shows what a reference to an array looks like.
.PP
.Vb 3
\&        use Devel::Peek;
\&        $a = [42];
\&        Dump $a;
.Ve
.PP
The output:
.PP
.Vb 20
\&        SV = RV(0xf041c)
\&          REFCNT = 1
\&          FLAGS = (ROK)
\&          RV = 0xb2850
\&        SV = PVAV(0xbd448)
\&          REFCNT = 1
\&          FLAGS = ()
\&          IV = 0
\&          NV = 0
\&          ARRAY = 0xb2048
\&          ALLOC = 0xb2048
\&          FILL = 0
\&          MAX = 0
\&          ARYLEN = 0x0
\&          FLAGS = (REAL)
\&        Elt No. 0 0xb5658
\&        SV = IV(0xbe860)
\&          REFCNT = 1
\&          FLAGS = (IOK,pIOK)
\&          IV = 42
.Ve
.PP
This says \f(CW$a\fR is an \s-1SV\s0 and that it is an \s-1RV\s0.  That \s-1RV\s0 points to
another \s-1SV\s0 which is a \s-1PVAV\s0, an array.  The array has one element,
element zero, which is another \s-1SV\s0. The field \f(CW\*(C`FILL\*(C'\fR above indicates
the last element in the array, similar to \f(CW\*(C`$#$a\*(C'\fR.
.PP
If \f(CW$a\fR pointed to an array of two elements then we would see the
following.
.PP
.Vb 3
\&        use Devel::Peek 'Dump';
\&        $a = [42,24];
\&        Dump $a;
.Ve
.PP
The output:
.PP
.Vb 25
\&        SV = RV(0xf041c)
\&          REFCNT = 1
\&          FLAGS = (ROK)
\&          RV = 0xb2850
\&        SV = PVAV(0xbd448)
\&          REFCNT = 1
\&          FLAGS = ()
\&          IV = 0
\&          NV = 0
\&          ARRAY = 0xb2048
\&          ALLOC = 0xb2048
\&          FILL = 0
\&          MAX = 0
\&          ARYLEN = 0x0
\&          FLAGS = (REAL)
\&        Elt No. 0  0xb5658
\&        SV = IV(0xbe860)
\&          REFCNT = 1
\&          FLAGS = (IOK,pIOK)
\&          IV = 42
\&        Elt No. 1  0xb5680
\&        SV = IV(0xbe818)
\&          REFCNT = 1
\&          FLAGS = (IOK,pIOK)
\&          IV = 24
.Ve
.PP
Note that \f(CW\*(C`Dump\*(C'\fR will not report \fIall\fR the elements in the array,
only several first (depending on how deep it already went into the
report tree).
.Sh "A reference to a hash"
.IX Subsection "A reference to a hash"
The following shows the raw form of a reference to a hash.
.PP
.Vb 3
\&        use Devel::Peek;
\&        $a = {hello=>42};
\&        Dump $a;
.Ve
.PP
The output:
.PP
.Vb 19
\&        SV = RV(0xf041c)
\&          REFCNT = 1
\&          FLAGS = (ROK)
\&          RV = 0xb2850
\&        SV = PVHV(0xbd448)
\&          REFCNT = 1
\&          FLAGS = ()
\&          NV = 0
\&          ARRAY = 0xbd748
\&          KEYS = 1
\&          FILL = 1
\&          MAX = 7
\&          RITER = -1
\&          EITER = 0x0
\&        Elt "hello" => 0xbaaf0
\&        SV = IV(0xbe860)
\&          REFCNT = 1
\&          FLAGS = (IOK,pIOK)
\&          IV = 42
.Ve
.PP
This shows \f(CW$a\fR is a reference pointing to an \s-1SV\s0.  That \s-1SV\s0 is a \s-1PVHV\s0, a
hash. Fields \s-1RITER\s0 and \s-1EITER\s0 are used by \f(CW\*(C`each\*(C'\fR.
.Sh "Dumping a large array or hash"
.IX Subsection "Dumping a large array or hash"
The \f(CW\*(C`Dump()\*(C'\fR function, by default, dumps up to 4 elements from a
toplevel array or hash.  This number can be increased by supplying a
second argument to the function.
.PP
.Vb 3
\&        use Devel::Peek;
\&        $a = [10,11,12,13,14];
\&        Dump $a;
.Ve
.PP
Notice that \f(CW\*(C`Dump()\*(C'\fR prints only elements 10 through 13 in the above code.
The following code will print all of the elements.
.PP
.Vb 3
\&        use Devel::Peek 'Dump';
\&        $a = [10,11,12,13,14];
\&        Dump $a, 5;
.Ve
.Sh "A reference to an \s-1SV\s0 which holds a C pointer"
.IX Subsection "A reference to an SV which holds a C pointer"
This is what you really need to know as an \s-1XS\s0 programmer, of course.  When
an \s-1XSUB\s0 returns a pointer to a C structure that pointer is stored in an \s-1SV\s0
and a reference to that \s-1SV\s0 is placed on the \s-1XSUB\s0 stack.  So the output from
an \s-1XSUB\s0 which uses something like the T_PTROBJ map might look something like
this:
.PP
.Vb 11
\&        SV = RV(0xf381c)
\&          REFCNT = 1
\&          FLAGS = (ROK)
\&          RV = 0xb8ad8
\&        SV = PVMG(0xbb3c8)
\&          REFCNT = 1
\&          FLAGS = (OBJECT,IOK,pIOK)
\&          IV = 729160
\&          NV = 0
\&          PV = 0
\&          STASH = 0xc1d10       "CookBookB::Opaque"
.Ve
.PP
This shows that we have an \s-1SV\s0 which is an \s-1RV\s0.  That \s-1RV\s0 points at another
\&\s-1SV\s0.  In this case that second \s-1SV\s0 is a \s-1PVMG\s0, a blessed scalar.  Because it is
blessed it has the \f(CW\*(C`OBJECT\*(C'\fR flag set.  Note that an \s-1SV\s0 which holds a C
pointer also has the \f(CW\*(C`IOK\*(C'\fR flag set.  The \f(CW\*(C`STASH\*(C'\fR is set to the package
name which this \s-1SV\s0 was blessed into.
.PP
The output from an \s-1XSUB\s0 which uses something like the T_PTRREF map, which
doesn't bless the object, might look something like this:
.PP
.Vb 10
\&        SV = RV(0xf381c)
\&          REFCNT = 1
\&          FLAGS = (ROK)
\&          RV = 0xb8ad8
\&        SV = PVMG(0xbb3c8)
\&          REFCNT = 1
\&          FLAGS = (IOK,pIOK)
\&          IV = 729160
\&          NV = 0
\&          PV = 0
.Ve
.Sh "A reference to a subroutine"
.IX Subsection "A reference to a subroutine"
Looks like this:
.PP
.Vb 18
\&        SV = RV(0x798ec)
\&          REFCNT = 1
\&          FLAGS = (TEMP,ROK)
\&          RV = 0x1d453c
\&        SV = PVCV(0x1c768c)
\&          REFCNT = 2
\&          FLAGS = ()
\&          IV = 0
\&          NV = 0
\&          COMP_STASH = 0x31068  "main"
\&          START = 0xb20e0
\&          ROOT = 0xbece0
\&          XSUB = 0x0
\&          XSUBANY = 0
\&          GVGV::GV = 0x1d44e8   "MY" :: "top_targets"
\&          FILE = "(eval 5)"
\&          DEPTH = 0
\&          PADLIST = 0x1c9338
.Ve
.PP
This shows that 
.IP "\(bu" 4
the subroutine is not an \s-1XSUB\s0 (since \f(CW\*(C`START\*(C'\fR and \f(CW\*(C`ROOT\*(C'\fR are
non\-zero, and \f(CW\*(C`XSUB\*(C'\fR is zero);
.IP "\(bu" 4
that it was compiled in the package \f(CW\*(C`main\*(C'\fR;
.IP "\(bu" 4
under the name \f(CW\*(C`MY::top_targets\*(C'\fR; 
.IP "\(bu" 4
inside a 5th eval in the program;
.IP "\(bu" 4
it is not currently executed (see \f(CW\*(C`DEPTH\*(C'\fR);
.IP "\(bu" 4
it has no prototype (\f(CW\*(C`PROTOTYPE\*(C'\fR field is missing).
.SH "EXPORTS"
.IX Header "EXPORTS"
\&\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
\&\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
default. Additionally available \f(CW\*(C`SvREFCNT\*(C'\fR, \f(CW\*(C`SvREFCNT_inc\*(C'\fR and
\&\f(CW\*(C`SvREFCNT_dec\*(C'\fR.
.SH "BUGS"
.IX Header "BUGS"
Readers have been known to skip important parts of perlguts, causing much
frustration for all.
.SH "AUTHOR"
.IX Header "AUTHOR"
Ilya Zakharevich	ilya@math.ohio\-state.edu
.PP
Copyright (c) 1995\-98 Ilya Zakharevich. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
.PP
Author of this software makes no claim whatsoever about suitability,
reliability, edability, editability or usability of this product, and
should not be kept liable for any damage resulting from the use of
it. If you can use it, you are in luck, if not, I should not be kept
responsible. Keep a handy copy of your backup tape at hand.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
perlguts, and perlguts, again.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.