aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-04-20 17:41:18 +0000
committerAndrew Cagney <cagney@redhat.com>2002-04-20 17:41:18 +0000
commit0f79675b658bbf6871b720d7b662ddfb6cce1533 (patch)
tree95162fc9721e697dd868128855446bab98e0c5cf /gdb/gdbarch.c
parentc04a1aa88fa42d61fafa570de6ab6ab1b7a12d27 (diff)
downloadgdb-0f79675b658bbf6871b720d7b662ddfb6cce1533.zip
gdb-0f79675b658bbf6871b720d7b662ddfb6cce1533.tar.gz
gdb-0f79675b658bbf6871b720d7b662ddfb6cce1533.tar.bz2
* gdbarch.sh (gdbarch_update_p): Keep the list of architectures
sorted in most most-recent-used order. Document. * gdbarch.h, gdbarch.c: Regenerate.
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r--gdb/gdbarch.c64
1 files changed, 40 insertions, 24 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 646b238..bc8f47a 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -4854,7 +4854,6 @@ int
gdbarch_update_p (struct gdbarch_info info)
{
struct gdbarch *new_gdbarch;
- struct gdbarch_list **list;
struct gdbarch_registration *rego;
/* Fill in missing parts of the INFO struct using a number of
@@ -4947,29 +4946,46 @@ gdbarch_update_p (struct gdbarch_info info)
/* Swap all data belonging to the old target out */
swapout_gdbarch_swap (current_gdbarch);
- /* Is this a pre-existing architecture? Yes. Swap it in. */
- for (list = &rego->arches;
- (*list) != NULL;
- list = &(*list)->next)
- {
- if ((*list)->gdbarch == new_gdbarch)
- {
- if (gdbarch_debug)
- fprintf_unfiltered (gdb_stdlog,
- "gdbarch_update: Previous architecture 0x%08lx (%s) selected\n",
- (long) new_gdbarch,
- new_gdbarch->bfd_arch_info->printable_name);
- current_gdbarch = new_gdbarch;
- swapin_gdbarch_swap (new_gdbarch);
- architecture_changed_event ();
- return 1;
- }
- }
-
- /* Append this new architecture to this targets list. */
- (*list) = XMALLOC (struct gdbarch_list);
- (*list)->next = NULL;
- (*list)->gdbarch = new_gdbarch;
+ /* Is this a pre-existing architecture? Yes. Move it to the front
+ of the list of architectures (keeping the list sorted Most
+ Recently Used) and then copy it in. */
+ {
+ struct gdbarch_list **list;
+ for (list = &rego->arches;
+ (*list) != NULL;
+ list = &(*list)->next)
+ {
+ if ((*list)->gdbarch == new_gdbarch)
+ {
+ struct gdbarch_list *this;
+ if (gdbarch_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: Previous architecture 0x%08lx (%s) selected\n",
+ (long) new_gdbarch,
+ new_gdbarch->bfd_arch_info->printable_name);
+ /* Unlink this. */
+ this = (*list);
+ (*list) = this->next;
+ /* Insert in the front. */
+ this->next = rego->arches;
+ rego->arches = this;
+ /* Copy the new architecture in. */
+ current_gdbarch = new_gdbarch;
+ swapin_gdbarch_swap (new_gdbarch);
+ architecture_changed_event ();
+ return 1;
+ }
+ }
+ }
+
+ /* Prepend this new architecture to the architecture list (keep the
+ list sorted Most Recently Used). */
+ {
+ struct gdbarch_list *this = XMALLOC (struct gdbarch_list);
+ this->next = rego->arches;
+ this->gdbarch = new_gdbarch;
+ rego->arches = this;
+ }
/* Switch to this new architecture. Dump it out. */
current_gdbarch = new_gdbarch;