基本上,我要做的是使用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,那么产生的内核映像将包括调试信息,从而产生一个更大的内核映像。如果您计划使用gdb调试内核,请在这里说Y。如果你不调试内核,你可以说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) 提前感谢
发布于 2016-01-19 18:15:28
这是一个误解:这个选项仅仅是在使用gdb打开kernel-imagefile时获得更好的信息:
gdb vmlinux请注意,这仅适用于ELF-映像(不用于引导后处理)。
它与调试进程无关,也与linux内核的实时调试无关。
https://stackoverflow.com/questions/34883916
复制相似问题