Re: Computer VARSIZE_ANY(PTR) during debugging - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Computer VARSIZE_ANY(PTR) during debugging
Date
Msg-id CAM3SWZRcOuEMmBFyYUeip=vww-HjU5WJY_DhhQ5dCSMyGOzxJg@mail.gmail.com
Whole thread Raw
In response to Re: Computer VARSIZE_ANY(PTR) during debugging  (Greg Stark <stark@mit.edu>)
List pgsql-hackers
On Tue, Jul 30, 2013 at 10:33 AM, Greg Stark <stark@mit.edu> wrote:
> I think there's some magic in gdb for this but I'm not sure how to
> make it happen. If you figure it out I would think it would be
> generally useful and we should find a way to put it in the source tree
> so it works for everyone.

You can write custom pretty printers for varlena types using GDB's
pretty printers (Python bindings expose this stuff). You can even
differentiate between text and bytea, even though they're both just
typedefs for varlena. I've done this myself in the past, but
unfortunately I don't control the source code. I can tell you that the
bindings are excellent, though.

I was even able to do things like printing output more or less
equivalent to what MemoryContextStats() dumps, but directly from GDB
(i.e I could walk the tree of memory contexts), even though there is a
bunch of private macros involved - I essentially re-rewrote
AllocSetStats() in weirdly C-like Python.

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Computer VARSIZE_ANY(PTR) during debugging
Next
From: Gibheer
Date:
Subject: Re: Backup throttling