I want to set a watchpoint (break on hardware write) temporarily in my C++ program to find memory corruption.
I\'ve seen all the ways to do it manually through gdb,
If you happen to be using Xcode, you can achieve the required effect (automatic setting of watchpoints) by using an action on another breakpoint to set your watchpoint:
watchpoint set variable  (or if you're using GDB1, a command like: watch ),
1: GDB is no longer supported in more recent versions of Xcode, but I believe it is still possible to set it up manually.