0
votes

How to debug a custom Linux Kernel on a remote machine?

I have a remote machine with a custom-built Linux Kernel originally from 5.6.8. The system under the kernel is running into problems which I want to fix. The kgdb-related options are

CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
# CONFIG_KGDB_TESTS is not set
CONFIG_KGDB_LOW_LEVEL_TRAP=y
CONFIG_KGDB_KDB=y

The kgdboc module is compiled builtin. The documentation of kgdb describes how to use terminal with a serial port. Here is how it is configured on the remote machine:

root@remote-pc:# cat /sys/module/kgdboc/parameters/kgdboc
ttyS0,115200

Using ssh I issued

root@remote-pc:~# echo g > /proc/sysrq-trigger

And after running gdb vminux what port should I use to connect to the remote Kernel?

(gdb) target remote remote-pc:__what_port?__
1
What do you mean, what port? You started the debugger on a serial console, so whatever you connected the other side of the serial port to. Did you connect the serial ports, or did you mean to use kgdboe?Cheatah
@Cheatah Actually have not heard about kgdboe (only kgdboc is not documented under the doc page I linked)Some Name
@Cheatah Is it even possible to connect to a serial port remotely?Some Name
That depends on what you define as "remotely". If you have an embedded system, connect the serial port to another system, I consider that to be remote, in a way. On a virtualised system you could tunnel it over SSH or something.Cheatah

1 Answers

1
votes

You cannot connect to a literally remote machine through a serial port. What you want to use is KGDB Over Ethernet (kdgboe). See How to use kgdb over ethernet (kgdboe)?