public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 5/5] Call ada_ensure_varsize_limit in indirection
Date: Wed, 10 Mar 2021 10:56:12 -0700	[thread overview]
Message-ID: <20210310175612.1759272-6-tromey@adacore.com> (raw)
In-Reply-To: <20210310175612.1759272-1-tromey@adacore.com>

Internal testing revealed yet another Ada regression from the
expression rewrite.  In this case, indirection did not use the Ada
varsize limit.  The old code relied on the expression resolution
process to evaluate this subexpression with EVAL_AVOID_SIDE_EFFECTS in
order to get this error.  However, this isn't always done in the new
approach; so this patch introduces another call to
ada_ensure_varsize_limit in the appropriate spot.

As with the earlier patches, this path was not tested in-tree, so this
patch also updates a test.

gdb/ChangeLog
2021-03-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (ada_unop_ind_operation::evaluate): Call
	ada_ensure_varsize_limit.

gdb/testsuite/ChangeLog
2021-03-10  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/varsize_limit.exp: Add new test.
	* gdb.ada/varsize_limit/vsizelim.adb: Update.
---
 gdb/ChangeLog                                    |  5 +++++
 gdb/ada-lang.c                                   |  5 +++++
 gdb/testsuite/ChangeLog                          |  5 +++++
 gdb/testsuite/gdb.ada/varsize_limit.exp          |  2 +-
 gdb/testsuite/gdb.ada/varsize_limit/vsizelim.adb | 14 ++++++++++++++
 5 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index f63891b2955..7c1a308edbb 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10480,6 +10480,11 @@ ada_unop_ind_operation::evaluate (struct type *expect_type,
 			      (CORE_ADDR) value_as_address (arg1));
     }
 
+  struct type *target_type = (to_static_fixed_type
+			      (ada_aligned_type
+			       (ada_check_typedef (TYPE_TARGET_TYPE (type)))));
+  ada_ensure_varsize_limit (target_type);
+
   if (ada_is_array_descriptor_type (type))
     /* GDB allows dereferencing GNAT array descriptors.  */
     return ada_coerce_to_simple_array (arg1);
diff --git a/gdb/testsuite/gdb.ada/varsize_limit.exp b/gdb/testsuite/gdb.ada/varsize_limit.exp
index eebb5d05def..aca926a79ab 100644
--- a/gdb/testsuite/gdb.ada/varsize_limit.exp
+++ b/gdb/testsuite/gdb.ada/varsize_limit.exp
@@ -37,4 +37,4 @@ gdb_test "print small" " = \"1234567890\""
 
 gdb_test "print larger" "object size is larger than varsize-limit.*"
 
-
+gdb_test "print name.all" "object size is larger than varsize-limit.*"
diff --git a/gdb/testsuite/gdb.ada/varsize_limit/vsizelim.adb b/gdb/testsuite/gdb.ada/varsize_limit/vsizelim.adb
index 058994ce88a..3b19e722eb2 100644
--- a/gdb/testsuite/gdb.ada/varsize_limit/vsizelim.adb
+++ b/gdb/testsuite/gdb.ada/varsize_limit/vsizelim.adb
@@ -14,10 +14,24 @@
 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 with Pck; use Pck;
+with System;
+with Unchecked_Conversion;
+
 procedure VsizeLim is
    Small : String := Ident ("1234567890");
    Larger : String := Ident ("1234567890|1234567890|1234567890");
+
+   type String_Ptr is access all String;
+   type Big_String_Ptr is access all String (Positive);
+
+   function To_Ptr is
+     new Unchecked_Conversion (System.Address, Big_String_Ptr);
+
+   Name_Str : String_Ptr := new String'(Larger);
+   Name : Big_String_Ptr := To_Ptr (Name_Str.all'Address);
+
 begin
    Do_Nothing (Small'Address); -- STOP
    Do_Nothing (Larger'Address);
+   Do_Nothing (Name'Address);
 end VsizeLim;
-- 
2.26.2


  parent reply	other threads:[~2021-03-10 17:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 17:56 [PATCH 0/5] Fix Ada expression regressions Tom Tromey
2021-03-10 17:56 ` [PATCH 1/5] Fix bug in Ada aggregate assignment Tom Tromey
2021-03-10 17:56 ` [PATCH 2/5] Fix Ada assignment resolution Tom Tromey
2021-03-10 17:56 ` [PATCH 3/5] Fix regression in Ada ptype Tom Tromey
2021-03-10 17:56 ` [PATCH 4/5] Implement Ada operator overloading Tom Tromey
2021-03-10 17:56 ` Tom Tromey [this message]
2021-03-15 12:38 ` [PATCH 0/5] Fix Ada expression regressions Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210310175612.1759272-6-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).