I am trying to remotely debug Linux Kernel and I am having issues.
- Target machine with Ubnutu Linux with my custom kernel 4.3 which I built with debugging information and KGDB.
- Development machine with Windows and Cygwin on it.
I connected the machines with Serial port on the Linux side and USB on the Development machine side. On target machine: I loaded my module X with insmod,
>cat /sys/module/X/sections/.text 0xffffffffc046e000 >cat /sys/module/X/sections/.bss 0xffffffffc04708c0 >cat /sys/module/X/sections/.data 0xffffffffc0470000
I read that I'm supposed to start kernel with "some parameters" but I don't really understand how to do it in Ubuntu so I did this:
>echo "ttyS0,115200 > /sys/module/kgdboc/parameters/kgdboc
Also tried just this:
echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc
>echo g > /proc/sysrq-trigger
At this point the Linux machine froze, which is good. (waiting for gdb) On the Windows machine I opened cygwin, I put the vmlinux and X.o files in the root directory, as well as the source code in the right place. Then I ran
gdb ./vmlinux - b 115200 (gdb) add-symbol-file byt_adsp21479.o 0xffffffffc046e000 -s .bss 0xffffffffc04708c0 -s .data 0xffffffffc0470000 (gdb) set architecture i386:x86-64:intel
Then I set some break points in my kernel module and ran
(gdb) target remote /dev/ttyS7 which is COM8
that worked and after typing
The linux machine unfroze, However when I ran an operation on my Linux machine that should trigger a break point, I got this message on the Development machine:
[New Thread 3264] Ignoring packet error, continuing... Remote 'g' packet reply is too long: 0840000000000000000e00080847c0ffffffff000100c0000000000300000000000000bc3b63360088ffff0000000000000000a03b63360088ffff983b63360088ffff000063360088ffff2f944e2fbd3b000020c00a360088ffff000000000000000000000000000000000300000000000000000000000000000000ccd7ceff7f0000ede146c0ffffffff4602000010000000180000000000000000000000
The weirdest is that once, I was able to step into 2 functions but then I got the same error message. What can be the issues?
Just FYI I already throught of abandoning debugging through serial port, and trying through ethernet, So I went here http://sysprogs.com/VisualKernel/kgdboe/tutorial/ And downloaded and built kgboe, but when I tried to run insmod kgdboe.ko I got an error:
insmod: Error: could not insert module kgdboe.ko : Unknown symbol module
and when I run dmesg I see
kgdboe: Unknown symbol set_memory_rw (err 0)
With the setup I have, can anyone please help me find a way to debug my kernel module please. Thank you!