This is a preliminary patch that adds lldb support for querying the register mapping from gdbserver remote targets using qXfer:features:read packet.
I have been testing this patch using x86 gdbserver running on the android emulator however I will be trying more gdbserver flavours (arm/mips) in the next few days.
Since this patch ties into a range of place in LLDB I thought It would be best to submit it early to get some feedback.
With this patch, upon connection to a remote, if lldb has no register information loaded and it sees the target supports qXfer:features:read, it will try to extract register info at that point.
It will parse all scalar registers, and translates this directly into gdb remote dynamic register info. Still to be implemented are vector register and flag register layout parsing.
This is currently enough to enable basic debugging via gdbserver from lldb with no prior knowledge of the target registers.
C&C will be appreciated.
A quick note on how I compiled libxml2 on windows and linked lldb against it:
I downloaded the latest libxml2 snapshot: ftp://xmlsoft.org/libxml2/libxml2-git-snapshot.tar.gz After unpacking I navigated to libxml2-2.9.2\win32. I ran a configuration using the following command: D:\libxml2\libxml2-2.9.2\win32>cscript configure.js compiler=msvc prefix=c:\opt include=c:\opt\include lib=c:\opt\lib debug=yes iconv=no use [vcvars32.bat for 32bit] build, or [vcvars64.bat for 64bit] build to kickstart compilation run: D:\libxml2\libxml2-2.9.2\win32>nmake /f Makefile.msvc The libs can be found in the following path: D:\libxml2\libxml2-2.9.2\win32\bin.msvc These libs were then supplied when running CMake for llvm: LIBXML2_INCLUDE_DIR=D:/libxml2/include LIBXML2_LIBRARIES=D:/libxml2/win32/bin.msvc/libxml2.lib
Also, here is a quick view of the initial gdb-rsp transcript for quick reference:
(lldb) log enable gdb-remote packets (lldb) target create d:/test.so Current executable set to 'd:/test.so' (i386). (lldb) gdb-remote 1234 < 1> send packet: + history[1] tid=0x1dac < 1> send packet: + < 19> send packet: $QStartNoAckMode#b0 < 1> read packet: + < 6> read packet: $OK#9a < 1> send packet: + < 41> send packet: $qSupported:xmlRegisters=i386,arm,mips#12 < 542> read packet: $PacketSize=3fff;QPassSignals+;QProgramSignals+;qXfer:libraries-svr4:read+;qXfer:auxv:read+;qXfer:spu:read+;qXfer:spu:wr ite+;qXfer:siginfo:read+;qXfer:siginfo:write+;qXfer:features:read+;QStartNoAckMode+;qXfer:osdata:read+;multiprocess+;QNonStop+;qXfer:threads :read+;ConditionalTracepoints+;TraceStateVariables+;TracepointSource+;DisconnectedTracing+;StaticTracepoints+;InstallInTrace+;qXfer:statictr ace:read+;qXfer:traceframe-info:read+;EnableDisableTracepoints+;QTBuffer:size+;tracenz+;ConditionalBreakpoints+;BreakpointCommands+;QAgent+# 9f < 40> send packet: $qXfer:features:read:target.xml:0,fff#7d < 582> read packet: $6c3c3f786d6c2076657273696f6e3d22312e30223f3e0a3c212d2d20436f707972696768742028432920323031302d32303133204672656520536f6 6747761726520466f756e646174696f6e2c20496e632e0a0a202a21436f7079696e6720616e6420646973747269627574696f6e206f6620746869732066696c652c207769746 8206f7220776974686f7574206d6f64696669636174696f6e2c0a202a21617265207065726d697474656420696e20616e79206d656469756d20776974686f757420726f79616 c74792070726f76696465642074686520636f707972696768740a202a216e6f7469636520616e642074686973206e6f7469636520617265207072657365727665642e20202d2 d3e0a0a3c212d2d2049333836207769746820535345202d20496e636c75646573204c696e75782d6f6e6c79207370656369616c20227265676973746572222e20202d2d3e0a0 a3c21444f4354595045207461726765742053595354454d20226764622d7461726765742e647464223e0a3c7461726765743e0a20203c6172636869746563747572653e69333 8363c2f6172636869746563747572653e0a20203c6f736162693e474e552f4c696e75783c2f6f736162693e0a20203c78693a696e636c75646520687265663d2233326269742 d636f72652e786d6c222f3e0a20203c78693a696e636c75646520687265663d2233326269742d6c696e75782e786d6c222f3e0a20203c78693a696e636c75646520687265663 d2233326269742d7373652e786d6c222f3e0a3c2f7461726765743e0a#75 noname.xml:14: namespace error : Namespace prefix xi on include is not defined <xi:include href="32bit-core.xml"/> ^ noname.xml:15: namespace error : Namespace prefix xi on include is not defined <xi:include href="32bit-linux.xml"/> ^ noname.xml:16: namespace error : Namespace prefix xi on include is not defined <xi:include href="32bit-sse.xml"/> ^ < 44> send packet: $qXfer:features:read:32bit-core.xml:0,fff#70 <2736> read packet: $6c3c3f786d6c2076657273696f6e3d22312e30223f3e0a3c212d2d20436f707972696768742028432920323031302d32303133204672656520536f6 6747761726520466f756e646174696f6e2c20496e632e0a0a202a21436f7079696e6720616e6420646973747269627574696f6e206f6620746869732066696c652c207769746 8206f7220776974686f7574206d6f64696669636174696f6e2c0a202a21617265207065726d697474656420696e20616e79206d656469756d20776974686f757420726f79616 c74792070726f76696465642074686520636f707972696768740a202a216e6f7469636520616e642074686973206e6f7469636520617265207072657365727665642e20202d2 d3e0a0a3c21444f435459504520666561747572652053595354454d20226764622d7461726765742e647464223e0a3c66656174757265206e616d653d226f72672e676e752e6 764622e693338362e636f7265223e0a20203c666c6167732069643d22693338365f65666c616773222073697a653d2234223e0a202a203c6669656c64206e616d653d2243462 ...
Unfortunately, by default libxml2 outputs warnings on stdout as it parses which is why the following messages show up. In a revised patch I will suppress this completely or pipe it into one of the logging channels.
noname.xml:16: namespace error : Namespace prefix xi on include is not defined <xi:include href="32bit-sse.xml"/> ^