* C++ debugging pain
@ 2008-08-27 16:04 Stefano Sabatini
2008-08-27 16:47 ` Paul Pluzhnikov
0 siblings, 1 reply; 3+ messages in thread
From: Stefano Sabatini @ 2008-08-27 16:04 UTC (permalink / raw)
To: gdb Mailing List
Hi all,
I'm writing here since google didn't help with the problems I'm
facing.
I'm currently writing a C++ app, and I'm using gdb to debug its code
(code compiled by gcc/g++), and facing many problems which make the use
of gdb quite problematic not to say frustrating sometimes.
Common problems which I'm faced are mainly:
* incomplete types problems when trying to print object with p.
I today followed a tip and added -femit-class-debug-always and
apparently I got that problem fixed.
* "class X does not have any method named Y": this happens with
virtual methods defined in a parent class rather than in the class
of the instance debugged
* "Cannot resolve method (null)X to any overloaded instance":
this happen when I try to invoke a method on some object
I've been already advised by Daniel Jacobowitz (thanks Daniel) that
it could depend on the method invoked being inlined.
I'll eventually try to provide test cases for each one of these
problems, for the moment I would just like to know if:
* these are common problems, or are just the way the universe is conjuring
for telling me: "I don't like you" ;-)
* these are to be considered gcc/gdb bugs, or are simply unavoidable
problems
* there is some magic incantation (e.g. gcc/gdb options) I could or should
use in order to avoid them.
Many thanks in advance.
Regards.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: C++ debugging pain
2008-08-27 16:04 C++ debugging pain Stefano Sabatini
@ 2008-08-27 16:47 ` Paul Pluzhnikov
2008-08-27 22:46 ` Stefano Sabatini
0 siblings, 1 reply; 3+ messages in thread
From: Paul Pluzhnikov @ 2008-08-27 16:47 UTC (permalink / raw)
To: gdb Mailing List; +Cc: Stefano Sabatini
On Tue, Aug 26, 2008 at 9:22 AM, Stefano Sabatini
<stefano.sabatini-lala@poste.it> wrote:
> * "class X does not have any method named Y": this happens with
> virtual methods defined in a parent class rather than in the class
> of the instance debugged
Try "set print object on".
(I am working on a fix which would make that unnecessary).
> * "Cannot resolve method (null)X to any overloaded instance":
> this happen when I try to invoke a method on some object
This usually happens when you have a pointer to Foo, and do:
print p.virtfn()
Instead, try:
print p->virtfn()
(I am also working on that fix).
> I've been already advised by Daniel Jacobowitz (thanks Daniel) that
> it could depend on the method invoked being inlined.
If you compiled without '-O*', no inlining should have happened.
If you do compile with '-g -O2', you are inflicting pain on yourself.
Cheers,
--
Paul Pluzhnikov
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: C++ debugging pain
2008-08-27 16:47 ` Paul Pluzhnikov
@ 2008-08-27 22:46 ` Stefano Sabatini
0 siblings, 0 replies; 3+ messages in thread
From: Stefano Sabatini @ 2008-08-27 22:46 UTC (permalink / raw)
To: gdb Mailing List
On date Tuesday 2008-08-26 09:36:35 -0700, Paul Pluzhnikov wrote:
> On Tue, Aug 26, 2008 at 9:22 AM, Stefano Sabatini
> <stefano.sabatini-lala@poste.it> wrote:
>
> > * "class X does not have any method named Y": this happens with
> > virtual methods defined in a parent class rather than in the class
> > of the instance debugged
>
> Try "set print object on".
> (I am working on a fix which would make that unnecessary).
I checked my gdbinit, I already had the command:
set print object
I think it should be equivalent to your command.
BTW I forgot to give my gdb version:
gdb --version
GNU gdb 6.8-debian
> > * "Cannot resolve method (null)X to any overloaded instance":
> > this happen when I try to invoke a method on some object
>
> This usually happens when you have a pointer to Foo, and do:
>
> print p.virtfn()
>
> Instead, try:
>
> print p->virtfn()
>
> (I am also working on that fix).
>
> > I've been already advised by Daniel Jacobowitz (thanks Daniel) that
> > it could depend on the method invoked being inlined.
Another problem which I'm facing is that I sometimes can't set
breakpoints on some functions, for example:
(gdb) b PUDPSocket::WriteTo()
Function "PUDPSocket::WriteTo()" not defined.
(gdb) b PUDPSocket::WriteTo
the class PUDPSocket does not have any method named WriteTo
Hint: try 'PUDPSocket::WriteTo<TAB> or 'PUDPSocket::WriteTo<ESC-?>
(Note leading single quote.)
Note also the inconsistency in the feedback message.
These are classes from the libpt, but now I'm not sure they've been
compiled with the right options (-O0 -ggdb) due to messy build system
implemented for that library.
> If you compiled without '-O*', no inlining should have happened.
> If you do compile with '-g -O2', you are inflicting pain on yourself.
Well being a programmer I like to inflict myself pain, but I'm not that
masochistic ;-), always use -O0 -ggdb when compiling.
BTW I'd be glad to help testing, feel free to contact me if you need
some tester for those fixes.
Thanks for your precious help.
Regards.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-27 7:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-27 16:04 C++ debugging pain Stefano Sabatini
2008-08-27 16:47 ` Paul Pluzhnikov
2008-08-27 22:46 ` Stefano Sabatini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox