From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5590 invoked by alias); 20 Nov 2013 12:18:29 -0000 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 Received: (qmail 5541 invoked by uid 89); 20 Nov 2013 12:18:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mga01.intel.com Received: from Unknown (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Nov 2013 12:18:25 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 20 Nov 2013 04:17:57 -0800 X-ExtLoop1: 1 Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by fmsmga002.fm.intel.com with ESMTP; 20 Nov 2013 04:17:56 -0800 Received: from irsmsx152.ger.corp.intel.com (163.33.192.66) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 20 Nov 2013 12:17:55 +0000 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.215]) by IRSMSX152.ger.corp.intel.com ([169.254.6.169]) with mapi id 14.03.0123.003; Wed, 20 Nov 2013 12:17:55 +0000 From: "Agovic, Sanimir" To: 'Pedro Alves' CC: 'Tom Tromey' , "gdb-patches@sourceware.org" Subject: RE: [PATCH 05/10] vla: allow side effects for sizeof argument Date: Wed, 20 Nov 2013 12:47:00 -0000 Message-ID: <0377C58828D86C4588AEEC42FC3B85A7176B8275@IRSMSX105.ger.corp.intel.com> References: <1382366424-21010-1-git-send-email-sanimir.agovic@intel.com> <1382366424-21010-6-git-send-email-sanimir.agovic@intel.com> <87d2mua1gi.fsf@fleche.redhat.com> <0377C58828D86C4588AEEC42FC3B85A71769F292@IRSMSX105.ger.corp.intel.com> <87ppqp9kme.fsf@fleche.redhat.com> <0377C58828D86C4588AEEC42FC3B85A7176B5F16@IRSMSX105.ger.corp.intel.com> <528B9A5F.5020706@redhat.com> In-Reply-To: <528B9A5F.5020706@redhat.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00592.txt.bz2 > -----Original Message----- > From: Pedro Alves [mailto:palves@redhat.com] > Sent: Tuesday, November 19, 2013 06:06 PM > To: Agovic, Sanimir > Cc: 'Tom Tromey'; gdb-patches@sourceware.org > Subject: Re: [PATCH 05/10] vla: allow side effects for sizeof argument >=20 > On 11/18/2013 08:39 AM, Agovic, Sanimir wrote: > > > > It turns out this patch is not needed anymore as the bounds are resolved > > before the sizeof function is called. So in v2 this patch will be dropp= ed > > from the series. > > > >> > (gdb) print sizeof (array[x++]) > >> > > >> > For an ordinary array this should not modify x. > > Indeed, that is the behavior we have now in HEAD@vla-c99. >=20 > Sounds like something that the testsuite should have caught. > I guess we don't have such a test? >=20 No yet, see below. test: test eval routines with EVAL_AVOID_SIDE_EFFECTS flag set Ensure that certain commands (e.g. whatis/ptype) and sizeof intrinsic have no side effects (variables cannot be altered). 2013-11-20 Sanimir Agovic testsuite/ * gdb.base/eval-avoid-side-effects.exp: New test. diff --git a/gdb/testsuite/gdb.base/eval-avoid-side-effects.exp b/gdb/tests= uite/gdb.base/eval-avoid-side-effects.exp new file mode 100644 index 0000000..da1e36f --- /dev/null +++ b/gdb/testsuite/gdb.base/eval-avoid-side-effects.exp @@ -0,0 +1,40 @@ +# Copyright 2013 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 . + +# Tests to cover evaluate_subexp and others with EVAL_AVOID_SIDE_EFFECTS +# flag set. + +standard_testfile int-type.c + +if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } { + return -1 +} + +if ![runto_main] { + return -1 +} + +set sizeof_int [get_sizeof "int" 4] + +gdb_test_no_output "set variable x=3D42" "set variable x=3D42" + +gdb_test "print sizeof ++x" "=3D ${sizeof_int}" "test sizeof side effects" +gdb_test "print x" "=3D 42" "sizeof has no side effects" + +gdb_test "ptype ++x" "=3D int" "test ptype side effects" +gdb_test "print x" "=3D 42" "ptype has no side effects" + +gdb_test "whatis ++x" "=3D int" "test whatis side effects" +gdb_test "print x" "=3D 42" "whatis has no side effects" Intel GmbH Dornacher Strasse 1 85622 Feldkirchen/Muenchen, Deutschland Sitz der Gesellschaft: Feldkirchen bei Muenchen Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk Registergericht: Muenchen HRB 47456 Ust.-IdNr./VAT Registration No.: DE129385895 Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052