Re: Watchpoints
Re: Watchpoints
- Subject: Re: Watchpoints
- From: Jim Ingham <email@hidden>
- Date: Thu, 17 Nov 2005 11:47:25 -0800
The watchpoint evaluator is being a little too clever for you, and in
the end not helping you out. Here's how it works. You suppose in a C
++ method, you say:
(gdb) watch this->ivar
So gdb is going to watch for ANYTHING that might change the value of
this expression. If the value of ivar changes, then the expression
will have changed. ALSO, if the value of "this" changes, that could
change the value of the expression. So we watch both the locations
of "this", and of "this->ivar". this->ivar is, as you correctly
state, not a stack variable, but somewhere on the heap.
Unfortunately, "this" really is a local variable, stored on the
stack, etc. So when the function scope is left, then the expression
is no longer valid, and can't be watched.
Sometimes this is useful, sometimes it isn't...
Anyway, you can work around this when you are watching stuff that is
referred to by local variables, by just watching the address of the
variable. So go to the console, and do:
(gdb) print &(this->ivar)
0xabc
(gdb) watch (int) *0xabc
if ivar is an int...
I have a bug to add a "watch only the resultant address of this
expression" variant of the watch command. But I haven't gotten to it
yet.
Jim
On Nov 17, 2005, at 11:26 AM, Jonathan Taylor wrote:
Just wondering - has anybody actually got watchpoints to work
reliably in Xcode? I can set them ok, but I get a message "The
program has left the block in which its expression in valid" almost
immediately. That is complete rubbish, incidentally! It seems to
happen as soon as another function is called. For example, I can
set the watchpoint on an instance variable in a class (when the PC
is in one of that class's methods and the focus in the debugger is
in that function at the top of the stack) and as soon as that
function calls through to another method _of_the_same_class_ I get
that error. This obviously makes watchpoints next to useless. This
has been the case since at least Xcode 2.1, quite possibly earlier.
Do other people see this? Can anybody suggest any workaround? I'm
fairly bored of coming up with repro scenarios for Radar at the
moment, so has anybody already raised this issue?
Cheers
Jonny
_______________________________________________
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
References: | |
| >Watchpoints (From: Jonathan Taylor <email@hidden>) |