Devel-MAT
view release on metacpan or search on metacpan
lib/Devel/MAT.xs view on Meta::CPAN
sv = ptr;
sv->df = newSVsv(df);
sv->addr = addr;
sv->refcnt = refcnt;
sv->size = size;
sv->blessed_at = blessed_at;
sv->glob_at = 0;
sv_rvweaken(sv->df);
sv_magicext((SV *)self, NULL, PERL_MAGIC_ext, &vtbl, (char *)sv, 0);
}
void DESTROY(self)
HV *self
CODE:
{
struct pmat_sv *sv = get_pmat_sv(self);
free_pmat_sv(sv);
lib/Devel/MAT/Context.pm view on Meta::CPAN
# or the Artistic License (the same terms as Perl itself)
#
# (C) Paul Evans, 2013-2024 -- leonerd@leonerd.org.uk
package Devel::MAT::Context 0.53;
use v5.14;
use warnings;
use Carp;
use Scalar::Util qw( weaken );
=head1 NAME
C<Devel::MAT::Context> - represent a single call context state
=head1 DESCRIPTION
Objects in this class represent a single level of state from the call context.
These contexts represent function calls between perl functions.
lib/Devel/MAT/Context.pm view on Meta::CPAN
}
sub new
{
shift;
my ( $type, $df, $bytes, undef, $strs ) = @_;
$types{$type} or croak "Cannot load unknown CTX type $type";
my $self = bless {}, $types{$type};
weaken( $self->{df} = $df );
( $self->{gimme}, $self->{line} ) = unpack "C $df->{uint_fmt}", $bytes;
( $self->{file} ) = @$strs;
return $self;
}
sub load_v0_1
{
my $class = shift;
my ( $type, $df ) = @_;
$types{$type} or croak "Cannot load unknown CTX type $type";
my $self = bless {}, $types{$type};
weaken( $self->{df} = $df );
# Standard fields all Contexts have
$self->{gimme} = $df->_read_u8;
$self->{file} = $df->_read_str;
$self->{line} = $df->_read_uint;
$self->_load_v0_1( $df );
return $self;
}
lib/Devel/MAT/SV.pm view on Meta::CPAN
# or the Artistic License (the same terms as Perl itself)
#
# (C) Paul Evans, 2013-2024 -- leonerd@leonerd.org.uk
package Devel::MAT::SV 0.53;
use v5.14;
use warnings;
use Carp;
use Scalar::Util qw( weaken );
use Syntax::Keyword::Match;
# Load XS code
require Devel::MAT;
use constant immortal => 0;
use List::Util qw( first );
lib/Devel/MAT/SV.pm view on Meta::CPAN
Returns the SV referred to by the reference.
=cut
sub rv { my $self = shift; return $self->df->sv_at( $self->rv_at ) }
=head2 is_weak
$weak = $sv->is_weak;
Returns true if the SV is a weakened RV reference.
=cut
# XS accessor
=head2 ourstash
$stash = $sv->ourstash;
Returns the stash of the SCALAR, if it is an 'C<our>' variable.
#!/usr/bin/perl
use v5.14;
use warnings;
use Test2::V0;
use Scalar::Util qw( weaken );
use Devel::MAT::Dumper;
use Devel::MAT;
my $ADDR = qr/0x[0-9a-f]+/;
my $DUMPFILE = __FILE__ =~ s/\.t/\.pmat/r;
my %HASH_WITH_KEY = (
a_shared_key => 123,
}
BEGIN { our $LVREF = \substr our $TMPPV = "abc", 1, 2 }
{
my $sv = $pmat->find_symbol( '$LVREF' );
ok( my $rv = $sv->rv, 'LVREF SV has RV' );
is( $rv->lvtype, "x", '$rv->lvtype is x' );
}
BEGIN { our $strongref = []; weaken( our $weakref = $strongref ) }
{
my $rv_strong = $pmat->find_symbol( '$strongref' );
my $rv_weak = $pmat->find_symbol( '$weakref' );
ref_is( $rv_strong->rv, $rv_weak->rv, '$strongref and $weakref have same referrant' );
ok( !$rv_strong->is_weak, '$strongref is not weak' );
ok( $rv_weak->is_weak, '$weakref is weak' ); # and longcat is long
my $target = $rv_weak->rv;
t/10tool-reachability.t view on Meta::CPAN
#!/usr/bin/perl
use v5.14;
use warnings;
use Test2::V0;
use List::Util qw( pairgrep );
use Scalar::Util qw( weaken );
use Devel::MAT::Dumper;
use Devel::MAT;
my $DUMPFILE = __FILE__ =~ s/\.t/\.pmat/r;
# Set up a reference cycle with an easy-to-find PV in it
# Run this from an anonymous sub so we know the lexical is dropped
do {
my $av = [ undef, "This is" ];
( run in 0.315 second using v1.01-cache-2.11-cpan-65fba6d93b7 )