This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] PR 17520 -- structure offset wrong when 1/4 GB or greater
- From: Eli Zaretskii <eliz at gnu dot org>
- To: David Taylor <dtaylor at emc dot com>
- Cc: gdb-patches at sourceware dot org, dtaylor at emc dot com
- Date: Fri, 19 Dec 2014 11:07:40 +0200
- Subject: Re: [PATCH] PR 17520 -- structure offset wrong when 1/4 GB or greater
- Authentication-results: sourceware.org; auth=none
- References: <1418954030-16797-1-git-send-email-dtaylor at emc dot com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> 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.