aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch-utils.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-11-10 04:39:17 +0000
committerAndrew Cagney <cagney@redhat.com>2003-11-10 04:39:17 +0000
commitebdba546a197a3b14163dbc7066bcf6862bfbe58 (patch)
tree90febdf7ec1f112f8811c19f37da0dbd91a1a146 /gdb/arch-utils.c
parent012a452b43b77eaf0f0f8a48192561702beea958 (diff)
downloadgdb-ebdba546a197a3b14163dbc7066bcf6862bfbe58.zip
gdb-ebdba546a197a3b14163dbc7066bcf6862bfbe58.tar.gz
gdb-ebdba546a197a3b14163dbc7066bcf6862bfbe58.tar.bz2
2003-11-09 Andrew Cagney <cagney@redhat.com>
* arch-utils.c (gdbarch_update_p): New function. * gdbarch.sh (gdbarch_update_p): Delete function. (find_arch_by_info, gdbarch_find_by_info): New functions. (deprecated_current_gdbarch_set_hack): New function. * gdbarch.c: Re-generate.
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r--gdb/arch-utils.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 9483b93..363e212 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -489,6 +489,45 @@ set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c)
show_architecture (NULL, from_tty);
}
+/* Try to select a global architecture that matches "info". Return
+ non-zero if the attempt succeds. */
+int
+gdbarch_update_p (struct gdbarch_info info)
+{
+ struct gdbarch *new_gdbarch = gdbarch_find_by_info (info);
+
+ /* If there no architecture by that name, reject the request. */
+ if (new_gdbarch == NULL)
+ {
+ if (gdbarch_debug)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
+ "Architecture not found\n");
+ return 0;
+ }
+
+ /* If it is the same old architecture, accept the request (but don't
+ swap anything). */
+ if (new_gdbarch == current_gdbarch)
+ {
+ if (gdbarch_debug)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
+ "Architecture 0x%08lx (%s) unchanged\n",
+ (long) new_gdbarch,
+ gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
+ return 1;
+ }
+
+ /* It's a new architecture, swap it in. */
+ if (gdbarch_debug)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
+ "New architecture 0x%08lx (%s) selected\n",
+ (long) new_gdbarch,
+ gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
+ deprecated_current_gdbarch_select_hack (new_gdbarch);
+
+ return 1;
+}
+
/* FIXME: kettenis/20031124: Of the functions that follow, only
gdbarch_from_bfd is supposed to survive. The others will
dissappear since in the future GDB will (hopefully) be truly