This is the mail archive of the gdb-patches@sources.redhat.com 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]

[patch/rfc] Use BFD_ENDIAN_UNKNOWN for default byte_order


Hello,

This patch should stop GDB assuming that a byte_order of 0 indicates 
that it hasn't yet been specified.  Instead, an explicit 
BFD_ENDIAN_UNKNOWN is used.

It doesn't cause regressions for a PPC target.  However, this change 
worries me sufficient too hold off for a few days before committing it.

enjoy,
Andrew
2001-12-19  Andrew Cagney  <ac131313@redhat.com>

	* arch-utils.c (initialize_current_architecture): Test byte_order
	against BFD_ENDIAN_UNKNOWN.
	(gdbarch_info_init): Initialize byte_order to BFD_ENDIAN_UNKNOWN.
	* gdbarch.sh: Update comments on default value of byte_order.
	(verify_gdbarch, gdbarch_update_p): Test byte_order against
	BFD_ENDIAN_UNKNOWN.
	* gdbarch.h, gdbarch.c: Re-generate.

Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.44
diff -u -r1.44 arch-utils.c
--- arch-utils.c	2001/12/19 14:14:52	1.44
+++ arch-utils.c	2001/12/19 15:21:26
@@ -762,7 +762,7 @@
   /* take several guesses at a byte order. */
   /* NB: can't use TARGET_BYTE_ORDER_DEFAULT as its definition is
      forced above. */
-  if (info.byte_order == 0
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN
       && default_bfd_vec != NULL)
     {
       /* Extract BFD's default vector's byte order. */
@@ -778,7 +778,7 @@
 	  break;
 	}
     }
-  if (info.byte_order == 0)
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN)
     {
       /* look for ``*el-*'' in the target name. */
       const char *chp;
@@ -788,7 +788,7 @@
 	  && strncmp (chp - 2, "el", 2) == 0)
 	info.byte_order = BFD_ENDIAN_LITTLE;
     }
-  if (info.byte_order == 0)
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN)
     {
       /* Wire it to big-endian!!! */
       info.byte_order = BIG_ENDIAN;
@@ -842,6 +842,7 @@
 gdbarch_info_init (struct gdbarch_info *info)
 {
   memset (info, 0, sizeof (struct gdbarch_info));
+  info->byte_order = BFD_ENDIAN_UNKNOWN;
 }
 
 /* */
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.98
diff -u -r1.98 gdbarch.sh
--- gdbarch.sh	2001/12/15 16:53:23	1.98
+++ gdbarch.sh	2001/12/19 15:21:32
@@ -894,8 +894,7 @@
 
    The INIT function parameter INFO shall, as far as possible, be
    pre-initialized with information obtained from INFO.ABFD or
-   previously selected architecture (if similar).  INIT shall ensure
-   that the INFO.BYTE_ORDER is non-zero.
+   previously selected architecture (if similar).
 
    The INIT function shall return any of: NULL - indicating that it
    doesn't recognize the selected architecture; an existing \`\`struct
@@ -919,7 +918,7 @@
   /* Use default: NULL (ZERO). */
   const struct bfd_arch_info *bfd_arch_info;
 
-  /* Use default: 0 (ZERO). */
+  /* Use default: BFD_ENDIAN_UNKNOWN (NB: is not ZERO).  */
   int byte_order;
 
   /* Use default: NULL (ZERO). */
@@ -1410,7 +1409,7 @@
   log = mem_fileopen ();
   cleanups = make_cleanup_ui_file_delete (log);
   /* fundamental */
-  if (gdbarch->byte_order == 0)
+  if (gdbarch->byte_order == BFD_ENDIAN_UNKNOWN)
     fprintf_unfiltered (log, "\n\tbyte-order");
   if (gdbarch->bfd_arch_info == NULL)
     fprintf_unfiltered (log, "\n\tbfd_arch_info");
@@ -2037,17 +2036,17 @@
     info.bfd_arch_info = TARGET_ARCHITECTURE;
 
   /* \`\`(gdb) set byte-order ...'' */
-  if (info.byte_order == 0
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN
       && !TARGET_BYTE_ORDER_AUTO)
     info.byte_order = TARGET_BYTE_ORDER;
   /* From the INFO struct. */
-  if (info.byte_order == 0
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN
       && info.abfd != NULL)
     info.byte_order = (bfd_big_endian (info.abfd) ? BIG_ENDIAN
 		       : bfd_little_endian (info.abfd) ? BFD_ENDIAN_LITTLE
-		       : 0);
+		       : BFD_ENDIAN_UNKNOWN);
   /* From the current target. */
-  if (info.byte_order == 0)
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN)
     info.byte_order = TARGET_BYTE_ORDER;
 
   /* Must have found some sort of architecture. */

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