title: Is it possible to have multiple connections to gdbserver?
body: <p>I am using Eclipse CDT and the GNU ARM QEMU simulator. Eclipse starts it own <code>gdb</code> session with the <code>gdbserver</code> running on QEMU. I want to also be able to connect from an OSX terminal for more fine tuned control. I also want to be able to use the GDB/MI from a Node.js script to grab useful data like register status, etc. and visualise it in a webpage.</p>
  
  <p>I can connect fine when running QEMU simulator standalone with my own gdb session, but I wanted to know if its possible to piggy back onto Eclipse's gdb, or make a second connection to <code>gdbserver</code>.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>From <a href="https://sourceware.org/gdb/onlinedocs/gdb/Server.html" rel="noreferrer">https://sourceware.org/gdb/onlinedocs/gdb/Server.html</a> (20.3.1.2):</p>
  
  <blockquote>
    <p>When gdbserver stays running, gdb can connect to it again later. Such reconnecting is useful for features like disconnected tracing. For completeness, at most one gdb can be connected at a time.</p>
  </blockquote>
  
  <hr>
  
  <p>So far I could not figure it out and it seems from the docs that it is not possible.</p>
  
  <p>The solution I am using now is to run the QEMU simulator manually from the terminal. The GNU ARM Eclipse debugger allows specifiying a <code>gdbserver</code> <code>host:port</code>, which I can point at the standalone QEMU which works fine.</p>
  
  <p>To allow simulatenous gdb sessions, I could create a custom TCP server for Eclipse to connect to instead of connecting directly to <code>gdbserver</code>. This TCP server would forward all traffic from Eclipse to the <code>gdbserver</code>, and I can also listen to and send messages to gdb over this channel.</p>
  
  <p>The end result being that you can debug and set breakpoints in Eclipse as usual, but also interact with gdb any way you want to such as through a web interface, native OSX terminal, etc.</p>