* GDB syntax error when casting to base class
@ 2010-09-09 12:50 Marc Khouzam
2010-09-09 14:00 ` André Pönitz
0 siblings, 1 reply; 3+ messages in thread
From: Marc Khouzam @ 2010-09-09 12:50 UTC (permalink / raw)
To: 'gdb@sourceware.org'
Hi,
I got an eclipse bug report that led me to a bizarre behavior from GDB.
In the very short session below, I'm getting a syntax error when casting
a variable to its base class.
If I remove the constructor (see comment in the code below)
the problem goes away. Or if I add the word 'struct', it also goes away.
This is causing problems in Eclipse because -var-info-path-expression
returns the expression that causes a syntax error.
I tried to debug it but I ended up in c-exp.y and had to give up.
I was going to propose a patch that adds 'struct' to the
-var-info-path-expression output, but I didn't think that was the
greatest of solutions. Currently, this is what we are planning to
do in Eclipse to work around this problem.
I can open a PR if it makes sense?
Thanks
Marc
> gdb.7.2 a.out
GNU gdb (GDB) 7.2
(gdb) l 1
1 class bar{};
2
3 class foo : public bar {
4 public:
5 foo() {} // Comment this line to make things work
6 void test() { return; }
7 };
8
9 int main(void)
10 {
11 foo f;
12 f.test();
13 return 0;
14 }
(gdb) b 6
Breakpoint 1 at 0x8048457: file base.cc, line 6.
(gdb) r
Starting program: /local/lmckhou/testing/a.out
Breakpoint 1, foo::test (this=0xbfffbfa3) at base.cc:6
6 void test() { return; }
(gdb) p (*(bar*) this)
A syntax error in expression, near `) this)'.
(gdb) p (*(struct bar*) this)
$1 = {<No data fields>}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: GDB syntax error when casting to base class
2010-09-09 12:50 GDB syntax error when casting to base class Marc Khouzam
@ 2010-09-09 14:00 ` André Pönitz
2010-09-09 15:09 ` Marc Khouzam
0 siblings, 1 reply; 3+ messages in thread
From: André Pönitz @ 2010-09-09 14:00 UTC (permalink / raw)
To: gdb; +Cc: ext Marc Khouzam
On Thursday 09 September 2010 14:50:07 ext Marc Khouzam wrote:
> Hi,
>
> I got an eclipse bug report that led me to a bizarre behavior from GDB.
> In the very short session below, I'm getting a syntax error when casting
> a variable to its base class.
> If I remove the constructor (see comment in the code below)
> the problem goes away. Or if I add the word 'struct', it also goes away.
>
> This is causing problems in Eclipse because -var-info-path-expression
> returns the expression that causes a syntax error.
>
> I tried to debug it but I ended up in c-exp.y and had to give up.
>
> I was going to propose a patch that adds 'struct' to the
> -var-info-path-expression output, but I didn't think that was the
> greatest of solutions. Currently, this is what we are planning to
> do in Eclipse to work around this problem.
>
> I can open a PR if it makes sense?
Tom mentioned the 'struct' workaround in comment #4 to
http://sourceware.org/bugzilla/show_bug.cgi?id=11912, so
maybe the issue is related.
Andre'
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: GDB syntax error when casting to base class
2010-09-09 14:00 ` André Pönitz
@ 2010-09-09 15:09 ` Marc Khouzam
0 siblings, 0 replies; 3+ messages in thread
From: Marc Khouzam @ 2010-09-09 15:09 UTC (permalink / raw)
To: 'André Pönitz', 'gdb@sourceware.org'
> -----Original Message-----
> From: André Pönitz [mailto:andre.poenitz@nokia.com]
> Sent: Thursday, September 09, 2010 10:00 AM
> To: gdb@sourceware.org
> Cc: Marc Khouzam
> Subject: Re: GDB syntax error when casting to base class
>
> On Thursday 09 September 2010 14:50:07 ext Marc Khouzam wrote:
> > Hi,
> >
> > I got an eclipse bug report that led me to a bizarre
> behavior from GDB.
> > In the very short session below, I'm getting a syntax error
> when casting
> > a variable to its base class.
> > If I remove the constructor (see comment in the code below)
> > the problem goes away. Or if I add the word 'struct', it
> also goes away.
> >
> > This is causing problems in Eclipse because
> -var-info-path-expression
> > returns the expression that causes a syntax error.
> >
> > I tried to debug it but I ended up in c-exp.y and had to give up.
> >
> > I was going to propose a patch that adds 'struct' to the
> > -var-info-path-expression output, but I didn't think that was the
> > greatest of solutions. Currently, this is what we are planning to
> > do in Eclipse to work around this problem.
> >
> > I can open a PR if it makes sense?
>
> Tom mentioned the 'struct' workaround in comment #4 to
> http://sourceware.org/bugzilla/show_bug.cgi?id=11912, so
> maybe the issue is related.
Yes, it looks like the same issue except that it also happens with 6.8.
I've added my info to the bug.
Thanks!
Marc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-09 15:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-09 12:50 GDB syntax error when casting to base class Marc Khouzam
2010-09-09 14:00 ` André Pönitz
2010-09-09 15:09 ` Marc Khouzam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox