1. adb root
手机需要rooted,并且开发者选项中设置adb可以获得root权限;
root access is disabled by system setting - enable in settings -> development options
2. ndk-build 设置
ndk-build NDK_DEBUG=1
V=1
Android.mk : LOCAL_CFLAGS := -g
(there should be gdb.setup gdbserver files under the libs/armeabi after ndk-build)..
3. adb shell
su
#am start -n com.xxx.xxx/.MainActivity
#ps |grep -i xxx
#gdbserver :5039 --attach your_process_id
4.
$adb forward tcp:5039 tcp:5039
$/Users/xxx/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-gdb
5.
(from the libs/armeabi/gdb.setup file, get the following path)
(gdb)set solib-search-path /Users/xxxx/obj/local/armeabi-v7a
(gdb)directory /path/to/your/project's all source/directory
(gdb)target remote :5039
(gdb) bt full
(gdb) set logging on
references:
1. http://www.bobbog.com/archives/24
2. http://wiki.debian.org/HowToGetABacktrace
3. http://www.kandroid.org/online-pdk/guide/debugging_gdb.html