This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 01/11] s390: Remove duplicate checks for cached gdbarch at init


When initializing the gdbarch there is a check whether an appropriate
gdbarch already exists in the gdbarch_list.  If any of the checks fails
this would lead to a different target description.  However
gdbarch_list_lookup_by_info already checks for

	if (info->target_desc != arches->gdbarch->target_desc)
	  continue;

So it never returns a gdbarch where any of the checks can fail.

Remove the duplicate check.  This also allows to move the lookup at the
start of the function.

gdb/ChangeLog:

	* s390-linux-tdep.c (s390_gdbarch_init): Remove douplicate checks when
	looking for cached gdbarch and move to start of function
---
 gdb/s390-linux-tdep.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index a0d4cdd740..e3e036a70d 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -7829,6 +7829,11 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   static const char *const stap_register_indirection_suffixes[] = { ")",
 								    NULL };
 
+  /* Find a candidate among extant architectures.  */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
+
   /* Default ABI and register size.  */
   switch (info.bfd_arch_info->mach)
     {
@@ -8040,27 +8045,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     vector_abi = S390_VECTOR_ABI_128;
 #endif
 
-  /* Find a candidate among extant architectures.  */
-  for (arches = gdbarch_list_lookup_by_info (arches, &info);
-       arches != NULL;
-       arches = gdbarch_list_lookup_by_info (arches->next, &info))
-    {
-      tdep = gdbarch_tdep (arches->gdbarch);
-      if (!tdep)
-	continue;
-      if (tdep->abi != tdep_abi)
-	continue;
-      if (tdep->vector_abi != vector_abi)
-	continue;
-      if ((tdep->gpr_full_regnum != -1) != have_upper)
-	continue;
-      if (tdep->have_gs != have_gs)
-	continue;
-      if (tdesc_data != NULL)
-	tdesc_data_cleanup (tdesc_data);
-      return arches->gdbarch;
-    }
-
   /* Otherwise create a new gdbarch for the specified machine type.  */
   tdep = XCNEW (struct gdbarch_tdep);
   tdep->abi = tdep_abi;
-- 
2.13.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]