From: Doug Evans <dje@google.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] fix PR c++/16117
Date: Tue, 05 Nov 2013 02:34:00 -0000 [thread overview]
Message-ID: <CADPb22S7OO-HqYXyreH1ueKNztA1M6yfyU2xtxQ64vup+NbezQ@mail.gmail.com> (raw)
In-Reply-To: <1383599806-19444-1-git-send-email-tromey@redhat.com>
On Mon, Nov 4, 2013 at 1:16 PM, Tom Tromey <tromey@redhat.com> 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 <http://www.gnu.org/licenses/>.
> +
> +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.
next prev parent reply other threads:[~2013-11-04 23:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-04 22:21 Tom Tromey
2013-11-05 2:34 ` Doug Evans [this message]
2013-11-05 17:44 ` Tom Tromey
2013-11-05 19:52 ` Tom Tromey
2013-11-05 9:15 ` Eli Zaretskii
2013-11-05 17:29 ` Tom Tromey
2013-11-15 15:54 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADPb22S7OO-HqYXyreH1ueKNztA1M6yfyU2xtxQ64vup+NbezQ@mail.gmail.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox