NAME

Devel::MAT::SV - represent a single SV from a heap dump

DESCRIPTION

Objects in this class represent individual SV variables found in the arena during a heap dump. Actual types of SV are represented by subclasses, which are documented below.

COMMON METHODS

$type = $sv->type

Returns the major type of the SV. This is the class name minus the Devel::MAT::SV:: prefix.

$desc = $sv->desc

Returns a string describing the type of the SV and giving a short detail of its contents. The exact details depends on the SV type.

$desc = $sv->desc_addr

Returns a string describing the SV as with desc and giving its address in hex. A useful way to uniquely identify the SV when printing.

$addr = $sv->addr

Returns the address of the SV

$count = $sv->refcnt

Returns the SvREFCNT reference count of the SV

$stash = $sv->blessed

If the SV represents a blessed object, returns the stash SV. Otherwise returns undef.

$padlist = $sv->is_padlist

Returns true if the SV is part of the padlist structure of a CV.

( $type, $sv, $type, $sv, ... ) = $sv->magic

Returns a pair list of magic applied to the SV; each giving the type and target SV.

%refs = $sv->outrefs

Returns a name/value list giving names and other SV objects for each of the SVs that this one directly refs to.

IMMORTAL SVs

Three special SV objects exist outside of the heap, to represent undef and boolean true and false. They are

  • Devel::MAT::SV::UNDEF

  • Devel::MAT::SV::YES

  • Devel::MAT::SV::NO

Devel::MAT::SV::GLOB

Represents a glob; an SV of type SVt_PVGV.

$stash = $gv->stash

Returns the stash to which the GV belongs.

$sv = $gv->scalar

$av = $gv->array

$hv = $gv->hash

$cv = $gv->code

$gv = $gv->egv

$io = $gv->io

$form = $gv->form

Return the SV in the various glob slots.

Devel::MAT::SV::SCALAR

Represents a scalar value; an SV of any of the types up to and including SVt_PVMV (that is, IV, NV, PV, PVIV, PVNV or PVMG). This includes all numbers, integers and floats, strings, references, and dualvars containing multiple parts.

$uv = $sv->uv

Returns the integer numeric portion, if valid, or undef.

$nv = $sv->nv

Returns the floating numeric portion, if valid, or undef.

$pv = $sv->pv

Returns the string portion, if valid, or undef.

$svrv = $sv->rv

Returns the SV referred to by the reference portion, if valid, or undef.

$weak = $sv->is_weak

Returns true if the SV is a weakened RV reference.

Devel::MAT::SV::ARRAY

Represents an array; an SV of type SVt_PVAV.

@svs = $av->elems

Returns all of the element SVs in a list

$sv = $av->elem( $index )

Returns the SV at the given index

Devel::MAT::SV::HASH

Represents a hash; an SV of type SVt_PVHV. The Devel::MAT::SV::STASH subclass is used to represent hashes that are used as stashes.

$av = $hv->backrefs

Returns the AV containing weak reference backrefs

@keys = $hv->keys

Returns the set of keys present in the hash, as plain perl strings, in no particular order.

$sv = $hv->value( $key )

Returns the SV associated with the given key

@svs = $hv->values

Returns all of the SVs stored as values, in no particular order.

Devel::MAT::SV::STASH

Represents a hash used as a stash; an SV of type SVt_PVHV whose HvNAME() is non-NULL. This is a subclass of Devel::MAT::SV::HASH.

$name = $stash->stashname

Returns the name of the stash

Devel::MAT::SV::CODE

Represents a function or closure; an SV of type SVt_PVCV.

$stash = $cv->stash

$gv = $cv->glob

$filename = $cv->file

$scope_cv = $cv->scope

$av = $cv->padlist

$sv = $cv->constval

Returns the stash, glob, filename, scope, padlist, padnames or constant value of the code.

@svs = $cv->constants

Returns a list of the SVs used as constants or method names in the code. On ithreads perl the constants are part of the padlist structure so this list is constructed from parts of the padlist at loading time.

@svs = $cv->globrefs

Returns a list of the SVs used as GLOB references in the code. On ithreads perl the constants are part of the padlist structure so this list is constructed from parts of the padlist at loading time.

$name = $cv->padname( $padix )

Returns the name of the $padix'th lexical variable, or undef if it doesn't have a name

@names = $cv->padnames

Returns a list of all the lexical variable names

$av = $cv->padnames_av

Returns the AV reference directly which stores the pad names.

$sv = $cv->padsv( $depth, $padix )

Returns the SV at the $padix'th index of the $depth'th pad. $depth is 1-indexed.

@svs = $cv->padsvs( $depth )

Returns a list of all the SVs at the $depth'th pad. $depth is 1-indexed.

@avs = $cv->pads

Returns a list of the actual pad AVs.

( $name, $sv, $name, $sv, ... ) = $cv->lexvars( $depth )

Returns a name/value list of the lexical variables at the given depth.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>