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

From Andres Freund
Subject Re: Computer VARSIZE_ANY(PTR) during debugging
Date
Msg-id 20130731021434.GE19053@alap2.anarazel.de
Whole thread Raw
In response to Computer VARSIZE_ANY(PTR) during debugging  (Amit Langote <amitlangote09@gmail.com>)
List 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

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [COMMITTERS] pgsql: Add support for REFRESH MATERIALIZED VIEW CONCURRENTLY.
Next
From: Peter Geoghegan
Date:
Subject: Re: Computer VARSIZE_ANY(PTR) during debugging