I am trying to find out who is changing my pNode->data between lines 3 and 5.
What makes you think that data
is getting modified between lines 3 and 5?
If the list is shared, pNode->data
could be modified 5 iterations later, or when the loop is already done.
In general, debugging multithreaded programs with debugger is hard. You really need to prove that the program is correct by construction, that is: you need to confirm that every time pNode->data
is modified, some mutex is held (I assume that's what you meant by "latch").
That said, you can achieve what you asked for.
Find the address of instruction immediately after line 3 ends, and set a breakpoint on that instruction (use b *0xaddress
to do so). Attach commands to that breakpoint:
commands 1
silent
watch -l pNode->data
cont
end
Likewise, find the instruction just before pNode
is assigned on line 5 and set a breakpoint there. Attach commands:
commands 2
silent
delete $bpnum
cont
end
This uses $bpnum
convenience variable, which is set to the number of breakpoint that was last set.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…