Re: Using watchpoints... (was Re: Possible GCC Bug?)
Re: Using watchpoints... (was Re: Possible GCC Bug?)
- Subject: Re: Using watchpoints... (was Re: Possible GCC Bug?)
- From: "B.J. Buchalter" <email@hidden>
- Date: Wed, 9 Apr 2008 19:30:53 -0400
On Apr 9, 2008, at 6:02 PM, Jim Ingham wrote:
To be clear... What's going on when you say:
(gdb) watch this->path->to->my->member
is that you are asking gdb to watch an EXPRESSION. There are many
reasons why the result of evaluating this expression might change.
For instance, "this" could change it's value. So could "path",
etc... So gdb watches all the components down the chain of the
expression.
Actually, I never am doing that. That is what Xcode was (is) doing
when I used the UI. I always do the address when I am doing it manually.
Watching an expression is very useful, but often times not what you
want. For instance,in the case you used of the "this" pointer,
"this" is the argument to a function. So the whole expression
becomes invalid when you leave the function scope, even though the
memory that it resolved to is actually on the heap somewhere. At
that point the watchpoint gets unset.
Yeah -- it is actually rarely what I want. I almost always am using
watchpoints for variable smashing bugs -- I just want to know when the
variable changes, not some complex expression.
sAnother potential problem with watching complex expressions on x86
machines is that they will exhaust the hardware watchpoint
capabilities (there are 4 on current x86 chips.)
We made it easier to watch the "current location this expression
resolves to" by adding a "-location" flag to the gdb "watch" command
a la:
(gdb) watch -location (this->path->to->my->member)
Oh -- that's cool. Even easier. Thanks.
That's the same as the two commands you gave above. The most recent
Xcode uses the "-location" for expressions it sets with the Run-
>Variables View->Watch Variables, but I don't remember when we
switched over to doing that however, maybe 3.1?
Make sense. I am not on 3.1 yet, so I *don't* think I have seen that
behavior yet. But the problem I was talking about has nothing to do
with the location issue. Rather it has to do with the fact that Xcode
sends gbd an expression that makes gdb barf and the watchpoint is not
set at all, which is why you often have to take a trip to the debugger
console....
Best regards,
B.J. Buchalter
Metric Halo
http://www.mhlabs.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden