gdb 6.8 selected_byte_order function

Richard Stuckey richard.stuckey@arc.com
Wed Sep 24 10:59:00 GMT 2008


Hello,

I am currently moving the ARC port of gdb from 6.6 on to 6.8, and I am a
little puzzled by the selected_byte_order function in file arch-utils.c;
I wonder if anyone could perhaps enlighten me about it.

The 6.8 code (this function did not exist in 6.6) is

enum bfd_endian
selected_byte_order (void)
{
  if (target_byte_order_user != BFD_ENDIAN_UNKNOWN)
    return gdbarch_byte_order (current_gdbarch);
  else
    return BFD_ENDIAN_UNKNOWN;
}

Given that that the variable ‘target_byte_order_user ‘ holds the user’s
preference as specified by the “set endian” command, it seems to me that
the code should be

  if (target_byte_order_user != BFD_ENDIAN_UNKNOWN)
    return target_byte_order_user;
 else
    return gdbarch_byte_order (current_gdbarch);

i.e. if the user has explicitly specified the byte order then we use
that, otherwise we use the order determined from the current
architecture.

I can see from the Changelogs, and various pages on the web (like
http://sourceware.org/ml/gdb-patches/2006-11/msg00052.html), that this
function has a history of change – so apologies if I have missed out on
all the reasoning that has led to the current version of the code!

     Regards,

          Richard Stuckey 




More information about the Gdb mailing list