Gdb/kgdb debugging loadable kernel module, gdb breakpoint never gets hit


As the title says, I was remote debugging a LKM(imx219), with KGDB config sets to:


KDB wasn’t set though.

So the kernel module was loaded at boot time and the kernel params kgdboc=ttyS0,115200 nokaslr were added following the existing quiet in file extlinux.conf.

After the target booting up, I got the module loading addr by cmd # cat /sys/module/imx219/sections/.text, which gave 0xffffff80_00fb6000, then I issued cmd # echo g >/proc/sysrq-trigger waiting for gdb to kick in, after that, gdb was pulled up on host and was configured:

# gdb [kernel_out]/vmlinux
(gdb) set serial baud 115200
(gdb) set remotetimeout 100
(gdb) tar rem /dev/ttyUSB0
(gdb) add-symbol-file [kernel_out]/drivers/media/i2c/imx219.ko 0xffffff80_00fb6000
(gdb) b imx219_power_on
(gdb) c

Target got back from halting and everything went well till this point. Then gsteamer was launched and func imx219_power_on was called seen from dmesg, however, the breakpoint set in gdb never got hit.

More info on the setup:
gdb version is 8.0
module folder Makefile was updated to subdir-ccflags-y += -Werror -DDEBUG -g
host and target was connected by a USB to TTL serial cable.

Any of the settings are incorrect, or did I miss anything?
Thank you.

Not sure if this will help or not, but take a look here:

@linuxdev although it’s not directly related, what it says from this link led me to another thread which reminded me to use gdb-multiarch and it worked. It’s that the default gdb I was using doesn’t support the arm arch.

Thank you linuxdev.

I’ve always used the gdb which comes with the toolchain, e.g., aarch64-linux-gnu-gcc also comes with aarch64-linux-gnu-gdb (at least in the older releases). I should have remembered to check this :(

1 Like