From 805e1f190887b3b7dea3fd157d58bc25effcf688 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 4 Nov 2013 12:38:10 -0700 Subject: fix PR c++/16117 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. Built and regtested on x86-64 Fedora 18. New test case included. 2013-11-15 Tom Tromey PR c++/16117: * c-exp.y (lex_one_token): Add "is_quoted_name" argument. (classify_name): Likewise. Prefer a field of "this" over a filename. (classify_inner_name, yylex): Update. 2013-11-15 Tom Tromey * gdb.texinfo (Variables): Note gdb rules for ambiguous cases. Add example. 2013-11-15 Tom Tromey * gdb.cp/includefile: New file. * gdb.cp/filename.exp: New file. * gdb.cp/filename.cc: New file. --- gdb/doc/ChangeLog | 5 +++++ gdb/doc/gdb.texinfo | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'gdb/doc') diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 0dc75cd..2750b0a 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2013-11-15 Tom Tromey + + * gdb.texinfo (Variables): Note gdb rules for ambiguous cases. + Add example. + 2013-11-14 Tom Tromey * gdb.texinfo (Breakpoints In Python): Replace "as" with "in". diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c2dfa17..cfb2cdb 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -8324,11 +8324,24 @@ $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 with single quotes. + +For example, suppose the program is stopped in a method of a class +that has a field named @code{includefile}, and there is also an +include file named @file{includefile} that defines a variable, +@code{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 -- cgit v1.1