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]

[commit/Ada] Use XVS field type instead of doing a parallel lookup.


From: brobecke <brobecke@f8352e7e-cb20-0410-8ce7-b5d9e71c585c>

This patch introduces a change based on an idea from Eric Botcazou.
The idea is that the XVS type contains one field whose name is the name
of the reference type.  However, his remark was that it would faster
to find our reference type if had a direct link to it.  So, instead
the XVS field type being bogus, he replaced it with a reference to
the type we're looking for.  The name of the XVS field remains unchanged,
making the change of encoding upwards compatible:

  1. If the type of the XVS field is a reference type, then it's
     the new encoding, and the reference type is target type of
     that reference;

  2. Otherwise, it's the older encoding, and we use the legacy approach
     of looking up by name (more expensive).

No behavior change.

gdb/ChangeLog:

        Use XVS field type instead of doing a parallel lookup.
        * ada-lang.c (ada_get_base_type): Follow the XVS field type
        if it is a reference type instead of doing a type lookup using
        the XVS field name.

Will commit shortly.
-- 
Joel

---
 gdb/ada-lang.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index e63cf88..4f77600 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7788,11 +7788,20 @@ ada_get_base_type (struct type *raw_type)
       || TYPE_NFIELDS (real_type_namer) != 1)
     return raw_type;
 
-  raw_real_type = ada_find_any_type (TYPE_FIELD_NAME (real_type_namer, 0));
-  if (raw_real_type == NULL)
-    return raw_type;
-  else
-    return raw_real_type;
+  if (TYPE_CODE (TYPE_FIELD_TYPE (real_type_namer, 0)) != TYPE_CODE_REF)
+    {
+      /* This is an older encoding form where the base type needs to be
+	 looked up by name.  We prefer the newer enconding because it is
+	 more efficient.  */
+      raw_real_type = ada_find_any_type (TYPE_FIELD_NAME (real_type_namer, 0));
+      if (raw_real_type == NULL)
+	return raw_type;
+      else
+	return raw_real_type;
+    }
+
+  /* The field in our XVS type is a reference to the base type.  */
+  return TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (real_type_namer, 0));
 }
 
 /* The type of value designated by TYPE, with all aligners removed.  */
-- 
1.6.3.3


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