* Is c++ debugging really "this" bad?
@ 2002-07-29 19:56 Peter Thompson/Amy Kirschner
2002-07-29 20:03 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Peter Thompson/Amy Kirschner @ 2002-07-29 19:56 UTC (permalink / raw)
To: gdb
I'm doing some contract work helping a small company with their tool
issues and have run across a nasty c++/gdb interaction. I've been
checking the archives and I find some related bugs in the c++ area, but
not the specific issue I'm running into.
The basic problem. Printing the value of 'this', the c++ object
pointer, does not agree with a simple printf of 'this' in the same
routine. The particular routine I'm looking at is a destructor routine,
and I have seen reasonable values of 'this' in other routines, but the
wrong behavior seems to occur more often. Or maybe just gets reported
to me more often...
Some details: We're using the 3.0.1 version of gcc and gdb with a mips
32 instruction set. We do have a version of 3.0.4 available, but have
not done extensive testing with that. Gdb first looks for a local
variable, $this, but doesn't find it in the current scope, or any
containing scope. Then it attempts to find 'this' in the local scope,
and, failing that, looks to the outer scope where it does eventually
find a 'this' variable, which is of course totally unrelated. Our
standard compilation options are (among a variety of others) -g and -O1.
I've tried -g -O0, -g by itself (pretty much the same, eh?), -g3 -O1,
and while -O0 produces a local copy of 'this', it still doesn't find the
right value. The gcc compiler I'm using produces a .mdebug section,
which contains ecoff data, and does not recognize a -gdwarf or -gdwarf-2
option.
I keep getting the feeling that maybe I'm just missing something basic,
or the debugger is. Certainly the compiler knows where the real value
is, and I can track it via the machine code for any line that
manipulates 'this', but I don't expect all the users to be able to do
that readily. Does this ring any bells with anyone?
Thanks,
PeterT
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is c++ debugging really "this" bad?
2002-07-29 19:56 Is c++ debugging really "this" bad? Peter Thompson/Amy Kirschner
@ 2002-07-29 20:03 ` Daniel Jacobowitz
2002-07-29 21:25 ` Peter Thompson/Amy Kirschner
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2002-07-29 20:03 UTC (permalink / raw)
To: Peter Thompson/Amy Kirschner; +Cc: gdb
On Mon, Jul 29, 2002 at 10:57:16PM -0400, Peter Thompson/Amy Kirschner wrote:
> I'm doing some contract work helping a small company with their tool
> issues and have run across a nasty c++/gdb interaction. I've been
> checking the archives and I find some related bugs in the c++ area, but
> not the specific issue I'm running into.
>
> The basic problem. Printing the value of 'this', the c++ object
> pointer, does not agree with a simple printf of 'this' in the same
> routine. The particular routine I'm looking at is a destructor routine,
> and I have seen reasonable values of 'this' in other routines, but the
> wrong behavior seems to occur more often. Or maybe just gets reported
> to me more often...
>
> Some details: We're using the 3.0.1 version of gcc and gdb with a mips
> 32 instruction set. We do have a version of 3.0.4 available, but have
> not done extensive testing with that. Gdb first looks for a local
> variable, $this, but doesn't find it in the current scope, or any
> containing scope. Then it attempts to find 'this' in the local scope,
> and, failing that, looks to the outer scope where it does eventually
> find a 'this' variable, which is of course totally unrelated. Our
> standard compilation options are (among a variety of others) -g and -O1.
> I've tried -g -O0, -g by itself (pretty much the same, eh?), -g3 -O1,
> and while -O0 produces a local copy of 'this', it still doesn't find the
> right value. The gcc compiler I'm using produces a .mdebug section,
> which contains ecoff data, and does not recognize a -gdwarf or -gdwarf-2
> option.
>
> I keep getting the feeling that maybe I'm just missing something basic,
> or the debugger is. Certainly the compiler knows where the real value
> is, and I can track it via the machine code for any line that
> manipulates 'this', but I don't expect all the users to be able to do
> that readily. Does this ring any bells with anyone?
I've never specifically seen the debugger lose track of 'this' in
destructors, but I haven't tried in a little while.
With GCC 3.0.1 (and mdebug to boot) you can't really expect C++
debugging to work. The required changes for stabs debugging of C++
code are only in later releases; I think 3.0.4 was fixed but I'm not
sure. Use 3.1.1 if possible. That will require a matching binutils
upgrade.
You didn't mention what version of GDB you were using, also.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is c++ debugging really "this" bad?
2002-07-29 20:03 ` Daniel Jacobowitz
@ 2002-07-29 21:25 ` Peter Thompson/Amy Kirschner
0 siblings, 0 replies; 3+ messages in thread
From: Peter Thompson/Amy Kirschner @ 2002-07-29 21:25 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb
Ah, yes. I'm pretty sure we're using 5.1.1 gdb, but I'm at home, so that's just
an informed guess. It does lend support to upgrading gcc and gdb though. It
didn't really look like a simple fix!
PeterT
Daniel Jacobowitz wrote:
> On Mon, Jul 29, 2002 at 10:57:16PM -0400, Peter Thompson/Amy Kirschner wrote:
> > I'm doing some contract work helping a small company with their tool
> > issues and have run across a nasty c++/gdb interaction. I've been
> > checking the archives and I find some related bugs in the c++ area, but
> > not the specific issue I'm running into.
> >
> > The basic problem. Printing the value of 'this', the c++ object
> > pointer, does not agree with a simple printf of 'this' in the same
> > routine. The particular routine I'm looking at is a destructor routine,
> > and I have seen reasonable values of 'this' in other routines, but the
> > wrong behavior seems to occur more often. Or maybe just gets reported
> > to me more often...
> >
> > Some details: We're using the 3.0.1 version of gcc and gdb with a mips
> > 32 instruction set. We do have a version of 3.0.4 available, but have
> > not done extensive testing with that. Gdb first looks for a local
> > variable, $this, but doesn't find it in the current scope, or any
> > containing scope. Then it attempts to find 'this' in the local scope,
> > and, failing that, looks to the outer scope where it does eventually
> > find a 'this' variable, which is of course totally unrelated. Our
> > standard compilation options are (among a variety of others) -g and -O1.
> > I've tried -g -O0, -g by itself (pretty much the same, eh?), -g3 -O1,
> > and while -O0 produces a local copy of 'this', it still doesn't find the
> > right value. The gcc compiler I'm using produces a .mdebug section,
> > which contains ecoff data, and does not recognize a -gdwarf or -gdwarf-2
> > option.
> >
> > I keep getting the feeling that maybe I'm just missing something basic,
> > or the debugger is. Certainly the compiler knows where the real value
> > is, and I can track it via the machine code for any line that
> > manipulates 'this', but I don't expect all the users to be able to do
> > that readily. Does this ring any bells with anyone?
>
> I've never specifically seen the debugger lose track of 'this' in
> destructors, but I haven't tried in a little while.
>
> With GCC 3.0.1 (and mdebug to boot) you can't really expect C++
> debugging to work. The required changes for stabs debugging of C++
> code are only in later releases; I think 3.0.4 was fixed but I'm not
> sure. Use 3.1.1 if possible. That will require a matching binutils
> upgrade.
>
> You didn't mention what version of GDB you were using, also.
>
> --
> Daniel Jacobowitz Carnegie Mellon University
> MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-07-30 4:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-29 19:56 Is c++ debugging really "this" bad? Peter Thompson/Amy Kirschner
2002-07-29 20:03 ` Daniel Jacobowitz
2002-07-29 21:25 ` Peter Thompson/Amy Kirschner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox