* gdbarch.sh (gdbarch_update_p): Keep the list of architectures
authorAndrew Cagney <cagney@redhat.com>
Sat, 20 Apr 2002 17:41:18 +0000 (17:41 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sat, 20 Apr 2002 17:41:18 +0000 (17:41 +0000)
sorted in most most-recent-used order.  Document.
* gdbarch.h, gdbarch.c: Regenerate.

gdb/ChangeLog
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh

index 16d3d763cf7c32ef5cc3347ed610f0ecea45e468..043cf342c95492acc9d1e992fd32eed10ea0a5d8 100644 (file)
@@ -1,3 +1,9 @@
+2002-04-20  Andrew Cagney  <ac131313@redhat.com>
+
+       * gdbarch.sh (gdbarch_update_p): Keep the list of architectures
+       sorted in most most-recent-used order.  Document.
+       * gdbarch.h, gdbarch.c: Regenerate.
+       
 2002-04-20  Daniel Jacobowitz  <drow@mvista.com>
 
        * gdbserver/inferiors.c (struct inferior_info): Add regcache_data.
index 646b238349e4c18d0ddf2062258349a100120adf..bc8f47a769fd92b921054fad528e15c9043ebe3a 100644 (file)
@@ -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;
index 7e665226fc132f8d08b7abddaddd9ab3d15aca19..f6a690d8a13070b57e10405bc49d3d87a0e599db 100644 (file)
@@ -2406,9 +2406,16 @@ extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
    architecture; ARCHES which is a list of the previously created
    ``struct gdbarch'' for this architecture.
 
-   The INIT function parameter INFO shall, as far as possible, be
-   pre-initialized with information obtained from INFO.ABFD or
-   previously selected architecture (if similar).
+   The INFO parameter is, as far as possible, be pre-initialized with
+   information obtained from INFO.ABFD or the previously selected
+   architecture.
+
+   The ARCHES parameter is a linked list (sorted most recently used)
+   of all the previously created architures for this architecture
+   family.  The (possibly NULL) ARCHES->gdbarch can used to access
+   values from the previously selected architecture for this
+   architecture family.  The global ``current_gdbarch'' shall not be
+   used.
 
    The INIT function shall return any of: NULL - indicating that it
    doesn't recognize the selected architecture; an existing ``struct
index 32a68fc28b43f38d67059d3330887e65349b2893..cdce9c1e9e9b9d9b0d76437b3e88fc3b22ac48ae 100755 (executable)
@@ -955,9 +955,16 @@ extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
    architecture; ARCHES which is a list of the previously created
    \`\`struct gdbarch'' for this architecture.
 
-   The INIT function parameter INFO shall, as far as possible, be
-   pre-initialized with information obtained from INFO.ABFD or
-   previously selected architecture (if similar).
+   The INFO parameter is, as far as possible, be pre-initialized with
+   information obtained from INFO.ABFD or the previously selected
+   architecture.
+
+   The ARCHES parameter is a linked list (sorted most recently used)
+   of all the previously created architures for this architecture
+   family.  The (possibly NULL) ARCHES->gdbarch can used to access
+   values from the previously selected architecture for this
+   architecture family.  The global \`\`current_gdbarch'' shall not be
+   used.
 
    The INIT function shall return any of: NULL - indicating that it
    doesn't recognize the selected architecture; an existing \`\`struct
@@ -2050,7 +2057,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
@@ -2143,29 +2149,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;
This page took 0.032321 seconds and 4 git commands to generate.