[lldb-dev] Using file-defined registers on Android
Abid, Hafiz
Hafiz_Abid at mentor.com
Wed Nov 27 04:00:18 PST 2013
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().
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
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
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?
* 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.
Regards,
Abid
Regards,
Abid
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/7015320b/attachment.html>
More information about the lldb-dev
mailing list