作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我用以下代码编译了 goldfish 内核:
[ ] Optimize for size,
[*] Kernel hacking
[*] Compile the kernel with debug info
[*] KGDB: kernel debugging with remote gdb —>
[*] Enable dynamic printk() call support
我用编译后的内核启动了 AVD。
emulator -kernel goldfish/arch/arm/boot/zImage -avd TestAVD
我将一个已编译的 c 程序推送到 AVD 上。
然后我下载了库(我不确定这是否是正确的方法)
adb pull /system/lib ./debuginfo/lib
adb pull /system/bin/linker ./debuginfo/lib
运行 gdbserver:
gdbserver 127.0.0.1:7777 ./a
转发端口:
adb forward tcp:7777 tcp:7777
运行 gdb
gdb-multiarch ./a
指定搜索目录:
set solib-search-path ./debuginfo/lib
连接到设备
target remote :7777
例如,我在收盘时突破。
0xaf0ae228 in close () from /home/wuyihao/android_sec/debuginfo/lib/libc.so
1: x/i $pc
=> 0xaf0ae228 <close+8>: svc 0x00000000
(gdb) list
No symbol table is loaded. Use the "file" command.
我无法得到来源。所以我尝试用变量 CFLAG="-g"
重新编译内核没什么不同。
谢谢!
ps:我注意到下载的库都被剥离了。
最佳答案
libc.so 不是 Linux 内核。它是 C 标准库。
您不太可能需要在那里寻找问题。如果您的 close() 调用不起作用,几乎可以肯定是您在使用它时出现了问题,而不是它的实现。
关于c - 如何将 Android native 代码调试到内核中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38346571/
我是一名优秀的程序员,十分优秀!