title: Is it possible to set a gdb watchpoint programmatically?
body: <p>I want to set a watchpoint (break on hardware write) temporarily in my C++ program to find memory corruption.</p>
  
  <p>I've seen all the ways to do it manually through gdb, but I would like to actually set the watchpoint via some method in my code so I don't have to break into gdb, find out the address, set the watchpoint and then continue.</p>
  
  <p>Something like:</p>
  
  <pre><code>#define SET_WATCHPOINT(addr) asm ("set break on hardware write %addr")
  </code></pre>