From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24807 invoked by alias); 4 Nov 2013 23:04:44 -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 24793 invoked by uid 89); 4 Nov 2013 23:04:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-vb0-f43.google.com Received: from Unknown (HELO mail-vb0-f43.google.com) (209.85.212.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 04 Nov 2013 23:04:42 +0000 Received: by mail-vb0-f43.google.com with SMTP id g10so1875642vbg.16 for ; Mon, 04 Nov 2013 15:04:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=uhoPfS/dYNk6licKJlKanqJEqTmuAjmfnlz59mfT4UU=; b=BlvE0AgZOsSdIVyi/+icMLNFS30kyp3wBtHAbhBW4TNAQIWpwEOxq62LcXPzuNGx+d kf5++5/qQ7ToZqDjzyEREijEuClobVCcKn73RTCD8axbCifjt94d2cudn5JnA4X4hGnE ayovyYRDEWVtdJ5YpdPd4D6ZfsvqsKnchrw0lv9WjaTK5ecgzqO4n9ZbZtXf9UV/TgkD xBRmVceWqW8lB//hQcQvaJoFznyp68/v8j+3P32UggmMopUfP9MRVeoQHn+8/O4nttIT /vfthQXn1O77Sh3+BtPPy5HnOgNIwTvZD2f9oVGlvil6ZBtVuUvezDxSoFi386NpXufJ GC9g== X-Gm-Message-State: ALoCoQmNEltNFJqMcnB079PW4RJSOUBDfPFP3cRtgB3eLZ4DI76TGP14h3sN06HVRqJntTBweVLd6FO+u7APpC8Kyiq/Hwx3wCa9UITf42OGa+3Rymx0RibwM5kuEbm9jZAHbUVG52yTEOB+qPbc0vvbDOQZlRQaQiNQE0r0Odecp8WFwTPOXwvLMwKcohxhoEXdMvaygnbvqWkyU8uAmHyjENdxCPVb0Q== MIME-Version: 1.0 X-Received: by 10.52.164.16 with SMTP id ym16mr12806vdb.39.1383606273592; Mon, 04 Nov 2013 15:04:33 -0800 (PST) Received: by 10.52.237.232 with HTTP; Mon, 4 Nov 2013 15:04:33 -0800 (PST) In-Reply-To: <1383599806-19444-1-git-send-email-tromey@redhat.com> References: <1383599806-19444-1-git-send-email-tromey@redhat.com> Date: Tue, 05 Nov 2013 02:34:00 -0000 Message-ID: Subject: Re: [PATCH] fix PR c++/16117 From: Doug Evans To: Tom Tromey Cc: gdb-patches Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00069.txt.bz2 On Mon, Nov 4, 2013 at 1:16 PM, Tom Tromey wrote: > This patch fixes PR c++/16117. > > gdb has an extension so that users can use expressions like FILE::NAME > to choose a variable of the given name from the given file. The bug > is that this extension takes precedence over ordinary C++ expressions > of the same form. You might think this is merely hypothetical, but > now that C++ headers commonly do not use an extension, it is more > common. > > This patch fixes the bug by making two related changes. First, it > changes gdb to prefer the ordinary C++ meaning of a symbol over the > extended meaning. Second, it arranges for single-quoting of the > symbol to indicate a preference for the extension. Do we need a NEWS entry for the change in behaviour? Also, and this is just for discussion's sake, I wonder if we'll ever need to handle nested quoting some day (blech :-)). > [...] > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 28e6ff9..9737355 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -8322,11 +8322,23 @@ $4 = 0 > @end smallexample > > @cindex C@t{++} scope resolution > -These uses of @samp{::} are very rarely in conflict with the very similar > -use of the same notation in C@t{++}. @value{GDBN} also supports use of the C@t{++} > -scope resolution operator in @value{GDBN} expressions. > -@c FIXME: Um, so what happens in one of those rare cases where it's in > -@c conflict?? --mew > +These uses of @samp{::} are very rarely in conflict with the very > +similar use of the same notation in C@t{++}. When they are in > +conflict, the C@t{++} meaning takes precedence; however, this can be > +overridden by quoting the file or function name. Can you add text to indicate "quoting" here means single-quotes *only*? > +For example, suppose the program is stopped in a method of a class > +that has a field named ``includefile'', and there is also an include > +file named ``includefile'' that defines a variable, ``some_global''. > + > +@smallexample > +(@value{GDBP}) p includefile > +$1 = 23 > +(@value{GDBP}) p includefile::some_global > +A syntax error in expression, near `'. > +(@value{GDBP}) p 'includefile'::some_global > +$2 = 27 > +@end smallexample > > @cindex wrong values > @cindex variable values, wrong > [...] > diff --git a/gdb/testsuite/gdb.cp/filename.exp b/gdb/testsuite/gdb.cp/filename.exp > new file mode 100644 > index 0000000..943cdc6 > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/filename.exp > @@ -0,0 +1,37 @@ > +# 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 . > + > +if { [skip_cplus_tests] } { continue } > + > +standard_testfile .cc > + > +if [get_compiler_info "c++"] { > + return -1 > +} > + > +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { > + return -1 > +} > + > +if ![runto_main] then { > + perror "couldn't run to main" > + continue > +} > + > +gdb_breakpoint [gdb_get_line_number "stop here"] > +gdb_continue_to_breakpoint "stop here" > + > +gdb_test "print includefile\[0\]" " = 23" > +gdb_test "print 'includefile'::some_global" " = 27" Is 'class'::member intended to work? (static member or whatever) [It works today, but I didn't check if that's intended. I presume it is.] If so, maybe a test to verify that still works as well? I grepped for "'::" in gdb.cp/*.exp and didn't find anything of use. Since we're touching single-quote handling here, I figure this is as good a place as any.