首先,我的英语说得不太好。请原谅我。 我想检查gdb中musl的源代码。 这就是我所做的。
apt 安装 musl-tools
git://git.musl-libc.org/musl ,我已经放到了~
设置gdb的路径,下面是我的'/~/.gdbinit'中的内容:
layout src directory ~/musl/src
我创建一个 C 程序:
#include <stdio.h> int main(){ printf("hello\n"); return 0; }
我用“musl-gcc -O1 -g3 -static test.c”编译它
然后我用 gdb 运行它。但是当我使用 's' 尝试进入 printf 的源代码时,它只是跳过它。
我尝试询问chatgpt,但仍然无法解决。 谁能告诉我为什么会发生这种情况以及我该如何解决它。
最佳答案
使用调试符号构建 musl:
$ (cd musl; configure --enable-debug; make)
使用调试符号针对库构建程序:
$ musl-gcc -g3 -static -Lmusl/lib test.c
享受甜蜜的成功:
$ gdb ./a.out (gdb) start Temporary breakpoint 1 at 0x40113d: file test.c, line 4. Starting program: /home/allan/a.out Temporary breakpoint 1, main () at test.c:4 4 printf("hello\n"); (gdb) s puts (s=0x402000 "hello") at src/stdio/puts.c:6 6 FLOCK(stdout);
关于c - 如何在gdb中查看musl的源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77673440/