From patchwork Mon Aug 18 15:30:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 2418 Received: (qmail 19777 invoked by alias); 18 Aug 2014 15:30:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 19671 invoked by uid 89); 18 Aug 2014 15:30:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 18 Aug 2014 15:30:55 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1B9C911616B for ; Mon, 18 Aug 2014 11:30:54 -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 XVCIAz33RvJs for ; Mon, 18 Aug 2014 11:30:54 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id E313011615E for ; Mon, 18 Aug 2014 11:30:53 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id CC155410E4; Mon, 18 Aug 2014 17:30:52 +0200 (CEST) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [pushed/Ada 3/3] ada_evaluate_subexp: Avoid static fixing when possible. Date: Mon, 18 Aug 2014 17:30:44 +0200 Message-Id: <1408375844-28020-4-git-send-email-brobecker@adacore.com> In-Reply-To: <1408375844-28020-1-git-send-email-brobecker@adacore.com> References: <1408375844-28020-1-git-send-email-brobecker@adacore.com> Now that the OP_VAR_VALUE section of this function has been reorganized a bit, we can fall-back on standard evaluation when static fixing is not required. This patch does that, but being exclusive about when static fixing has to be used, rather than doing it all the time when noside is EVAL_AVOID_SIDE_EFFECTS. This will pave the way for later when we want to evaluate entities that have no GNAT encodings related to them but dynamic properties instead. In that case, we expect the standard evaluation to resolve those dynamic properties for us, even in no-side-effect mode. gdb/ChangeLog: * ada-lang.c (ada_evaluate_subexp) : When noside is EVAL_AVOID_SIDE_EFFECTS, only return a statically fixed value for records and unions for which some GNAT encodings are present. --- gdb/ChangeLog | 7 +++++++ gdb/ada-lang.c | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 23bc214..4ca5ea8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2014-08-18 Joel Brobecker + * ada-lang.c (ada_evaluate_subexp) : + When noside is EVAL_AVOID_SIDE_EFFECTS, only return a statically + fixed value for records and unions for which some GNAT encodings + are present. + +2014-08-18 Joel Brobecker + * ada-lang.c (ada_evaluate_subexp) : Slight code rewrite to avoid "else if" and "else" constructs. Should be a no-op in practice. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a9b5e6f..c4e85d2 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10185,8 +10185,22 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, } } - *pos += 4; - return value_zero (to_static_fixed_type (type), not_lval); + /* Records and unions for which GNAT encodings have been + generated need to be statically fixed as well. + Otherwise, non-static fixing produces a type where + all dynamic properties are removed, which prevents "ptype" + from being able to completely describe the type. + For instance, a case statement in a variant record would be + replaced by the relevant components based on the actual + value of the discriminants. */ + if ((TYPE_CODE (type) == TYPE_CODE_STRUCT + && dynamic_template_type (type) != NULL) + || (TYPE_CODE (type) == TYPE_CODE_UNION + && ada_find_parallel_type (type, "___XVU") != NULL)) + { + *pos += 4; + return value_zero (to_static_fixed_type (type), not_lval); + } } arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);