Kernel Debugging using Qemu
Aruna Hewapathirane
aruna.hewapathirane at gmail.com
Sun Aug 16 00:19:25 EDT 2015
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150816/4531e9b6/attachment.html
More information about the Kernelnewbies
mailing list