aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2001-12-19 14:14:52 +0000
committerAndrew Cagney <cagney@redhat.com>2001-12-19 14:14:52 +0000
commitfb6ecb0ffc17d5942c04c8c6fc0abeefd7e93e54 (patch)
tree707988e347077b91873d97caf4b393c8249081fd
parenta5eb27e6ff61757fc74229dce1f8864262a51fbe (diff)
downloadgdb-fb6ecb0ffc17d5942c04c8c6fc0abeefd7e93e54.zip
gdb-fb6ecb0ffc17d5942c04c8c6fc0abeefd7e93e54.tar.gz
gdb-fb6ecb0ffc17d5942c04c8c6fc0abeefd7e93e54.tar.bz2
Add function gdbarch_info_init() replaces memset().
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/arch-utils.c23
-rw-r--r--gdb/arch-utils.h4
-rw-r--r--gdb/cris-tdep.c6
-rw-r--r--gdb/rs6000-nat.c2
5 files changed, 37 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a44bdc5..87f7c59 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+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.
+
2001-12-19 Jim Blandy <jimb@redhat.com>
* c-lang.c (c_emit_char): Print ASCII 11 as '\v', to match
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index d7e82d7..73fab81 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -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 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
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 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
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 @@ set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c)
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 @@ set_gdbarch_from_file (bfd *abfd)
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 @@ initialize_current_architecture (void)
/* 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
@@ -831,6 +832,18 @@ initialize_current_architecture (void)
}
+/* 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));
+}
+
/* */
extern initialize_file_ftype _initialize_gdbarch_utils;
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 834d3f1..4fbe042 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -146,4 +146,8 @@ extern int generic_register_raw_size (int regnum);
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
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index d3376b5..d9175b0 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3615,7 +3615,7 @@ cris_version_update (char *ignore_args, int from_tty,
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 @@ cris_mode_update (char *ignore_args, int from_tty,
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 @@ cris_abi_update (char *ignore_args, int from_tty,
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.");
}
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index e6693cc..1f2e1f7 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -926,7 +926,7 @@ set_host_arch (int pid)
}
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))