title: Automate GDB to print stack frame at a particular breakpoint
body: <p>Is it possible to have gdb attached to the PID of a running process and every time the program hits a particular breakpoint have gdb output the stackframe to an external file?</p>
  
  <p>I've had a look at <a href="https://stackoverflow.com/questions/2388799/automate-gdb-show-backtrace-at-every-call-to-function-puts">this</a> and <a href="https://stackoverflow.com/questions/10748501/automating-gdb-sessions?lq=1">this</a> but there is no mention on whether it is possible to attach gdb to an already running process (instead of having gdb launch it).</p>
  
  <p>I can otherwise attach gdb to the PID just fine, but I'd like to automate it to run <code>bt</code>, store the output in an external file and then run <code>continue</code>. At the moment I'm doing this manually and it's a pain when I have to do it every time a breakpoint is hit.</p>