[lldb-dev] Using file-defined registers on Android
Todd Fiala
tfiala at google.com
Wed Nov 27 07:28:23 PST 2013
Thanks, Abid!
On Wed, Nov 27, 2013 at 4:00 AM, Abid, Hafiz <Hafiz_Abid at mentor.com> wrote:
> Hi Todd,
>
> 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().
>
>
Excellent, thanks. I'll step through that and see if there's some kind of
logging there.
>
>
> On x86_64 linux, I use the following command to connect to gdbserver.
>
> (lldb) file ~/demos/act
>
> Current executable set to '~/demos/act' (x86_64).
>
> (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
>
> (lldb) gdb-remote 10000
>
>
>
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.
> I also noted that you have retained the following line from x86_64 file.
> You may want to update it for ARM.
>
> g_target_definition['breakpoint-pc-offset'] = -1
>
>
>
Thanks, I wasn't sure exactly which context needed this.
> Are the target and file commands needed with the architecture file?
>
> 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?
>
>
I will see what it does when I don't specify the arch for the file.
>
>
> * 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)?
>
> If your target did not supply qRegisterInfo packet (which I think it did
> not) then LLDB will end up parsing your target definition file.
>
>
>
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.
I'll be debugging through this today so hopefully I'll have something to
report soon.
>
>
> *From:* lldb-dev-bounces at cs.uiuc.edu [mailto:lldb-dev-bounces at cs.uiuc.edu]
> *On Behalf Of *Todd Fiala
> *Sent:* 26 November 2013 23:58
> *To:* lldb-dev at cs.uiuc.edu
> *Subject:* [lldb-dev] Using file-defined registers on Android
>
>
>
> Hi all,
>
>
>
> 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).
>
>
>
> I went ahead and created a python register definition. I generated the
> definition file based on referencing these:
>
>
>
> svn cat
> http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/x86_64_linux_target_definition.py
> svn cat
> http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/x86_64_target_definition.py
>
>
>
> and the output from using one of gdb's commands when gdb was attached to
> the gdbserver:
>
>
>
> (gdb) maint print raw-registers
>
>
>
>
>
> Now I'm attempting to do some debugging with lldb.
>
>
>
> 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.
>
>
>
> Here's what I do on the lldb side. The Android app to be debugged is
> running at this point.
>
>
>
> lldb
>
>
>
> # set the platform file
>
> (lldb) settings set plugin.process.gdb-remote.target-definition-file
> /home/tfiala/work/arm-arch/armv7a_linux_target_definition.py
>
>
>
> # note I tried to use armv7-pc-linux, which said the file didn't match,
> and there
>
> # doesn't appear to be an armv7a-pc-linux. Should I be using something
> else here?
>
> (lldb) target create --arch arm-pc-linux
> libs/armeabi-v7a/libnative-activity.so
>
>
>
> # As above, only arm-pc-linux seemed to accept this file. The .so file
>
> # is an armv7a-built lib in this case and runs fine on Nexus 7 and 10
> devices.
>
> (lldb) file --arch arm-pc-linux libs/armeabi-v7a/libnative-activity.so
>
>
>
> # Now ready for the connect: the adb redirector to communicate with
>
> # gdbserver is localhost:5039
>
> (lldb) gdb-remote 5039
>
>
>
>
>
> Here's what I get:
>
> (lldb) thread list
>
> Process 8176 stopped
>
> * thread #1: tid = 8176, , stop reason = signal SIGTRAP
>
> (lldb) bt
>
> * thread #1: tid = 8176, , stop reason = signal SIGTRAP
>
> * frame #0:
>
>
>
> 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.
>
>
>
> 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.
>
>
>
> I'm attaching my architecture definition file and the maintenance dump in
> case anybody sees something obviously wrong.
>
>
>
> Some questions:
>
>
>
> * 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?
>
>
>
> * Why is LLDB telling me the armv7a object files are not valid armv7 files?
>
>
>
> * Is the "pc" part of the arm-pc-linux part right, wrong, or a don't care
> for my scenario?
>
>
>
> * 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)?
>
>
>
> * 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?
>
>
>
> 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.
>
>
>
> Thanks for any suggestions and for helping fill in my understanding!
>
>
>
> Sincerely,
>
> Todd Fiala
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20131127/e0d68746/attachment.html>
More information about the lldb-dev
mailing list