From patchwork Fri Jun 14 14:08:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33115 Received: (qmail 72622 invoked by alias); 14 Jun 2019 14:08:43 -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 72606 invoked by uid 89); 14 Jun 2019 14:08:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Always, ada-lang.c, UD:ada-lang.c, adalangc 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 ESMTP; Fri, 14 Jun 2019 14:08:41 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 08F42560BE; Fri, 14 Jun 2019 10:08:40 -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 Wr86iyyLLmgL; Fri, 14 Jun 2019 10:08:39 -0400 (EDT) Received: from murgatroyd.Home (174-29-48-168.hlrn.qwest.net [174.29.48.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id A863256040; Fri, 14 Jun 2019 10:08:39 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Allow re-assigning to convenience variables Date: Fri, 14 Jun 2019 08:08:37 -0600 Message-Id: <20190614140837.31394-1-tromey@adacore.com> MIME-Version: 1.0 In Ada mode, re-assigning an array of a different size to a convenience variable will cause an error: (gdb) set lang ada (gdb) set $v := "abc" (gdb) set $v := "abcd" cannot assign arrays of different length However, this does not really make sense -- instead, it should always be possible to overwrite a convenience variable. This patch fixes this bug. This was reviewed off-list by Joel. I'm checking it in. gdb/ChangeLog 2019-06-14 Tom Tromey * ada-lang.c (ada_evaluate_subexp) : Always allow assignment to an internalvar. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey * gdb.ada/set_wstr.exp: Add reassignment test. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 6 +++++- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.ada/set_wstr.exp | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 1f0ada35902..1b5f18316fa 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10486,7 +10486,11 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg2 = evaluate_subexp (type, exp, pos, noside); if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) return arg1; - if (ada_is_fixed_point_type (value_type (arg1))) + if (VALUE_LVAL (arg1) == lval_internalvar) + { + /* Nothing. */ + } + else if (ada_is_fixed_point_type (value_type (arg1))) arg2 = cast_to_fixed (value_type (arg1), arg2); else if (ada_is_fixed_point_type (value_type (arg2))) error diff --git a/gdb/testsuite/gdb.ada/set_wstr.exp b/gdb/testsuite/gdb.ada/set_wstr.exp index 0c5c42c17dc..ac7098515da 100644 --- a/gdb/testsuite/gdb.ada/set_wstr.exp +++ b/gdb/testsuite/gdb.ada/set_wstr.exp @@ -72,3 +72,8 @@ gdb_test "print rws" \ gdb_test "set variable www := \"1#2#3#4#5#\"" \ "cannot assign arrays of different length" + +# However, reassigning an array of a different length should work when +# the LHS is a convenience variable. +gdb_test_no_output "set variable \$str := \"1234\"" +gdb_test_no_output "set variable \$str := \"12345\""