Software: Official TI android release (source code package), Jelly bean 4.2.2 for AM335x
Hardware: am335xevm_sk
What I do:
1. build the system and using sd card to boot the hardware. Everything works properly.
2. adb pull the init.am335xevm.rc file, comment out the rild service and push it back, reboot the target system. I do this because I want to use cross debugger to remote debug rild.
3. set up the remote debug: adb forward tcp ports. and launch gdbserver on target system, as:
root@android:/ # gdbserver localhost:2345 system/bin/rild
Process system/bin/rild created; pid = 829
Listening on port 2345
Remote debugging from host 127.0.0.1
4. remote debug rild, as:
ma@ma-aspire:~/devkit/JB422$ PATH=$PATH:/home/ma/devkit/JB422/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin
ma@ma-aspire:~/devkit/JB422$ arm-linux-androideabi-gdb
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-android".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file /home/ma/devkit/JB422/out/target/product/am335xevm_sk/symbols/system/bin/rild
Reading symbols from /home/ma/devkit/JB422/out/target/product/am335xevm_sk/symbols/system/bin/rild...done.
(gdb) set sysroot /home/ma/devkit/JB422/out/target/product/am335xevm_sk/symbols
(gdb) target remote localhost:2345
Remote debugging using localhost:2345
__dl__start () at bionic/linker/arch/arm/begin.S:35
35 mov r0, sp
(gdb) n
36 mov r1, #0
(gdb) n
37 bl __linker_init
(gdb) n
Program received signal SIGILL, Illegal instruction.
0x4013a89e in __linker_init (elfdata=0xbee7bae0) at bionic/linker/linker.cpp:2030
2030 extern "C" unsigned __linker_init(unsigned **elfdata) {
(gdb) c
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am not very familiar with low-level toolchain problem. I googled the problem and it seems very few people encountered the same problem.
I downloaded the aosp source (Android 4.2.2_r1, JDQ39) and compared the prebuilt toolchain and NDK content, no significant difference was found.
I also tried with the latest NDK (r10b). Use the prebuilt toolchain in the NDK to rebuild the whole target system and do the debug, the results are the same.
I also tried to generate the standalone toolchain with platform set to android-17 and android-18, and repeat the above steps, the results are the same.
I also tried to re-built the NDK toolchain and got no difference.
I also tried the newer version of gdbserver (prebuilts in NDK r10b package), and the problem persists.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
but if I use the NDK toolchain to debug a simple hello-world program (with liblog dynamically linked), as proposed in this page:
http://www.srombauts.fr/2011/03/06/standalone-toolchain/
and do the debug, I can step into main(), but after the program exit, the process on target system got a similar SIGILL termination, instead of a normal exit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am very confused why this occurs, since many many developers use gdb to debug native code and platform developers at google should also rely on gdb debug heavily. It seems unlikely that the problem arised from a bug in gdb or gdbserver. Perhaps it is related and specific to am335x kernel? Or I missed something important to use gdb? say, target architecture options? Or certain compiler options should be specified for this kind of native debug? I had read quite a few online articles on native remote debug on android carefully and not found anything specifically being pointed out.
I really want to use remote GDB to debug some native program, including ril and some other test cases wrapping HAL libs. Please HELP!