This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR 17520 -- structure offset wrong when 1/4 GB or greater


> From: David Taylor <dtaylor@emc.com>
> Cc: David Taylor <dtaylor@emc.com>
> Date: Thu, 18 Dec 2014 20:53:50 -0500
> 
> This patch addresses PR 17520 -- structure offset wrong when 1/4 GB or
> greater.
> 
> When calculating the offset of a structure member, GDB did the
> calculation using 32 bit signed integers.  Because GDB uses this
> same machinery for bit fields and for non bit fields, it does the
> offset calcuation first in bits and then, if a byte offset is desired
> it divides by 8.
> 
> This meant that if the offset was 1/4 G bytes or greater, the returned
> value would be wrong.  Such large offsets were possible on 32-bit
> architectures and even more so on 64-bit ones.
> 
> With this change GDB uses 64-bit integers.

I see you use %lld to print the 64-bit integer quantities, but I think
you should use inttypes.h's PRId64 instead.  At least MinGW32 use the
Windows runtime, which doesn't understand %lld, AFAIK.  And using
inttypes.h's macros is more portable anyway.

Thanks.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]