Bug 11927 - looking up structure members as symtabs?
Summary: looking up structure members as symtabs?
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 8.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 17772 19535 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-08-18 21:02 UTC by dje
Modified: 2023-12-27 13:41 UTC (History)
6 users (show)

See Also:
Host: amd64-linux
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dje 2010-08-18 21:02:13 UTC
When parsing "p mybar.foo" gdb will do a global lookup of symbol "foo".
That seems a tad clumsy.

The bug, though, is that gdb may also try to lookup "foo" as a symtab.

play$ cat foo
/* Copy this to file "foo" and compile as
   gcc -g -x c foo -o foo.x
*/

struct bar
{
  int foo;
};

struct bar mybar;

int
main ()
{
  return 0;
}
play$ gcc -g -x c foo -o foo.x
play$ build/obj64/gdb/gdb foo.x
GNU gdb (GDB) 7.2.50.20100817-cvs
[...]
Reading symbols from /home/dje/src/play/foo.x...done.
(gdb) start
Temporary breakpoint 1 at 0x40044c: file foo, line 15.
Starting program: /home/dje/src/play/foo.x

Temporary breakpoint 1, main () at foo:15
15        return 0;
(gdb) p mybar.foo
A syntax error in expression, near `foo'.
(gdb)
Comment 1 Tom Tromey 2023-12-11 00:20:46 UTC
I think this is a consequence of trying to classify names
in the lexer, but without feedback from the parser.
It'd be better for the C++ parser to follow Rust and
drop yacc in favor of recursive descent.  Then the parser
is just ordinary code and the lexer can be made a bit
less tricky -- like it can just return "this is a name" instead
of trying to figure out the meaning of the name.
Comment 3 Hannes Domani 2023-12-27 13:05:36 UTC
*** Bug 17772 has been marked as a duplicate of this bug. ***
Comment 4 Hannes Domani 2023-12-27 13:08:15 UTC
*** Bug 19535 has been marked as a duplicate of this bug. ***