Android : ndk-gdb and ndk-gdb.py Errors

on Wednesday, July 23, 2014


I want to use ndk-gdb to debug my native code on Android application. My ndk version is r9d, and my OS is Ubuntu 12.04 64-bit.


I use HelloJni to my test project. After compiling (ndk-build NDK_DEBUG=1), I try to use ndk-gdb to debug this project. But there are errors.



WARNING: The shell running this script isn't bash. Although we try to avoid bashism inscripts, things can happen.
/home/jargo/ndk/android-ndk-r9d/ndk-gdb: 143: /home/jargo/ndk/android-ndk-r9d/ndk-gdb: Bad substitution
/home/jargo/ndk/android-ndk-r9d/ndk-gdb: 555: [: 1: unexpected operator
/home/jargo/ndk/android-ndk-r9d/ndk-gdb: 771: [: armeabi: unexpected operator
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://source.android.com/source/report-bugs.html>.
./obj/local/armeabi/gdb.setup:4: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer.
(gdb) l
No symbol table is loaded. Use the "file" command.


It seems the error is in its script, and can't load symbol table. I found this link, it says use ndk-gdb.py - the python version of ndk-gdb. The errors show following, seems the connection failed.



Cannot attach to lwp 31720: Operation not permitted (1)

Exiting
97 KB/s (9564 bytes in 0.095s)
367 KB/s (63176 bytes in 0.167s)
470 KB/s (301636 bytes in 0.625s)
JDB :: java.io.IOException: handshake failed - connection prematurally closed
JDB :: at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:136)
JDB :: at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:232)
JDB :: at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
JDB :: at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90)
JDB :: at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519)
JDB :: at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328)
JDB :: at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
JDB :: at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1066)
JDB ::
JDB :: Fatal error:
JDB :: Unable to attach to target VM.
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://source.android.com/source/report-bugs.html>.
./obj/local/armeabi/gdb.setup:4: Error in sourced command file:
Remote communication error. Target disconnected.: connection reset by peerenter code here.
(gdb)


Have any one know what's the problem?


0 comments:

Post a Comment