If I set a watchpoint for a variable local to the current scope, it will be auto deleted when going out of the scope. Is there any way to set it once and keep it au
You can set a watchpoint that does not go out of scope by setting it to the memory address.
(gdb) p &var1 $1 = (int *) 0x41523c0 (gdb) watch *(int *)0x41523c0 Hardware watchpoint 1: *(int *)0x41523c0
This also works for other data types and pointers.