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] Various fixes after "dwarf reader and typedefs"


Hello,

The recent change we made in the DWARF reader regarding typdefs
caused a few regressions with Ada. One of them is actually visible
through the testsuite, but most of them were found while testing
the change through our testsuite (the code is proprietory so can't
contribute).

In the ada-* files, I really find that these check_typedef calls
are obscure and annoying. I've started discussing internally on
how to try to get rid of them, or rather localize them so that
we wouldn't need to constantly do a check_typdef, just because
we might get a typedef... But it's not as simple as I initially
hoped, so that's for another rainy day. Actually, I have long-term
plans to cleanup the ada-* files, but that's for another couple
of rainy years :-).

Anyways, I fixed one issue at a time, and ended up with a series
of 6 independent patches. Here they are. They have been tested
individually through AdaCore's testsuite and then together as
a group with the official gdb testsuite (on x86_64-linux). For
each of these patches, I will include a brief description of what
is happening.

2009-03-23  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c (ada_get_field_index): Add handling of the case
        when TYPE is a typedef of a struct.

This one is very visible. In particular, when trying to extract
a field of a struct, we end up not finding that field because
we expected a struct, not a typedef.

2009-03-23  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c (ada_evaluate_subexp): [OP_ATR_FIRST, OP_ATR_LAST]
        [OP_ATR_LENGTH]: When using the attribute on a type, make sure
        to get the real type, not the associated typedef.

This one fixes issues with the 'First, 'Last and 'Length attributes.
We were erroring-out because the type on which the attribute was
being applied was no longer a valid type for these attributes, because
we ended up with the typedef rather than the "real" type.

2009-03-23  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c (ada_evaluate_subexp) [OP_ATR_MODULUS]: Use check_typdef
        to make sure we try to get the modulus of the actual type, not the
        associated typedef.

Same thing, this time with 'modulus attribute.

2009-03-23  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c (ada_evaluate_subexp) [UNOP_IN_RANGE]: make sure
        we try to apply the attribute on the real type, rather than
        its associated typedef.

Same issue, but with the "in <range>" operator.

2009-03-23  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c (resolve_subexp) [UNOP_QUAL]: Resolve typedefs before
        trying to resolve the type qualification.

This time, this is when try to "qualify" an expression (aka in C as
"casting").

2009-03-23  Joel Brobecker  <brobecker@adacore.com>

        * ada-exp.y (get_symbol_field_type): Make sure to resolve typedefs
        before looking up the fields inside our struct type.

This one actually is the second part after the first patch above
which fixes the following two regresions:

|       FAIL | PASS       | ptype_field.exp: ptype circle.pos
|       FAIL | PASS       | ptype_field.exp: ptype circle.pos.x

That's all, folks!

(I left the git log at the start of each patch, to help identify which
patch is which)

-- 
Joel
commit eebcef619b317f51dba47d05ac3556a23db828a8
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Mar 23 17:07:59 2009 -0700

    Fix task getting fields of a record causing task switching issues
    (among other things).
    
        * ada-lang.c (ada_get_field_index): Add handling of the case
        when TYPE is a typedef of a struct.

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0800454..b4e1eb9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -411,25 +411,28 @@ field_name_match (const char *field_name, const char *target)
 }
 
 
-/* Assuming TYPE is a TYPE_CODE_STRUCT, find the field whose name matches
-   FIELD_NAME, and return its index.  This function also handles fields
-   whose name have ___ suffixes because the compiler sometimes alters
-   their name by adding such a suffix to represent fields with certain
-   constraints.  If the field could not be found, return a negative
-   number if MAYBE_MISSING is set.  Otherwise raise an error.  */
+/* Assuming TYPE is a TYPE_CODE_STRUCT or a TYPE_CODE_TYPDEF to
+   a TYPE_CODE_STRUCT, find the field whose name matches FIELD_NAME,
+   and return its index.  This function also handles fields whose name
+   have ___ suffixes because the compiler sometimes alters their name
+   by adding such a suffix to represent fields with certain constraints.
+   If the field could not be found, return a negative number if
+   MAYBE_MISSING is set.  Otherwise raise an error.  */
 
 int
 ada_get_field_index (const struct type *type, const char *field_name,
                      int maybe_missing)
 {
   int fieldno;
-  for (fieldno = 0; fieldno < TYPE_NFIELDS (type); fieldno++)
-    if (field_name_match (TYPE_FIELD_NAME (type, fieldno), field_name))
+  struct type *struct_type = check_typedef ((struct type *) type);
+
+  for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type); fieldno++)
+    if (field_name_match (TYPE_FIELD_NAME (struct_type, fieldno), field_name))
       return fieldno;
 
   if (!maybe_missing)
     error (_("Unable to find field %s in struct %s.  Aborting"),
-           field_name, TYPE_NAME (type));
+           field_name, TYPE_NAME (struct_type));
 
   return -1;
 }
commit c574f412380c58b6b215fafe04878f7047b18b6e
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Mar 23 17:08:52 2009 -0700

    Fix issues with 'first/'last/'length attributes.
    
        * ada-lang.c (ada_evaluate_subexp): [OP_ATR_FIRST, OP_ATR_LAST]
        [OP_ATR_LENGTH]: When using the attribute on a type, make sure
        to get the real type, not the associated typedef.

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b4e1eb9..b9a0a3d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8872,7 +8872,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
           {
             evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
             arg1 = NULL;
-            type_arg = exp->elts[pc + 2].type;
+            type_arg = check_typedef (exp->elts[pc + 2].type);
           }
         else
           {
commit 481c9bfc79e8ce7e07c22456b8b6dd2df59d19f9
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Mar 23 17:09:11 2009 -0700

    Fix issues with the 'modulus attribute...
    
        * ada-lang.c (ada_evaluate_subexp) [OP_ATR_MODULUS]: Use check_typdef
        to make sure we try to get the modulus of the actual type, not the
        associated typedef.

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b9a0a3d..38902af 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9010,7 +9010,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
 
     case OP_ATR_MODULUS:
       {
-        struct type *type_arg = exp->elts[pc + 2].type;
+        struct type *type_arg = check_typedef (exp->elts[pc + 2].type);
         evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
 
         if (noside == EVAL_SKIP)
commit f98f8475053188720788ff03bc71f82f6f0dcbe9
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Mar 23 17:09:45 2009 -0700

    Fix issue with 'range attribute...
    
        * ada-lang.c (ada_evaluate_subexp) [UNOP_IN_RANGE]: make sure
        we try to apply the attribute on the real type, rather than
        its associated typedef.

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 38902af..f257fb3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8786,7 +8786,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
     case UNOP_IN_RANGE:
       (*pos) += 2;
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
-      type = exp->elts[pc + 1].type;
+      type = check_typedef (exp->elts[pc + 1].type);
 
       if (noside == EVAL_SKIP)
         goto nosideret;
commit ea9cdacd4022903b97221693da360f4020ee9998
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Mar 23 17:10:05 2009 -0700

    Fix the handling of type qualification...
    
        * ada-lang.c (resolve_subexp) [UNOP_QUAL]: Resolve typedefs before
        trying to resolve the type qualification.

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index f257fb3..6fa4cfa 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2654,7 +2654,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
 
     case UNOP_QUAL:
       *pos += 3;
-      resolve_subexp (expp, pos, 1, exp->elts[pc + 1].type);
+      resolve_subexp (expp, pos, 1, check_typedef (exp->elts[pc + 1].type));
       break;
 
     case OP_ATR_MODULUS:
commit 1411de443cc3d01c38e75e35416a1bc198477765
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Mar 23 18:00:02 2009 -0700

    Fix a SEGV while doing a ptype of a record_value.field expression
    where record_value is a variable whose type is a record and field
    is the name of one of its components.
    
        * ada-exp.y (get_symbol_field_type): Make sure to resolve typedefs
        before looking up the fields inside our struct type.

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 0da0caa..ee0fcf3 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1207,6 +1207,7 @@ get_symbol_field_type (struct symbol *sym, char *encoded_field_name)
 
   if (type == NULL || field_name == NULL)
     return NULL;
+  type = check_typedef (type);
 
   while (field_name[0] != '\0')
     {

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