Watchpoints are used to track a write to an address in memory (the default behavior). If you know where an object is in memory (you have a pointer to it), and you know the offset into the object that you care about, that's what watchpoints are for. For instance, in a simple C example, if you have:
struct info
{
int a;
int b;
int c;
};
int main()
{
struct info variable = {5, 10, 20};
variable.a += 5; // put a breakpoint on this line, run to the breakpoint
variable.b += 5;
variable.c += 5;
return variable.a + variable.b + variable.c;
}
Once you're at a breakpoint on variable.a
, do:
(lldb) wa se va variable.c
(lldb) continue
And the program will pause when variable.c
has been modified. (I didn't bother to type out the full "watch set variable" command).
With a complex object like an NSMutableDictionary
, for instance, I don't think watchpoints will do what you need. You would need to know the implementation details of the NSMutableDictionary
object layout to know which word (or words) of memory to set a watchpoint.