in reply to XS: Manipulating refcounts

I dont have time to look into this deeper, but i thought i might point you at sv_dump(), the (simplified) internals version of Devel::Peek::Dump() that can be called directly from your XS code. This may make it easier to see what is going on. I know that I have used it to work out refcount issues in XS/internals code before.

---
$world=~s/war/peace/g

Replies are listed 'Best First'.
Re^2: XS: Manipulating refcounts
by creamygoodness (Curate) on Sep 19, 2006 at 11:16 UTC

    Thanks, demerphq. I've been using sv_dump, which is handy, though it is frustrating that it only shows one level. For instance, it would only show the reference, and not the object (caveat: I'm not sure I haven't got those mixed up -- see my reply to mugwumpjism):

    SV = RV(0x182186c) at 0x1856bf8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x1801380 SV = PVMG(0x1822080) at 0x1801380 /* instead of... */ SV = RV(0x182186c) at 0x1856bf8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x1801380 SV = PVMG(0x1822080) at 0x1801380 REFCNT = 2 FLAGS = (OBJECT,IOK,pIOK) IV = 3880080 NV = 0 PV = 0 STASH = 0x180b56c "Artist"

    To find out how to make multiple levels appear, I peeked inside ext/Devel/Peek/Peek.xs and saw that it was implemented using the private function do_sv_dump. Obviously, do_sv_dump doesn't belong in production code, but this is just debugging and it's even handier than sv_dump if you're motivated enough to memorize its 7-argument interface.

    --
    Marvin Humphrey
    Rectangular Research ― http://www.rectangular.com