Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Linux Kernel on a remote machine?

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?__
like image 954
Some Name Avatar asked Apr 07 '26 10:04

Some Name


1 Answers

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)?

like image 131
Marco Bonelli Avatar answered Apr 09 '26 01:04

Marco Bonelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!