diff options
author | Andrew Cagney <cagney@redhat.com> | 2003-11-10 04:39:17 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2003-11-10 04:39:17 +0000 |
commit | a4be445201963e679f7a744faed644505fd10c0a (patch) | |
tree | dfe6dc976d64b4502dab511dabc71a9eef3fd1b7 /gdb/arch-utils.c | |
parent | a01a3246763a669ce54e5c9f1f87d3ee4c1b3a1e (diff) | |
download | gdb-a4be445201963e679f7a744faed644505fd10c0a.tar.gz |
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.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 9483b938377..363e2120aeb 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 |