title: How does gdb select "current thread"?
body: <p>When <code>gdb</code> controls the program, it will select a thread as "current thread".   </p>
  
  <p>For example, use <code>gdb</code> to debug core dump file, the corrupt thread will be the "current thread":  </p>
  
  <pre><code># gdb -q program core_program_0_0_1402630731_27929
   (gdb) bt
   #0  0xfefb2d50 in strlen () from /lib/libc.so.1
   #1  0xff01f4a0 in _ndoprnt () from /lib/libc.so.1
   #2  0xff021cac in vsprintf () from /lib/libc.so.1
   ......
   #9  0xff04aee8 in _lwp_start () from /lib/libc.so.1
  </code></pre>
  
  <p>But if the program is running, when the <code>gdb</code> attach it, how does it select the "current thread"? I have done a test, and find it uses the main thread as the "current thread".  </p>
  
  <p>Does <code>gdb</code> always choose main thread as the "current thread"? I have searched in the <a href="https://sourceware.org/gdb/onlinedocs/gdb/Threads.html" rel="nofollow">gdb manual</a>, but unfortunately, there is no answer about it.  </p>
  
  <p>Could any one give some comments on this issue?</p>