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
diff --git a/src/include/postgres.h b/src/include/postgres.h index cb9d196..4bf98cf 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -98,8 +98,8 @@ typedef enum vartag_external } vartag_external; #define VARTAG_SIZE(tag) \ - ((tag) == VARTAG_INDIRECT ? sizeof(varatt_indirect) : \ - (tag) == VARTAG_ONDISK ? sizeof(varatt_external) : \ + ((tag) == VARTAG_INDIRECT ? sizeof(struct varatt_indirect) : \ + (tag) == VARTAG_ONDISK ? sizeof(struct varatt_external) : \ TrapMacro(true, "unknown vartag")) /*
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers