Debugging a custom kernel

Christopher Harvey chris at basementcode.com
Wed Jun 29 12:41:34 EDT 2011


On 06/29/11 16:14, Apelete Seketeli wrote:
> Hello,
>
> I am working on a custom kernel, and I would like to add the necessary
> support to enable it to boot with qemu.
When you say "debug inside qemu", do you run
gdb qemu
or
gdb vmlinux
> In order to achieve that I am
> trying to debug it inside qemu by attaching a gdb to it.
you do this by adding -S -s to the qemu boot parameters.
the from the gdb shell, target remote :1234.
 > I still can't
> figure where the boot process is getting stuck with step-by-step
> execution, but it seems that the last function called is "delay_loop"
> from arch/x86/lib/delay.c.
Have you run the backtrace (bt) command from the gdb shell? That should 
tell you what function is calling the __delay.
> That function contains some assembly code, does someone know what it
> is supposed to do ?
Probably wait a specific amount of time. Since a compiler optimizes C 
you can't write an accurate delay in C. The compiler wont optimize the 
inline assembly.
> Beside, do you have any advice on the way I should proceed to get the
> necessary information to port the kernel ?
You should find an existing board and tweak it to get started, or post 
the backtrace output.
>
> Thanks.

Have you had any luck with a google search along the lines of "qemu gdb 
kernel"?



More information about the Kernelnewbies mailing list