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] Fix printing flags field


On 2018-03-11 08:46 PM, Simon Marchi wrote:
> On 2018-03-09 11:58, Yao Qi wrote:
>> As reported in PR gdb/22938, the field value in flags is not correct.
>> It is wrong in bit shift in val_print_type_code_flags, but the field
>> value is still correct if field_len is 1.
>>
>> This patch also adds a self test to default_print_one_register_info, to
>> check that eflags on x86 and cpsr on aarch64 are correctly printed.
>>
>> Regression tested on x86_64-linux and aarch64-linux.
> 
> Hi Yao,
> 
> A question that comes to mind is if this works correctly with a 
> bits_big_endian architecture.  The doc for field_location::bitpos says 
> that it's relative to the MSB on bits_big_endian arches.  Therefore, I 
> would guess that the right shift would be wrong then (just an 
> assumption, I can't test right now).
> 
> Would it be possible to create a selftest that creates its own flags 
> types so we are not dependent on any arch type?  We would have more 
> control on scenarios/edge cases we want to test, including testing with 
> bits_big_endian arches.
> 
> Simon

I'm trying to understand how this works, but I can't get a conclusive answer
about how a flag or field would be described on a big endian machine.  In the
XML target descriptions, for example, are the start/end fields relative to the
MSB on bits big endian machines and LSB on bits little endian machines?  That
would make it like the comment on bitpos:

  /* * Position of this field, counting in bits from start of
     containing structure.  For gdbarch_bits_big_endian=1
     targets, it is the bit offset to the MSB.  For
     gdbarch_bits_big_endian=0 targets, it is the bit offset to
     the LSB.  */

Reading target-descriptions.c, it's not clear to me.  For bitfields in structs,
it seems like the target description always describes relative to the LSB, and
then converts it depending on the endianness (see make_gdb_type_struct).
However, for flag types, make_gdb_type_flags just passes the start as the bit
position.  This means that bitpos will be set to whatever was written in the
target description.  It would mean that one would have to put the position
relative to the MSB in the target desc.  Either there's an inconsistency between
bitfields in structs and flags/fields in flag types, or there's something I
don't understand.

Simon


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