Cursory dumping the arenas from gdb

jjore on 2009-03-23T07:27:35

Lately I've had some problems in production where some processes have gone "WTF!" I haven't had much time to spend on it myself so mostly I'm just a bystander while other people with more time poke at it.

I've been reading the manuals about gdb and learned I didn't need to use Internals::DumpArenas to see everything but could just use gdb directly. This snippet just loops and shows the arena's heads.

define dumparenas
    printf "arenas = {\n"
    dumparena PL_sv_arenaroot
    print "}\n"
end

define dumparena printf "\t0x%x", (int)$arg0 set $acount = ((struct sv*)$arg0)->sv_refcnt set $anext = (struct sv*)(((struct sv*)$arg0)->sv_any) if $anext printf ", /* has %d SVs */\n", $acount dumparena $anext else printf " /* has %d SVs */\n", $acount end end

dumparenas


When I run this on a pretty small perl, I get this. Now it's just another "small" step to writing Devel::Peek in gdb. :-/

(gdb) run -Mblib -MSomething -edump
(gdb) dumparenas
arenas = {
	0x80a200, /* has 128 SVs */
	0x833200, /* has 255 SVs */
	0x817800, /* has 255 SVs */
	0x813400, /* has 255 SVs */
	0x816800, /* has 255 SVs */
	0x830200, /* has 255 SVs */
	0x82ae00, /* has 255 SVs */
	0x815800, /* has 255 SVs */
	0x824e00, /* has 255 SVs */
	0x204240, /* has 17 SVs */
	0x823e00, /* has 255 SVs */
	0x827e00, /* has 255 SVs */
	0x826e00, /* has 255 SVs */
	0x825e00, /* has 255 SVs */
	0x820000, /* has 255 SVs */
	0x81e600, /* has 255 SVs */
	0x80f200, /* has 255 SVs */
	0x804000 /* has 255 SVs */
$1 = "}\n"