我基本上想要做的是使用gdb逐行进入内核源代码。
这是我得到的代码:
int main(void)
{
int childPID;
childPID = fork();
return 0;
}
当我使用gcc -g编译一些东西时,当我在gdb中逐步跟踪程序时,我得到了有意义的输出。我已经检查了我的linux安装配置文件(\ boot \ config-3.19.0-15-generic),并且config_debug_info已打开:
CONFIG_DEBUG_INFO=y
基于帮助文字:
如果你在这里说Y,结果内核映像将包含调试 信息导致更大的内核映像。只有你计划时才在这里说Y. 使用gdb来调试内核。如果你不调试内核,你可以 说N。
我不明白的是,当我使用gdb进行跟踪时,我怎么能得到任何有意义的输出?
这是我得到的一些输出:
Breakpoint 1, main () at ftest.c:7
7 childPID = fork();
(gdb) s
__libc_fork () at ../sysdeps/nptl/fork.c:59
59 ../sysdeps/nptl/fork.c: No such file or directory.
(gdb) s
54 in ../sysdeps/nptl/fork.c
(gdb) s
111 in ../sysdeps/nptl/fork.c
(gdb) s
__GI__IO_list_lock () at genops.c:1300
1300 genops.c: No such file or directory.
(gdb) s
__x86.get_pc_thunk.bx () at ../sysdeps/i386/i686/multiarch/strcat.S:55
55 ../sysdeps/i386/i686/multiarch/strcat.S: No such file or directory.
(gdb) s
__GI__IO_list_lock () at genops.c:1302
1302 genops.c: No such file or directory.
(gdb) s
1304 in genops.c
(gdb) s
__libc_fork () at ../sysdeps/nptl/fork.c:114
114 ../sysdeps/nptl/fork.c: No such file or directory.
(gdb) s
120 in ../sysdeps/nptl/fork.c
(gdb) s
121 in ../sysdeps/nptl/fork.c
(gdb) s
124 in ../sysdeps/nptl/fork.c
(gdb) s
131 in ../sysdeps/nptl/fork.c
(gdb) s
124 in ../sysdeps/nptl/fork.c
(gdb) s
131 in ../sysdeps/nptl/fork.c
(gdb) s
206 in ../sysdeps/nptl/fork.c
(gdb) s
209 in ../sysdeps/nptl/fork.c
(gdb) s
212 in ../sysdeps/nptl/fork.c
(gdb) s
__GI__IO_list_unlock () at genops.c:1309
1309 genops.c: No such file or directory.
(gdb) s
__x86.get_pc_thunk.cx () at ../sysdeps/unix/syscall-template.S:83
83 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) s
__GI__IO_list_unlock () at genops.c:1311
1311 genops.c: No such file or directory.
(gdb) s
__libc_fork () at ../sysdeps/nptl/fork.c:215
215 ../sysdeps/nptl/fork.c: No such file or directory.
(gdb) s
229 in ../sysdeps/nptl/fork.c
(gdb) s
main () at ftest.c:8
8 childPID = childPID+ 1;
(gdb) s
10 return 0;
(gdb) Quit
(gdb)
提前致谢
答案 0 :(得分:3)
这是一个误解:该选项仅用于在使用gdb打开 kernel-imagefile 时获取更好的信息:
gdb vmlinux
请注意,这仅适用于(不适用于启动后处理的)ELF图像。
它与调试进程无关,也没有与linux内核的实时调试
相关