Re: Computer VARSIZE_ANY(PTR) during debugging

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Computer VARSIZE_ANY(PTR) during debugging
Date: 2013-07-31 02:14:34
Message-ID: 20130731021434.GE19053@alap2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2013-06-26 13:27:15 +0900, Amit Langote wrote:
> Is it possible to compute VARSIZE_ANY(PTR) during debugging?
>
> ---------------------------------------------------------
> #define VARSIZE_ANY(PTR) \
> (VARATT_IS_1B_E(PTR) ? VARSIZE_1B_E(PTR) : \
> (VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR) : \
> VARSIZE_4B(PTR)))
>
> #define VARATT_IS_1B_E(PTR) \
> ((((varattrib_1b *) (PTR))->va_header) == 0x80)
> -----------------------------------------------------------
>
> I tried using above expression, but it gives following:
>
> (gdb) p ((((varattrib_1b *) ( tp+off ))->va_header) == 0x80)
> No symbol "varattrib_1b" in current context.

FWIW, for me, just replacing typedefs in such cases by the actual
struct's name often works. Unfortunately varattrib_1b is an anonymous
struct, but that's easy enough to change.
In HEAD it seems enough to replace the usages in VARTAG_SIZE by the
actual structs. Like in the attached patch.

If you compile postgres with -g3 or higher, it will include most macro
definitions in the binary. If you then additionally define:
macro define __builtin_offsetof(T, F) ((int) &(((T *) 0)->F))
macro define __extension__

In your .gdbinit, many macros work OOTB.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
typedef-to-struct.diff text/x-diff 534 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2013-07-31 02:31:44 Re: Computer VARSIZE_ANY(PTR) during debugging
Previous Message Andres Freund 2013-07-31 01:39:14 Re: [COMMITTERS] pgsql: Add support for REFRESH MATERIALIZED VIEW CONCURRENTLY.