<div dir="ltr">Thanks, Abid!<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 27, 2013 at 4:00 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Todd,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">You can try reading the registers using ‘register read’ command after connecting with the gdbserver. If LLDB shows the register then you will know that it has
parsed the file ok. Otherwise the quickest way to find the problem will be to debug LLDB. The python target definition is parsed in ProcessGDBRemote::ParsePythonTargetDefinition().<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u></span></p></div></div></blockquote><div><br></div><div>Excellent, thanks. I'll step through that and see if there's some kind of logging there.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">On x86_64 linux, I use the following command to connect to gdbserver.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">(lldb) file ~/demos/act<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Current executable set to '~/demos/act' (x86_64).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">(lldb) settings set plugin.process.gdb-remote.target-definition-file /home/abidh/work/llvm/src/tools/lldb/examples/python/x86_64_linux_target_definition.py<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">(lldb) gdb-remote 10000<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> </span></p></div></div></blockquote><div><br></div><div>Great, thanks for passing along your steps. This will help if I compare and contrast against what I'm doing on ARM when I debug it.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I also noted that you have retained the following line from x86_64 file. You may want to update it for ARM.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">g_target_definition['breakpoint-pc-offset'] = -1<u></u><u></u></span></p><div class="im">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> </span></p></div></div></div></blockquote><div><br></div><div>Thanks, I wasn't sure exactly which context needed this.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><div class="im"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u></span></p>
<p class="MsoNormal">Are the target and file commands needed with the architecture file?<u></u><u></u></p>
</div><p class="MsoNormal"><span style="color:#4f81bd">The python target definition file is not a substitute for target or file command. I also wonder what happens when you don’t supply arch in the ‘target create’ command. What arch LLDB finds out from the executable
file?<u></u><u></u></span></p><div class="im">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u></span></p></div></div></div></blockquote><div><br></div><div>I will see what it does when I don't specify the arch for the file.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><div class="im"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> <u></u></span></p>
<p class="MsoNormal">* Is it the mere fact that I'm attaching remotely good enough for lldb to be using the architecture definition specified with "settings set plugin.process.gdb-remote.target-definition-file ...", or is it keying off of some of the meta data
it has (like me specifying the "target create" and "file --arch" commands)?<u></u><u></u></p>
</div><p class="MsoNormal"><span style="color:#4f81bd">If your target did not supply qRegisterInfo packet (which I think it did not) then LLDB will end up parsing your target definition file.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#4f81bd"><u></u> </span></p></div></div></blockquote><div><br></div><div>Right - I'm using the stock Android gdbserver. I'll need to check exactly what's in there, but my first guess would be that there are no lldb extensions added to it since our NDK only supports gdb at this time.</div>
<div><br></div><div>I'll be debugging through this today so hopefully I'll have something to report soon.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;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> 26 November 2013 23:58<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] Using file-defined registers on Android<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi all,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I'm attempting to follow the platform definition approach that Greg laid out when attempting to attach to a gdbserver running on an Android device. In particular, Android arm v7a devices (Nexus 10 and Nexus 7).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I went ahead and created a python register definition. I generated the definition file based on referencing these:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:"Arial","sans-serif"">svn cat </span><a href="http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/x86_64_linux_target_definition.py" target="_blank"><span style="font-size:9.5pt;font-family:"Arial","sans-serif"">http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/x86_64_linux_target_definition.py</span></a><span style="font-size:9.5pt;font-family:"Arial","sans-serif""><br>
svn cat </span><a href="http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/x86_64_target_definition.py" target="_blank"><span style="font-size:9.5pt;font-family:"Arial","sans-serif"">http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/x86_64_target_definition.py</span></a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">and the output from using one of gdb's commands when gdb was attached to the gdbserver:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:"Arial","sans-serif"">(gdb) maint print raw-registers</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Now I'm attempting to do some debugging with lldb.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I created an app, fired it up on the Android, and attempt to attach to the running process. Since I can debug this app fine remotely with gdb, I believe the basic pipe should be okay.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Here's what I do on the lldb side. The Android app to be debugged is running at this point.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">lldb<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"># set the platform file<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">(lldb) settings set plugin.process.gdb-remote.target-definition-file /home/tfiala/work/arm-arch/armv7a_linux_target_definition.py<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"># note I tried to use armv7-pc-linux, which said the file didn't match, and there<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"># doesn't appear to be an armv7a-pc-linux. Should I be using something else here?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">(lldb) target create --arch arm-pc-linux libs/armeabi-v7a/libnative-activity.so<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"># As above, only arm-pc-linux seemed to accept this file. The .so file<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"># is an armv7a-built lib in this case and runs fine on Nexus 7 and 10 devices.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">(lldb) file --arch arm-pc-linux libs/armeabi-v7a/libnative-activity.so<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"># Now ready for the connect: the adb redirector to communicate with<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"># gdbserver is localhost:5039<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">(lldb) gdb-remote 5039<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Here's what I get:<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">(lldb) thread list<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Process 8176 stopped<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">* thread #1: tid = 8176, , stop reason = signal SIGTRAP<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">(lldb) bt<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">* thread #1: tid = 8176, , stop reason = signal SIGTRAP<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> * frame #0: <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The app itself is still running on the Android device - at least the main thread is. So the listing of it as stopped appears to be incorrect. If I do "(lldb) exit", it will kill the main thread fwiw, but not nuke the process. I'm not
particularly concerned with that piece yet as it might be related to the dual-heritage java/native aspect.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I've got the architecture definition file indicating the triple it provides is arm-*-linux (at least, I think). I have no idea if the file is working since I haven't (yet) figured out how to get output from the loading process.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I'm attaching my architecture definition file and the maintenance dump in case anybody sees something obviously wrong.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Some questions:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">* Am I running the right commands in the right order to connect to a gdbserver where I'm specifying the register information explicitly? Are the target and file commands needed with the architecture file?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">* Why is LLDB telling me the armv7a object files are not valid armv7 files?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">* Is the "pc" part of the arm-pc-linux part right, wrong, or a don't care for my scenario?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">* Is it the mere fact that I'm attaching remotely good enough for lldb to be using the architecture definition specified with "settings set plugin.process.gdb-remote.target-definition-file ...", or is it keying off of some of the meta data
it has (like me specifying the "target create" and "file --arch" commands)?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">* How do I debug python loaded via lldb or get feedback from the lldb python support (e.g. if there's a syntax error or something else goofy) when running lldb?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I assume I have something really basic wrong at this point since the arch definition file specified seems to make no difference on the output vs. what I see when I attach with lldb without specifying the architecture file.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks for any suggestions and for helping fill in my understanding!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Sincerely,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Todd Fiala<u></u><u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>
</blockquote></div><br></div></div>