1
votes

What I'm basically trying to do is to step into the kernel source code line by line using gdb.

This is the code I've got:

int main(void)
{
    int childPID;
    childPID = fork();
    return 0;
}

when I compile something using gcc -g I get meaningful output when I trace the program step by step in gdb. I've checked the configuration file of my linux install (\boot\config-3.19.0-15-generic) and the config_debug_info is on:

CONFIG_DEBUG_INFO=y

based on the help text:

If you say Y here the resulting kernel image will include debugging info resulting in a larger kernel image. Say Y here only if you plan to use gdb to debug the kernel. If you don't debug the kernel, you can say N.

What I don't understand is how come when I trace using gdb I don't get any meaningful output?

here is some of the output I'm getting:

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) 

Thanks in advance

1
You might be able to step into the kernel with a debugger, but some architectures don't offer the necessary hardware support to be able to single step or set breakpoints. Being able to see the source is much easier (yum install kernel-debuginfo-<release>). - wallyk

1 Answers

3
votes

This is a misunderstanding: The option is solely to get better information when opening the kernel-imagefile with gdb:

gdb vmlinux

Note that this works only with the (not for booting postprocessed) ELF-image.

It has nothing to do with debugging processes, neither with live-debugging the linux kernel