gpt4 book ai didi

c - 如何将 Android native 代码调试到内核中?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:44:51 25 4
gpt4 key购买 nike

我用以下代码编译了 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com