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] memset() -> gdbarch_info_init()


Hello,

This is a mechanical change replacing any memset() with a call to the 
new function gdbarch_info_init().

The next step, in theory, is to just add:
	info->byte_order = BFD_ENDIAN_UNKNOWN;
to that function.  Ha!

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

	* arch-utils.h (gdbarch_info_init): Declare.
	* arch-utils.c: Include "arch-utils.h".
	(gdbarch_info_init): Define.
	(set_endian, set_architecture, set_gdbarch_from_file)
	(initialize_current_architecture): Use gdbarch_info_init.
	* rs6000-nat.c (set_host_arch): Ditto.
	* cris-tdep.c	(cris_version_update, cris_mode_update)
	(cris_abi_update): Ditto.

Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.43
diff -u -r1.43 arch-utils.c
--- arch-utils.c	2001/12/15 16:53:22	1.43
+++ arch-utils.c	2001/12/19 14:11:54
@@ -21,6 +21,7 @@
 #include "defs.h"
 
 #if GDB_MULTI_ARCH
+#include "arch-utils.h"
 #include "gdbcmd.h"
 #include "inferior.h"		/* enum CALL_DUMMY_LOCATION et.al. */
 #else
@@ -466,7 +467,7 @@
       if (GDB_MULTI_ARCH)
 	{
 	  struct gdbarch_info info;
-	  memset (&info, 0, sizeof info);
+	  gdbarch_info_init (&info);
 	  info.byte_order = BFD_ENDIAN_LITTLE;
 	  if (! gdbarch_update_p (info))
 	    {
@@ -484,7 +485,7 @@
       if (GDB_MULTI_ARCH)
 	{
 	  struct gdbarch_info info;
-	  memset (&info, 0, sizeof info);
+	  gdbarch_info_init (&info);
 	  info.byte_order = BIG_ENDIAN;
 	  if (! gdbarch_update_p (info))
 	    {
@@ -663,7 +664,7 @@
   else if (GDB_MULTI_ARCH)
     {
       struct gdbarch_info info;
-      memset (&info, 0, sizeof info);
+      gdbarch_info_init (&info);
       info.bfd_arch_info = bfd_scan_arch (set_architecture_string);
       if (info.bfd_arch_info == NULL)
 	internal_error (__FILE__, __LINE__,
@@ -695,7 +696,7 @@
   if (GDB_MULTI_ARCH)
     {
       struct gdbarch_info info;
-      memset (&info, 0, sizeof info);
+      gdbarch_info_init (&info);
       info.abfd = abfd;
       if (! gdbarch_update_p (info))
 	error ("Architecture of file not recognized.\n");
@@ -732,7 +733,7 @@
 
   /* determine a default architecture and byte order. */
   struct gdbarch_info info;
-  memset (&info, 0, sizeof (info));
+  gdbarch_info_init (&info);
   
   /* Find a default architecture. */
   if (info.bfd_arch_info == NULL
@@ -830,6 +831,18 @@
   }
 }
 
+
+/* Initialize a gdbarch info to values that will be automatically
+   overridden.  Note: Originally, this ``struct info'' was initialized
+   using memset(0).  Unfortunatly, that ran into problems, namely
+   BFD_ENDIAN_BIG is zero.  An explicit initialization function that
+   can explicitly set each field to a well defined value is used.  */
+
+void
+gdbarch_info_init (struct gdbarch_info *info)
+{
+  memset (info, 0, sizeof (struct gdbarch_info));
+}
 
 /* */
 
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.26
diff -u -r1.26 arch-utils.h
--- arch-utils.h	2001/12/11 22:15:54	1.26
+++ arch-utils.h	2001/12/19 14:11:54
@@ -146,4 +146,8 @@
 
 extern int generic_register_virtual_size (int regnum);
 
+/* Initialize a ``struct info''.  Can't use memset(0) since some
+   default values are not zero.  */
+extern void gdbarch_info_init (struct gdbarch_info *info);
+
 #endif
Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.7
diff -u -r1.7 cris-tdep.c
--- cris-tdep.c	2001/12/15 16:53:22	1.7
+++ cris-tdep.c	2001/12/19 14:11:58
@@ -3615,7 +3615,7 @@
       usr_cmd_cris_version_valid = 1;
   
       /* Update the current architecture, if needed.  */
-      memset (&info, 0, sizeof info);
+      gdbarch_info_init (&info);
       if (!gdbarch_update_p (info))
         internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture.");
     }  
@@ -3633,7 +3633,7 @@
       usr_cmd_cris_mode_valid = 1;
   
       /* Update the current architecture, if needed.  */
-      memset (&info, 0, sizeof info);
+      gdbarch_info_init (&info);
       if (!gdbarch_update_p (info))
         internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture.");
     }
@@ -3651,7 +3651,7 @@
       usr_cmd_cris_abi_valid = 1;
   
       /* Update the current architecture, if needed.  */
-      memset (&info, 0, sizeof info);
+      gdbarch_info_init (&info);
       if (!gdbarch_update_p (info))
         internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture.");
     }
Index: rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.17
diff -u -r1.17 rs6000-nat.c
--- rs6000-nat.c	2001/05/04 04:15:27	1.17
+++ rs6000-nat.c	2001/12/19 14:12:00
@@ -926,7 +926,7 @@
     }
   bfd_default_set_arch_mach (&abfd, arch, mach);
 
-  memset (&info, 0, sizeof info);
+  gdbarch_info_init (&info);
   info.bfd_arch_info = bfd_get_arch_info (&abfd);
 
   if (!gdbarch_update_p (info))

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