This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Quoting and the expr parser


On Tuesday 05 August 2008 21:45:00 Mark Kettenis wrote:
> > Date: Tue, 05 Aug 2008 12:24:04 -0700
> > From: Keith Seitz <keiths@redhat.com>
> > 
> > Hi,
> > 
> > I have a simple question:
> > 
> > Why must one type "my_class::'operator+'" instead of simply
> > "my_class::operator+"?
> > 
> > *Should* gdb accept the latter; after all, it's not ambiguous (assuming 
> > it's not overloaded).
> 
> GDB probably should accept that if the selected language is C++.  The
> problem though is that it is actually pretty difficult to make GDB
> accept that wiouout the additional quotes.  Normally a '+' sign isn't
> allowed in a function name, so you'd have to teach the lexer/parser
> that it is allowed but only if there the "operator" keyword is used
> right in front of it.

[This sounds like a one-line rule for a parser generator. But that's
not the point, see below]

> This is a fundamental problem with C++.  It is 
> so badly designed that it is almost impossible to write a proper
> parser for it.

While this seems like a good opportunity for a bit of C++ bashing I'd
like to point out that the problem is _not_ a "C++ parser". The problem
is "gdb cannot read back what gdb writes out", and that's a very 
generic one, completely independent of the language.

There are several places where gdb produces type information that
cannot be easily handed back to gdb because it needs to be quoted
in order to survive the gdb CLI parsing.

Now quoting would be not a problem if there were rules for it.
Unfortunately, for gdb the quoting rules are far from obvious, let
alone from being documented. It would be _so easy_ if there
were a 'replace x by \x' or 'put quotes around it' or even 'encode
it in base64' or 'only use mangled names'.


Andrà 

PS: As usual: These are my opinions, not the company's.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]