package Devel::Peek;
-$VERSION = '1.12';
+$VERSION = '1.13';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
@ISA = qw(Exporter);
@EXPORT = qw(Dump mstat DeadCode DumpArray DumpWithOP DumpProg
fill_mstats mstats_fillhash mstats2hash runops_debug debug_flags);
-@EXPORT_OK = qw(SvREFCNT SvREFCNT_inc SvREFCNT_dec CvGV);
+@EXPORT_OK = qw(SvREFCNT CvGV);
%EXPORT_TAGS = ('ALL' => [@EXPORT, @EXPORT_OK]);
XSLoader::load();
datatype, and C<mstat("marker")> function to report on memory usage
(if perl is compiled with corresponding option). The function
DeadCode() provides statistics on the data "frozen" into inactive
-C<CV>. Devel::Peek also supplies C<SvREFCNT()>, C<SvREFCNT_inc()>, and
-C<SvREFCNT_dec()> which can query, increment, and decrement reference
+C<CV>. Devel::Peek also supplies C<SvREFCNT()> which can query reference
counts on SVs. This document will take a passive, and safe, approach
to data debugging and for that it will describe only the C<Dump()>
function.
op_dump(PL_main_root);
}
-I32
+U32
SvREFCNT(sv)
SV * sv
-
-# PPCODE needed since otherwise sv_2mortal is inserted that will kill the value.
-
-SV *
-SvREFCNT_inc(sv)
-SV * sv
-PPCODE:
-{
- RETVAL = SvREFCNT_inc(sv);
- PUSHs(RETVAL);
-}
-
-# PPCODE needed since by default it is void
-
-void
-SvREFCNT_dec(sv)
-SV * sv
-PPCODE:
-{
- SvREFCNT_dec(sv);
- PUSHs(sv);
-}
+PROTOTYPE: \[$@%&*]
+CODE:
+ RETVAL = SvREFCNT(SvRV(sv)) - 1; /* -1 because our ref doesn't count */
+OUTPUT:
+ RETVAL
SV *
DeadCode()
SAVED_COPY = 0x0)?
');
+{ # perl #117793: Extend SvREFCNT* to work on any perl variable type
+ my %hash;
+ my $base_count = Devel::Peek::SvREFCNT(%hash);
+ my $ref = \%hash;
+ is(Devel::Peek::SvREFCNT(%hash), $base_count + 1, "SvREFCNT on non-scalar");
+}
+
done_testing();