From patchwork Thu Nov 30 23:48:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 24651 Received: (qmail 67864 invoked by alias); 30 Nov 2017 23:48:36 -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 67855 invoked by uid 89); 30 Nov 2017 23:48:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, KB_WAM_FROM_NAME_SINGLEWORD, NORMAL_HTTP_TO_IP, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=STOP, pck 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; Thu, 30 Nov 2017 23:48:33 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4C33A116B16 for ; Thu, 30 Nov 2017 18:48:32 -0500 (EST) 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 yqmFyoXnTNtU for ; Thu, 30 Nov 2017 18:48:32 -0500 (EST) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 3B266116B15 for ; Thu, 30 Nov 2017 18:48:32 -0500 (EST) Received: by tron.gnat.com (Postfix, from userid 4233) id 3748A16E; Thu, 30 Nov 2017 18:48:32 -0500 (EST) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [pushed/Ada] New gdb.ada/repeat_dyn testcase. Date: Thu, 30 Nov 2017 18:48:30 -0500 Message-Id: <1512085710-138839-1-git-send-email-brobecker@adacore.com> Hello, This patch introduces a testcase that exercises a scenario which used to trigger an internal-error, but no longer does: Consider the following array: type Small is new Integer range Ident (1) .. Ident (10); type Table is array (1 .. 3) of Small; A1 : Table := (3, 5, 8); The particularity of this array is that the type of each element is a range type whose bounds are dynamic, since they depend on the value returned by Ident (1) and Ident (10). Trying to apply the repeat operator ('@') on one of its elements used to yield an internal error: (gdb) p a1(1)@3 $1 = /[...]/gdbtypes.c:4512: internal-error: copy_type: Assertion `TYPE_OBJFILE_OWNED (type)' failed. Although the issue no longer appears, the testcase is still interesting to have. gdb/testsuite/ChangeLog: * gdb.ada/repeat_dyn: New testcase. Tested on x86_64-linux with clean results. Pushed to master. Thanks, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e95d9f6..a9b81b3 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-11-30 Joel Brobecker + + * gdb.ada/repeat_dyn: New testcase. + 2017-11-30 Ulrich Weigand * gdb.cell/gcore.exp: Fix typo when setting spu_bin. diff --git a/gdb/testsuite/gdb.ada/repeat_dyn.exp b/gdb/testsuite/gdb.ada/repeat_dyn.exp new file mode 100644 index 0000000..8f4d42b --- /dev/null +++ b/gdb/testsuite/gdb.ada/repeat_dyn.exp @@ -0,0 +1,30 @@ +# Copyright 2016-2017 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib "ada.exp" + +standard_ada_testfile foo_oc22_002 + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/foo_oc22_002.adb] +runto "foo_oc22_002.adb:$bp_location" + +gdb_test "print a1(1)@3" \ + " = \\(3, 5, 8\\)" diff --git a/gdb/testsuite/gdb.ada/repeat_dyn/foo_oc22_002.adb b/gdb/testsuite/gdb.ada/repeat_dyn/foo_oc22_002.adb new file mode 100644 index 0000000..98163c5 --- /dev/null +++ b/gdb/testsuite/gdb.ada/repeat_dyn/foo_oc22_002.adb @@ -0,0 +1,25 @@ +-- Copyright 2016-2017 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Pck; use Pck; + +procedure Foo_OC22_002 is + type Small is new Integer range Ident (1) .. Ident (10); + type Table is array (1 .. 3) of Small; + + A1 : Table := (3, 5, 8); +begin + Do_Nothing (A1'Address); -- STOP +end Foo_OC22_002; diff --git a/gdb/testsuite/gdb.ada/repeat_dyn/pck.adb b/gdb/testsuite/gdb.ada/repeat_dyn/pck.adb new file mode 100644 index 0000000..f6e5027 --- /dev/null +++ b/gdb/testsuite/gdb.ada/repeat_dyn/pck.adb @@ -0,0 +1,27 @@ +-- Copyright 2016-2017 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package body Pck is + function Ident (I : Integer) return Integer + is + begin + return I; + end Ident; + + procedure Do_Nothing (A : System.Address) is + begin + null; + end Do_Nothing; +end Pck; diff --git a/gdb/testsuite/gdb.ada/repeat_dyn/pck.ads b/gdb/testsuite/gdb.ada/repeat_dyn/pck.ads new file mode 100644 index 0000000..10c885d --- /dev/null +++ b/gdb/testsuite/gdb.ada/repeat_dyn/pck.ads @@ -0,0 +1,22 @@ +-- Copyright 2016-2017 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with System; + +package Pck is + function Ident (I : Integer) return Integer; + + procedure Do_Nothing (A : System.Address); +end Pck;