[PATCH 2/2] Suppress printing of empty bitfields when printing flags
John Baldwin
jhb@FreeBSD.org
Thu Jun 6 16:04:00 GMT 2019
On 6/6/19 5:23 AM, Alan Hayward wrote:
> Consider a variable containing:
> flags A=1 and B=0, 2 bit ranges X=3 and Y=0
>
> When printing, empty flags are suppressed, giving:
> $1 = [ A X=3 Y=0 ]
>
> For consistency, it makes sense to also suppress any bit ranges which are
> also 0. This now gives us:
> $2 = [ A X=3 ]
>
> Consider the CPSR register on AArch64 made up of many flags and bitfields.
> DIT is a single bit flag, only used on Armv8.4-A, and TCO is a 2 bit field
> only used on Armv8.5-A. Printing this in the existing code on Armv8.1-A
> gives:
> $3 = [C Z TCO=0]
> This is confusing for the Armv8.1-A user as TCO does not exist, and would
> be better shown as:
> $4 = [C Z]
The only downside to this is that you may have fields for which 0 is a valid
value. Consider the IOPL field in the x86 eflags/rflags register, it is a
2-bit field for which all of the values (0-3) are valid. There isn't an
"unused" field. The other alternative you could use that might be more
accurate for your use case (but more work) would be to use a feature for
CPSR itself with different feature xml descriptions for different
architecture versions and choose the right one based on the arch. That seems
like a fair bit of work though (and I'm not sure how readily available the
arch version would even be for core dumps and native targets).
--
John Baldwin
More information about the Gdb-patches
mailing list