title: Best way to print information when debugging a race condition
body: <p>I am debugging an application to fix a segmentation fault that I suspect to be caused by a race condition.</p>
  
  <p>I'd like to put some print statements in the code, but I know for experience that adding calls to <code>printf</code> is not recommended since this could change the behavior of the threads and in some case hide the bug.</p>
  
  <p>Looking at other options, I have seen that with <strong>gdb</strong> it is possible to use break points to print something and then automatically continue the execution:</p>
  
  <pre><code>break foo
  commands
  silent
  printf "Called foo: x is %d\n",x
  cont
  end
  </code></pre>
  
  <p>Is this any better then putting a <code>printf</code> in my code?</p>
  
  <p>I know that <strong>gdb</strong> has a also <a href="https://sourceware.org/gdb/onlinedocs/gdb/Tracepoints.html" rel="noreferrer">Tracepoints</a> but they only work with gdbserver and this is an additional level of complication that I would prefer to avoid at the moment.</p>
  
  <p><em>Additional information</em>: the application is written in C and it runs on Linux.</p>