This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/2] Suppress printing of empty bitfields when printing flags
> On 6 Jun 2019, at 17:03, John Baldwin <jhb@FreeBSD.org> wrote:
>
> 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.
That’s fair enough. I’d still say my version works for that case as it’s
obvious what the value of IOPL is if it’s missing from the print. However,
I doubt anyone is going to OK that as a change.
> 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).
That feels like the correct solution. Given the xml descriptions don’t require
the xml file, that part might not be too tricky. Getting the arch version might
be though. I’ll look into it a bit more.
>
> --
> John Baldwin