Re: Kernel Debugging using Qemu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux