From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23250 invoked by alias); 24 Mar 2009 02:22:30 -0000 Received: (qmail 23242 invoked by uid 22791); 24 Mar 2009 02:22:28 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_63 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Mar 2009 02:22:23 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 991B12BABA3 for ; Mon, 23 Mar 2009 22:22:21 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id El7+8Kqv0REd for ; Mon, 23 Mar 2009 22:22:21 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 074D12BABA2 for ; Mon, 23 Mar 2009 22:22:21 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 261505BD21; Mon, 23 Mar 2009 19:22:16 -0700 (PDT) Date: Tue, 24 Mar 2009 02:40:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [commit/Ada] Various fixes after "dwarf reader and typedefs" Message-ID: <20090324022216.GH7912@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00519.txt.bz2 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 3298 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 * 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 * 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 * 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 * 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 " operator. 2009-03-23 Joel Brobecker * 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 * 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 --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="01-task-switch.diff" Content-length: 2179 commit eebcef619b317f51dba47d05ac3556a23db828a8 Author: Joel Brobecker 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; } --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="02-tick-first.diff" Content-length: 859 commit c574f412380c58b6b215fafe04878f7047b18b6e Author: Joel Brobecker 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 { --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="03-tick-modulus.diff" Content-length: 840 commit 481c9bfc79e8ce7e07c22456b8b6dd2df59d19f9 Author: Joel Brobecker 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) --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="04-tick-range.diff" Content-length: 817 commit f98f8475053188720788ff03bc71f82f6f0dcbe9 Author: Joel Brobecker 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; --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="05-type-qual.diff" Content-length: 745 commit ea9cdacd4022903b97221693da360f4020ee9998 Author: Joel Brobecker 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: --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="06-record-field.diff" Content-length: 800 commit 1411de443cc3d01c38e75e35416a1bc198477765 Author: Joel Brobecker 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') { --2oS5YaxWCcQjTEyO--