[lldb-dev] Using file-defined registers on Android

Todd Fiala tfiala at google.com
Tue Nov 26 15:57:43 PST 2013


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/20131126/46442036/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: armv7a_linux_target_definition.py
Type: text/x-python-script
Size: 18331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20131126/46442036/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb-reg-output-armv7a.out
Type: application/octet-stream
Size: 9113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20131126/46442036/attachment.obj>


More information about the lldb-dev mailing list