From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42333 invoked by alias); 13 Apr 2015 08:26:18 -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 42318 invoked by uid 89); 13 Apr 2015 08:26:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 13 Apr 2015 08:26:15 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 1532A8E78A; Mon, 13 Apr 2015 08:26:14 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3D8QC7s026007; Mon, 13 Apr 2015 04:26:12 -0400 Message-ID: <552B7DA3.5070103@redhat.com> Date: Mon, 13 Apr 2015 08:26:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Doug Evans , Sergio Durigan Junior CC: Yao Qi , gdb-patches Subject: Re: [RFC] Unset tcl variable addr to avoid clashing References: <1428666671-12926-1-git-send-email-qiyaoltc@gmail.com> <87r3rqppgq.fsf@redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-04/txt/msg00452.txt.bz2 On 04/12/2015 06:22 PM, Doug Evans wrote: > On Sat, Apr 11, 2015 at 10:03 AM, Sergio Durigan Junior > wrote: >> On Friday, April 10 2015, Yao Qi wrote: >> >>> From: Yao Qi >>> >>> Hi, >>> I see some tcl ERRORs in gdb.sum recently: >>> >>> ERROR: tcl error sourcing ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp. >>> ERROR: can't set "addr": variable is array >>> while executing >>> "set addr "0x\[0-9a-zA-Z\]+"" >>> (file "../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp" line 45) >>> invoked from within >>> "source ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp" >>> ("uplevel" body line 1) >>> invoked from within >>> "uplevel #0 source ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp" >>> invoked from within >>> "catch "uplevel #0 source $test_file_name"" >>> >>> It is OK to run single dmsym.exp. This error is caused by the name >>> clashing with coredump-filter.exp, and it can be reproduced, >> >> It seems that coredump-filter.exp is causing lots of headaches >> lately... Sorry about that. >> >>> $ make check RUNTESTFLAGS='coredump-filter.exp dmsym.exp exception.exp stepi-random-signal.exp' >>> >>> as variable addr is used in all of them. This patch is to unset array >>> addr, but manually unset variables isn't good to me. Is there any >>> approaches we can do to avoid name clashing? >> >> FWIW, there is not strong reason to keep the variable name as "addr" in >> the testcase. So, an easier solution would be to rename the variable to >> something else, like "coredump_var_addr" (I think this name is unique >> enough). The patch below does that. >> >> WDYT? >> >> -- >> Sergio >> GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 >> Please send encrypted e-mail if possible >> http://sergiodj.net/ >> >> gdb/testsuite/ChangeLog: >> 2015-04-11 Sergio Durigan Junior >> >> * gdb.base/coredump-filter.exp: Rename variable "addr" to >> "coredump_var_addr" to avoid naming conflict with other >> testcases. > > Ok by me with one nit. > There's an issue here that still needs to be documented so it becomes > part of the collective lore. > Can this include a note about the need to give global array variables > unique names to either testsuite/README or > https://sourceware.org/gdb/wiki/Internals%20GDB-Testsuite-Coding-Standards I don't agree with this resolution. Renaming is not sufficient. The same .exp file can be run in the same dejagnu invocation. Most commonly, RUNTESTFLAGS="--target_board=unix\{-m64,-m32\}", but can also be mix of native and gdbserver, like RUNTESTFLAGS="--target_board='unix native-gdbserver'" So it's not just conflicting with other testcases that we need to worry about, but also a testcase conflicting with itself. Even though in that "multiple boards" scenario the variable will be arrays in all invocations, we should still clear it to avoid stale contents, like e.g., here: https://sourceware.org/ml/gdb-patches/2015-04/msg00261.html Therefore I think the solution must be that we unset/clear the variable. And if we must do that, then the renaming to avoid naming conflicts is not a necessary condition. Thanks, Pedro Alves