This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Unset tcl variable addr to avoid clashing
- From: Doug Evans <dje at google dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Fri, 10 Apr 2015 11:08:46 -0700
- Subject: Re: [RFC] Unset tcl variable addr to avoid clashing
- Authentication-results: sourceware.org; auth=none
- References: <1428666671-12926-1-git-send-email-qiyaoltc at gmail dot com> <CADPb22TpwGMD1CPKodSCPmeRWaiqdKe+_1WYVT+poxH+c7hODg at mail dot gmail dot com> <55280E9A dot 1020204 at redhat dot com>
On Fri, Apr 10, 2015 at 10:55 AM, Keith Seitz <keiths@redhat.com> wrote:
> On 04/10/2015 09:53 AM, Doug Evans wrote:
>>
>> Bleah. :-)
>> The first thing that comes to mind is of course a convention that
>> array globals must be prefixed with the name of the test.
>> OTOH gdb_base_coredump_filter_addr is painful.
>
>
> I've had to do this in several places, too, with my big locations patchset.
>
> In the end, I felt the path-of-least-resistance was to encapsulate the whole
> test in its own namespace and then declare variables:
>
> namespace eval $testfile {
> variable addr
> variable linespec
> variable location
>
> # do all test stuff
> }
>
> namespace delete $testfile
>
> This is rather inconvenient, so I played for a short while with trying to
> automate this in some way. The only solution that I could devise that didn't
> involve modifying dejagnu was to track the global variable list in
> standard_testfile or prepare_for_testing, unset'ing "new" globals every time
> the procedure was called.
Tucking the thing away in a namespace works too.
[for a definition of "works" that recognizes we have to be pragmatic here :-)]