<div dir="ltr">Hey, awesome Andy!  <div><br></div><div>Thanks for the patch and the details.  I'm pretty sure I'll be interested in trying to at least get the current Android gdbserver working with lldb if for no other reason than to help decouple the remote platform piece from any other work that could be done in parallel on the lldb side.  I'm sure this will be useful info (and maybe code too) to have in that pursuit.  Very much appreciated!</div>
<div><br></div><div>> <span style="color:rgb(31,73,125);font-family:Calibri,sans-serif;font-size:15px">The register definition mechanism that Matt referred you to is much better.</span></div><div><span style="color:rgb(31,73,125);font-family:Calibri,sans-serif;font-size:15px"><br>
</span></div>I definitely have a task on my list to look at that.  Glad to hear others have given the idea a once-over, too. <div><br></div><div>Sincerely,</div><div>Todd Fiala</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Nov 19, 2013 at 12:54 PM, Kaylor, Andrew <span dir="ltr"><<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">






<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Todd,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I did some experimental work back in September to see what the road blocks might be in getting LLDB working with Android.  I’m attaching a patch from the branch
 I was working on back then.  This patch is probably badly out-of-date now, and it only just wiggled even when it was fresh.  It might be of some use to you though.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">The patch contains several things of varying degrees of usefulness.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">1. It implements LLDB “platform” support based on ADB.  The idea behind this was to see if I could get LLDB to attach to a “clean” Android device and install
 whatever bits were necessary to connect and start debugging.  This sort of worked but it’s quite sloppy, has almost no error handling and it’s debatable how much value it provides.  Also, this was my first exploration of LLDB’s platform mechanism, which was
 relatively new at the time, and I can’t promise I was doing it right.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">2. It provides a set of hard-coded x86-based register definitions.  This is absolutely not the correct way to do this, but it was the quickest way to get something
 working.  You’d think you could reuse one of the existing register context classes provided by LLDB, but the implementation that was current at the time didn’t work that way (and I think it still doesn’t).  The register definition mechanism that Matt referred
 you to is much better.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">3. It fixes a problem with LLDB’s remote protocol handling that causes it to throw away register values provided in a gdb-remote packet if the values don’t
 appear in the expected order.  The particular problem this fixed for me was that the version of gdbserver I was working with was sending stop packets with values for the stack and instruction pointer registers, but they appeared before the thread info and
 so LLDB was ignoring them.  This was compounded by the fact that the version of gdbserver I was using wasn’t responding to attempts to query the value of these registers directly (or rather it was responding but it wasn’t giving me the values).<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">With this patch, I was able to attach to a process running on an x86 emulator.  As I recall I wasn’t able to set a breakpoint. I didn’t get as far as figuring
 out why, but I suspect it was something simple.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I definitely think that the platform independent remote debugging proposal that Matt referred you to is the correct direction for future work, but getting things
 working with gdbserver is probably at least an interesting exercise.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Good luck!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">-Andy<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> <a href="mailto:lldb-dev-bounces@cs.uiuc.edu" target="_blank">lldb-dev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:lldb-dev-bounces@cs.uiuc.edu" target="_blank">lldb-dev-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>Todd Fiala<br>
<b>Sent:</b> Monday, November 18, 2013 8:41 PM<br>
<b>To:</b> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> [lldb-dev] LLDB for Android initiative<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">Hi all!</span><u></u><u></u></p>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">I'm starting up an effort to get LLDB running on Android.  I just wanted to reach out, say hi, and give you an outline of how I'm thinking about attacking this effort.  I'm
 looking for feedback, so please fire away if you have any suggestions or comments!<u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"> I'm thinking of attacking the effort in stages, looking something like this:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">1. Get LLDB up and running against a local Linux x86 process. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"> It looks like many aspects of this already work.  I've heard there might be some rough edges around core dump support, DWARF 4/5 support, and possibly some optimized debug
 info support on the clang side, so any work here might touch those areas.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">I see we have what looks like 2 buildbots dedicated to building lldb in linux scenarios:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><a href="http://lab.llvm.org:8011/builders/lldb-x86_64-debian-clang" target="_blank">http://lab.llvm.org:8011/builders/lldb-x86_64-debian-clang</a><u></u><u></u></span></p>

</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><a href="http://lab.llvm.org:8011/builders/lldb-x86_64-linux" target="_blank">http://lab.llvm.org:8011/builders/lldb-x86_64-linux</a><u></u><u></u></span></p>

</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">Android currently builds linux host tools as 32-bit.  Both of those buildbots above appear to be 64-bit. I'd love to get the equivalent of an Ubuntu 12.04 LTS x64 buildbot
 building a 32-bit LLDB executable.  How can I go about setting that up?   <u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">2. Get the LLDB remote solution up and running against a remote Linux x86 process.  <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">Here we get to the first high-level question mark: do we continue to use gdbserver, use debugserver, or base something on lldb-platform?  I haven't dug into this yet.  I've
 heard some thoughts on this topic, such as (a) LLDB has extended the gdb remote protocol and offers some benefits over using gdbserver, (b) debugserver is currently very part-specific and might be a painful way to go in the short term (but I haven't heard
 comments on the longer-term potential benefits of toughing through that), and (c) lldb-platform is a reasonable starting point and has been used to get some traction bringing up LLDB on other chipsets.  Like in (1), I'll want to set up a build bot that builds
 and runs remote tests in this environment.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">Any thoughts on this?<u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">3. Get the LLDB remote solution up and running against a remote Linux ARM system.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">The idea being that it will be easier for me to poke around on the Linux ARM system than it would be to go straight for the Android device or emulator, but gets me working
 against an ARM system, one step closer to a typical Nexus device.  And helps out ARM Linux remote support in the process (if there are any weak spots).  I don't know yet what the scope of work here might entail.  Similar to (2), I'll want to set up a build
 bot that builds and runs remote tests in this environment as well.<u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><img border="0"><u></u><u></u></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">4. Getting LLDB remote solution up and running against an Android ARM device.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">5. Either directly implement or make it straightforward for Android vendors to fill in anything necessary to use our remote solution on other Android hardware.<u></u><u></u></span></p>

</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">I look forward to working with the LLDB community on this effort!  Suggestions or comments are appreciated.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">Sincerely,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif">Todd Fiala<u></u><u></u></span></p>
</div>
</div>
</div>
</div></div></div>
</div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34)">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-397-1352</a></font></td></tr></tbody></table><br></div>
</div></div>