Using watchpoints... (was Re: Possible GCC Bug?)
Using watchpoints... (was Re: Possible GCC Bug?)
- Subject: Using watchpoints... (was Re: Possible GCC Bug?)
- From: Jim Ingham <email@hidden>
- Date: Wed, 9 Apr 2008 15:02:12 -0700
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.
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.
Another 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)
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?
Jim
On Apr 9, 2008, at 2:11 PM, B.J. Buchalter wrote:
On Apr 9, 2008, at 4:41 PM, Jack Repenning wrote:
On Apr 9, 2008, at 12:34 PM, B.J. Buchalter wrote:
Xcode manages to confuse the hell out of gdb when you try to watch
(sufficiently nested) member variables, and the watch doesn't get
set. You can work around this by going into the gdb console and
typing:
p &(this->path->to->my->member)
Is this confusion apparent at the Xcode UI? Or should I just be
paranoid and always use this technique when there's indirection
involved?
There is a small, unobvious error put into the status bar at the
bottom of some of the windows (where it would normally say things
like "build succeeded" and it is also printed into the gdb console.
But it doesn't put up a dialog or anything, so you have to double
check...
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
_______________________________________________
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