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
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 <aruna.hewapathirane@gmail.com> 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@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Saket, Thank you so much for the clear instructions. I really wanted to get qemu to work on my 64bit system so I kept trying and finally I got things to work. After following your instructions I could get further but gdb complained about a "Remote 'g' packet reply is too long".Your way works fine but I needed to debug a kernel module so what finally worked for me is this. I am enclosing the steps it may help others some day: After Googling into the late hours of the morning I saw someone else had similar issues and he resolved this way: http://lists.gnu.org/archive/html/qemu-discuss/2014-10/msg00069.html I am using GNU gdb (GDB) 7.9 the file is remote.c and I commented out lines: /* Further sanity checks, with knowledge of the architecture. */ 6157 //if (buf_len > 2 * rsa->sizeof_g_packet) 6158 // error (_("Remote 'g' packet reply is too long: %s"), rs->buf); make then make install gdm, then proceed as usual but you need to specify the -initrd else cannot debug kernel modules. You can still step into the kernel no issues there but modules nope. qemu-system-x86_64 -s -S -kernel arch/x86/boot/bzImage -initrd /boot/initrd.img-4.1.2-vtaqemu+ /dev/zero xvnc4viewer :5900 ( Your port # may differ.. ) gdb vmlinux target remote localhost:1234 (gdb) add-symbol-file /home/aruna/kmod/misc.ko 0xffffffffa057e000 -s .data 0xffffffffa0580000 -s .bss 0xffffffffa05802c8 ----------gdb output--------------------------------------------------------------------------------- add symbol table from file "/home/aruna/kmod/misc.ko" at .text_addr = 0xffffffffa057e000 .data_addr = 0xffffffffa0580000 .bss_addr = 0xffffffffa05802c8 (y or n) y Reading symbols from /home/aruna/kmod/misc.ko...done. (gdb) b hello_write ...and it triggers when I echo "testing123" > /dev/aruna Breakpoint 2 at 0xffffffffa057e050: file /home/aruna/kmod/misc.c, line 29. ----end--gdb output--------------------------------------------------------------------------------- Thank you very much for your help I am extremely grateful, without your guidance I would have not figured things out :) Aruna
participants (2)
-
Aruna Hewapathirane -
Saket Sinha