Thread (3 messages) 3 messages, 2 authors, 2015-08-16

Kernel Debugging using Qemu

From: Saket Sinha <hidden>
Date: 2015-08-15 04:40:53

Hi Aruna,

Please find the steps below -


The kernel needs to be compiled with debugging support, for the same
add -g option in KBUILD_CFLAGS and KBUILD_CXXFLAGS.
CONFIG_DEBUG_INFO=y

make ARCH=i386 menuconfig
make ARCH=i386 bzImage -j 5
Now we have compiled the 32 bit binaries


Starting the qemu with the kernel image
qemu -s -S  -kernel arch/x86/boot/bzImage -append "console=ttyS0"
-serial mon:stdio -nographic
OR
qemu -s -S -smp 1,cores=1  -hda /dev/zero -kernel arch/x86/boot/bzImage


Debugging using plane gdb
$gdb vmlinux
(gdb) target remote localhost:1234
(gdb) b start_kernel
(gdb) c



Regards,
Saket Sinha


On Sat, Aug 15, 2015 at 7:47 AM, Aruna Hewapathirane
[off-list ref] wrote:
Hi,

If anyone uses Qemu can someone please show me how to get started ?

I tried :

sudo qemu-system-x86_64 -s -S -kernel arch/x86/boot/bzImage -initrd
/boot/initrd.img-4.1.2-vtaqemu+ /dev/zero

And it does allow me to access through gdb using target remote
localhost:1234 but when I set a breakpoint in kernel_start and
continue it hangs and tells me /bin/sh: can't access tty; job control
turned off ?

I am runing a Debian 4.1.2 custom kernel. I have enabled Intel
virtulization in the bios. And menuconfig have setup virtualization.

After many tries have finally managed to get this far but now I can
use all the help I can get.

And and all suggestions, guidance, *pointers are most welcome.

Thanks - Aruna

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help