<div dir="ltr">Hello,<div><br></div><div>Sorry, since I also had a RLE patch pending, here it is in case it is useful (before it's too late).</div><div>Hope we can merge both of them together maybe?<br></div><div><br></div>



<div>This one also tries to handle escaped characters (#, $ and }), when receiving and sending.<br></div><div>Did it from <a href="http://sourceware.org/gdb/onlinedocs/gdb/Overview.html">http://sourceware.org/gdb/onlinedocs/gdb/Overview.html</a></div>

<div>Also, it converts everything where the packet copy was happening, to avoid extra copy and O(n) insertion.</div><div>
<br>
</div><div>Not sure if checksum is supposed to work on the escaped version or not. Need to check how GDB is working (spec doesn't say anything).</div><div><br></div><div><div>I didn't have a chance to test it again since I added character escaping, so I should probably do that again in case there is real interest in it.</div>

<div>Also couldn't polish it as I intended, but thought it would still be more useful as is before the other one get merged than after.</div>

</div><div><br></div><div>Sincerely,</div><div>Virgile</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 27, 2013 at 6:51 PM, Abid, Hafiz <span dir="ltr"><<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.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-GB" link="blue" vlink="purple">
<div>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I have been working in the last few weeks on making LLDB working with gdbserver on Linux host. Some of the things that I noted missing are.<u></u><u></u></span></p>




<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p><u></u><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span>1.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">     
</span></span></span><u></u><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Run length encoding as already mentioned. I have a patch for it that I will submit shortly.<u></u><u></u></span></p>




<p><u></u><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span>2.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">     
</span></span></span><u></u><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I had to hardcode the registers for x86_64 as gdbserver does not support qRegisterInfo.<u></u><u></u></span></p>




<p><u></u><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><span>3.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">     
</span></span></span><u></u><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Make sure to use g/G packets for registers.<u></u><u></u></span></p>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">After that I had a working connection. But then I noticed the following 2 problem.<u></u><u></u></span></p>


<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">PC is not decremented by length of breakpoint instruction after target stops.<u></u><u></u></span></p>


<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">LLDB failing to recognize a breakpoint is for stepping and stopping before a source level step was really complete.<u></u><u></u></span></p>




<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I am working on these 2 issues.<u></u><u></u></span></p>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Regards,<u></u><u></u></span></p>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Abid
<u></u><u></u></span></p>
<p class=""><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div style="border-style:none none none solid;border-left-color:blue;border-left-width:1.5pt;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0cm 0cm">
<p class=""><b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span lang="EN-US" 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>Virgile Bello<br>
<b>Sent:</b> 27 August 2013 02:34<br>
<b>To:</b> Sebastien Metrot<br>
<b>Cc:</b> lldb-dev<br>
<b>Subject:</b> Re: [lldb-dev] gdb-remote to android gdbserver<u></u><u></u></span></p>
</div>
</div><div><div>
<p class=""><u></u> <u></u></p>
<div>
<p class="">Yes, I suppose a lldb-only change would be much more easier for now.<u></u><u></u></p>
<div>
<p class=""><u></u> <u></u></p>
</div>
<div>
<p class="">From what I remember when I tested, hard-coding the ARM registers temporarily + the runtime-length encoding patch (that I will commit soon) was enough to to have a simple address breakpoint working.<u></u><u></u></p>




</div>
<div>
<p class="">Backtrace didn't, but I didn't bother investigate further.<u></u><u></u></p>
</div>
</div>
<div>
<p class="" style="margin-bottom:12pt"><u></u> <u></u></p>
<div>
<p class="">On Tue, Aug 27, 2013 at 10:09 AM, Sebastien Metrot <<a href="mailto:meeloo@gmail.com" target="_blank">meeloo@gmail.com</a>> wrote:<u></u><u></u></p>
<p class="">If I understand correctly 1 and 3 implies modifying the android gdbserver while 2 could be done entirely in lldb? Having gdbserver changes accepted by the maintainers and integrated in future builds of android and/or the NDK looks like
 a hard path to walk.<br>
Also I have looked at the gdbserver sources of the current android (found here <a href="https://android.googlesource.com/toolchain/gdb/" target="_blank">
https://android.googlesource.com/toolchain/gdb/</a> ) and a couple of greps seems to indicate that xmlRegisters is only supported on x86 although register definition xmls exists for many arm/linux variants.<br>
In this light 2 seems like a good short term solution to force a register mapping on lldb by reading the xml from the gdb sources, until 1 is finally implemented in both projects and lldb is able to detect the register mapping.<br>




<br>
Is that correct?<br>
<span style="color:rgb(136,136,136)"><br>
<span>S.</span></span><u></u><u></u></p>
<div>
<div>
<p class=""><br>
<br>
On 26 Aug 2013, at 19:34 , Greg Clayton <<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>> wrote:<br>
<br>
> The problem is we don't know the registers. GDB assumes that the GDB that is being used knows what registers are on the other side of the remote connection. New GDB binaries and GDBSERVER binaries are compiled for each target. LLDB has one binary for all
 systems. So LLDB expects to be able to query the GDBSERVER for the register information. LLDB has defined new packets to get this information. We have documented the packets we added:<br>
><br>
> svn cat <a href="http://llvm.org/svn/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt" target="_blank">
http://llvm.org/svn/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt</a><br>
><br>
> I believe there is a way defined in the remote protocol to query for registers using the "qXfer" command with the "xmlRegisters" gdb feature. We haven't added support for this, but the "XML target description" format is missing information we need. The details
 on this are at:<br>
><br>
> <a href="https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format" target="_blank">
https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format</a><br>
><br>
> It could also be easily extended to support giving us the information required.<br>
><br>
> So, in order to get things going you will need to do one of the following:<br>
> 1 - add support for the qRegisterInfo packet (easiest)<br>
> 2 - add a new "settings set" setting for the "gdb-remote" plug-in that contains a path to a register description file. The file format should be something parseable like XML and you would need to write a parser for it and parse the contents by adding a method
 to the  GDBRemoteDynamicRegisterInfo class (harder)<br>
> 3 - If the current gdbserver for android does support the "XML target description", we would need to modify the GDBRemoteCommunicationClient class to be able to retrieve the information and parse the XML. You would then need to modify the gdbserver for android
 to add extra data we need to the register info (compiler register numbers for each register if one exists, DWARF register numbers, generic register info) (hardest)<br>
><br>
> I think option 1 or 2 would be the easiest.<br>
><br>
> Greg<br>
><br>
> On Aug 25, 2013, at 10:53 AM, Sebastien Metrot <<a href="mailto:meeloo@gmail.com" target="_blank">meeloo@gmail.com</a>> wrote:<br>
><br>
>> Hi,<br>
>><br>
>> I have started to investigate connecting lldb to gdbserver running on an android device (arm). It connects correctly, I'm able to start the remote program and interrupt it but lldb doesn't permit me to access any data as it says the current frame is invalid:<br>




>><br>
>> mbp:NativeTest meeloo$ lldb ../../../ndk/samples/hello-gl2/libs/armeabi/libgl2jni.so<br>
>> Current executable set to '../../../ndk/samples/hello-gl2/libs/armeabi/libgl2jni.so' (arm).<br>
>> (lldb) gdb-remote<br>
>> error: gdb-remote [<hostname>:]<portnum><br>
>> (lldb) gdb-remote <a href="http://127.0.0.1:5039" target="_blank">127.0.0.1:5039</a><br>
>> Process 12260 stopped<br>
>> * thread #1: tid = 0x2fe4, , stop reason = signal SIGTRAP<br>
>>    frame #0:<br>
>> (lldb) frame variable<br>
>> error: invalid frame<br>
>> (lldb) continue<br>
>> Process 12260 resuming<br>
>> ---- Here I hit Ctrl+C<br>
>> Process 12260 stopped<br>
>> * thread #1: tid = 0x2fe4, , stop reason = signal SIGINT<br>
>>    frame #0:<br>
>> (lldb) continue<br>
>> Process 12260 resuming<br>
>> (lldb) process interrupt<br>
>> Process 12260 stopped<br>
>> * thread #1: tid = 0x2fe4, , stop reason = signal SIGINT<br>
>>    frame #0:<br>
>> (lldb) register read<br>
>> error: invalid frame<br>
>> (lldb) process status<br>
>> Process 12260 stopped<br>
>> * thread #1: tid = 0x2fe4, , stop reason = signal SIGINT<br>
>>    frame #0:<br>
>><br>
>><br>
>> Does anyone have already tried to do this kind of things? I'm trying to get it to work before moving to implementing android support in my program with the C++ API...<br>
>><br>
>> Thanks in advance,<br>
>><br>
>> S.<br>
>><br>
>> _______________________________________________<br>
>> lldb-dev mailing list<br>
>> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
<br>
<br>
_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><u></u><u></u></p>
</div>
</div>
</div>
<p class=""><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div></div>