Question about remote debugging protocol setup

Hi All,

I'm trying to understand how to write a gdbserver for one of our chips, which we are planning to attach lldb to.

First off, I started doing a sniff of protocol between debugger and gdbserver with local debug of an linux intel 64-bit process.

I then compared the traces between the debugger being gdb and lldb.

Using gdb:

CLIENT SENDS: +
CLIENT SENDS: $qSupported:multiprocess+;xmlRegisters=i386;qRelocInsn+#b5
SERVER SENDS: +
SERVER SENDS: $PacketSize=3fff;QPassSignals+;QProgramSignals+;qXfer:libraries-svr4:read+;augmented-libraries-svr4-read+;qXfer:auxv:read+;qXfer:spu:read+;qXfer:spu:write+;qXfer:siginfo:read+;qXfer:siginfo:write+;qXfer:features:read+;QStartNoAckMode+;qXfer:osdata:read+;multiprocess+;QNonStop+;QDisableRandomization+;qXfer:threads:read+;ConditionalTracepoints+;TraceStateVariables+;TracepointSource+;DisconnectedTracing+;FastTracepoints+;StaticTracepoints+;InstallInTrace+;qXfer:statictrace:read+;qXfer:traceframe-info:read+;EnableDisableTracepoints+;QTBuffer:size+;tracenz+;ConditionalBreakpoints+;BreakpointCommands+;QAgent+;Qbtrace:bts+;Qbtrace:off+;qXfer:btrace:read+#ad
SERVER SENDS: +
CLIENT SENDS: $QStartNoAckMode#b0
SERVER SENDS: +
SERVER SENDS: $OK#9a
CLIENT SENDS: +

Using lldb:

CLIENT SENDS: +
CLIENT SENDS: $QStartNoAckMode#b0
SERVER SENDS: +
CLIENT SENDS: $OK#9a
SERVER SENDS: +

So I'm wondering why does lldb not send the qSupported request? Is it a deliberate omission or is this still a work in progress?

All viewpoints appreciated,
thanks Matt

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.

So I'm wondering why does lldb not send the qSupported request? Is it a deliberate omission or is this still a work in progress?

All viewpoints appreciated,
thanks Matt

Matt,
I think source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient::GetRemoteQSupported () is lazily evaluated thanks to work by Steve Pucci in January (Thu 23/01/2014 21:04 [lldb-dev] [PATCH] new utility methods in GDBRemoteCommunicationClient)

That is, the qSupported is only sent when the debugger really needs to know about certain features like the SVR_4 library list - which would be irrelevant on a platform with no ld.so dynamic linker. Lldb should then start slightly faster than gdb for some scenarios.

David Earlam

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.

Note, if you are going to write an monitor to work with lldb, if you haven't already, take a look at:

http://llvm.org/svn/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt

That has the additional packets that lldb will send an use to make debugging go faster. lldb will still work with a vanilla gdb-remote protocol monitor, but have a look at what is there to see if it makes sense for you to support any of these additions.

Jim

All debugging on MacOSX uses the GDB remote protocol a Mac specific GDB server binary called "debugserver". So the GDB remote protocol is very well supported and quite mature.

The GDB remote protocol, as GDB implements it, lacks key features required to support good multi-threaded debugging. As Jim stated, we fix this by adding LLDB specific additions:

svn cat http://llvm.org/svn/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt

The main issue with the standard GDB remote protocol is it likes to think only one thread stops for a reason. So if you run a multi-threaded program and more than one thread stops at a breakpoint, the standard GDB server will tell you about one of them only. Then when you continue, it won't actually continue, it will immediately stop at one of the other threads. This means stepping through multi-threaded code is quite painful as you ping pong between threads. So if you will only have 1 thread, you won't need to worry about this. If you have multiple threads, you should. We specify which packets are important to implement and classify them by which ones you should implement first.

Greg Clayton