[PATCH 1/3] struct packed: Use gcc_struct on Windows

Eli Zaretskii eliz@gnu.org
Thu Jul 21 18:28:39 GMT 2022


> Cc: gdb-patches@sourceware.org
> From: Pedro Alves <pedro@palves.net>
> Date: Thu, 21 Jul 2022 19:18:20 +0100
> 
> On 2022-07-21 6:40 p.m., Eli Zaretskii wrote:
> >> Cc: gdb-patches@sourceware.org
> >> From: Pedro Alves <pedro@palves.net>
> 
> >> Because without it the struct won't really be packed.
> > 
> > Can you tell why is that necessary?
> 
> Somehow I missed this question.  It is necessary because that's the whole
> point of "struct packed".  To wrap some other type and pack it.  We use it
> in some size-sensitive structures, to make them are as small as possible.
> This is described in the gdbsupport/packed.h header.

You mean, this part:

  /* Each instantiation and full specialization of the packed template
     defines a type that behaves like a given scalar type, but that has
     byte alignment, and, may optionally have a smaller size than the
     given scalar type.  This is typically used as alternative to
     bit-fields (and ENUM_BITFIELD), when the fields must have separate
     memory locations to avoid data races.  */

I don't think I see the rationale here, except "make them as small as
possible".  Is that the reason?  If so, what would happen if the size
is somewhat larger?  If the only result is less efficient GDB, I'd be
happier if we sustained the efficiency hit, but stayed compatible to
the ABI.


More information about the Gdb-patches mailing list