首先,我英语说得不太好。请原谅我。 我想检查gdb中musl的源代码。 这就是我所做的。
安装 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
告诉 musl-gcc 在构建程序时使用这些:
$ musl-gcc -g3 -static -Lmusl/lib test.c
享受甜蜜的成功:
Temporary breakpoint 1 at 0x40113d: file test.c, line 4.
Starting program: /home/allan/1/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);