系統4.4.4 手機n4
zygote本來是app_system程序但是裏面 也有java的部分,上次用as沒用成功調試他,這次用gdb調試。
進入手機直接用adbserver 附加。手機默認seliunx開啓,需要輸入 setenforce 0
130|shell@mako:/ # reboot
haidragon@ubuntu:~$ adb devices
List of devices attached
047e3631ce95b902 device
haidragon@ubuntu:~$ adb shell
shell@mako:/ $ su
shell@mako:/ # ps | grep zygote
root 174 1 860932 42196 ffffffff 400c26d8 S zygote
shell@mako:/ # setenforce 1
shell@mako:/ # gdbserver :9999 --attach 174
Attached; pid = 174
waitpid: Permission denied.
Exiting
1|shell@mako:/ # setenforce 0
shell@mako:/ # gdbserver :9999 --attach 174
Attached; pid = 174
先端口轉發 adb forward tcp:9999 tcp:9999
linux上找到 arm-linux版的gdb必須用要arm-linux的arm-linux-androideabi-gdb(網上都是在ndk裏面找的我這邊就它沒有 其它全有,同時我這有倆個版只有4.7的能行 )
運行
'/home/haidragon/Desktop/android/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gdb'
加載二進制文件,加載符號根路徑,加載源碼根路徑
haidragon@ubuntu:~/Desktop/android$ '/home/haidragon/Desktop/android/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gdb'
GNU gdb (GDB) 7.6
Copyright (C) 2013 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>.
(gdb) file '/home/haidragon/Desktop/android/out/target/product/mako/symbols/system/bin/app_process'
Reading symbols from /home/haidragon/Desktop/android/out/target/product/mako/symbols/system/bin/app_process...done.
(gdb) set sysroot '/home/haidragon/Desktop/android/out/target/product/mako/symbols'
(gdb) set dir '/home/haidragon/Desktop/android'
(gdb) list
130 /*
131 * sets argv0 to as much of newArgv0 as will fit
132 */
133 static void setArgv0(const char *argv0, const char *newArgv0)
134 {
135 strlcpy(const_cast<char *>(argv0), newArgv0, strlen(argv0));
136 }
137
138 int main(int argc, char* const argv[])
139 {
(gdb)
可以選擇進入gdb tui界面按 ctrl-x a
然後連接服務端 target remote:9999
調試c層就是這麼調試的,gdb怎麼使用的其它可以自己研究。