Lets say I have the following simplified code to loop through a linked list. Each node has a data pointer and next pointer.
1 while (pNode->next != NULL)
2 {
3 pNode->data = newData;
4
5 pNode = pNode->next;
6 }
How would I go about automatically setting up a watchpoint on the address of the current pNode->data
and update it every time pNode changes? So have something like on line 1 delete the watchpoint and set a new watchpoint on pNode->data
. And then since this doesn't happen always I would need to clear all watchpoints after so I don't halt unnecessarily so on line 7 clear all watchpoints.
This code is running in a multithreaded application and pNode list is shared so I am trying to find out who is changing my pNode->data between lines 3 and 5. I do have a latch that should be preventing changing the list while I iterate but because of this error we must be changing it somewhere without the latch and I want to find out where.