title: How to debug a running C++ program in Linux?
body: <p>I have a question about debugging a running C++ program in Linux. If a programming is already running and can't be interrupted, how to do that. </p>
  
  <p>I can find three ways, but I don't know too much about details, I am grateful if any one can elaborate it deeper.</p>
  
  <p>1) we can use GDB by specifying the process ID</p>
  
  <pre><code>gdb -p PID
  </code></pre>
  
  <p>In this case, what's the difference between this and <code>attach PID</code>?</p>
  
  <p>2) We can use pstat, however, I am using Ubuntu, no pstat, but only mpstat</p>
  
  <p>it seems that mpstat does not provide too much information, and not so many options.</p>
  
  <p>3) check the details information under directory ./proc</p>
  
  <p>In this case, just go to the directory with the PID. However, should this be done mannually?</p>