I am trying to remotely debug Linux Kernel and I am having issues.

My setup:

  • 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
>cat /sys/module/X/sections/.bss
>cat /sys/module/X/sections/.data

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

And then

>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

(gdb) continue

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!

  • Debugging kernel from windows? Get a second Linux instead. – user140866 Dec 24 '15 at 5:08
  • Can you please explain how do you deduct from the error message that the problem is Windows? I am using Cygwin on Windows. And the guys that SysProgs that created VisualKernel for Visual Studio are also using Windows. – Michael P Dec 25 '15 at 7:27
  • Judging by address lengths and set architecture command, I see you're debugging a x86_64 kernel. Just a first thought - Windows use LLP64 and Linux use LP64. – user140866 Dec 25 '15 at 11:12
  • That's interesting. I will try on my Mac ( I don't have another Linux machine unfortunately) – Michael P Dec 26 '15 at 4:27
  • If you have a decent CPU with enough RAM and CPU has virtualization assistance, you can install second Linux into a VM such as VirtualBox and try from there. – user140866 Dec 26 '15 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.