Score:2

Debugging Kernel Module with dynamic debug

de flag

My system:

mik@michaelUbuntu:~$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
mik@michaelUbuntu:~$ uname -r
5.15.0-78-generic

I would like to debug a kernel driver module (mceusb.c). The code uses the dev_dbg function to output debug messages.

Googling I found, that the output can be enabled by using dynamic debug.

mik@michaelUbuntu:~$ cat /boot/config-5.15.0-78-generic | grep DYNAMIC_DEBUG
CONFIG_DYNAMIC_DEBUG=y
CONFIG_DYNAMIC_DEBUG_CORE=y

So the ubuntu kernel is compiled with the needed option.

I tried to enable dynamic debug for kernel module mceusb as described here: https://stackoverflow.com/questions/50504516/enable-linux-kernel-driver-dev-dbg-debug-messages

but without success:

mik@michaelUbuntu:~$ sudo su
[sudo] password for mik: 
root@michaelUbuntu:/home/mik# echo 'file mceusb +p' > /sys/kernel/debug/dynamic_debug/control 
bash: /sys/kernel/debug/dynamic_debug/control: Operation not permitted
mik@michaelUbuntu:~$ dmsg
Lockdown: bash: debugfs access is restricted; see man kernel_lockdown.7

Accoring to https://www.kernel.org/doc/html/v4.14/admin-guide/dynamic-debug-howto.html it is possible to enable the debug output as a parameter for modprobe. But this does not seam to work either.

root@michaelUbuntu:/home/mik# modprobe mceusb dyndbg="+pmf"

No output in syslog, dmesg or command line.

So how can I enable dynamic_debug logging for the driver mceusb in ubuntu 20.04?

Thanks for your help!

Doug Smythies avatar
gn flag
try [the documentation version for the proper kernel version](https://www.kernel.org/doc/html/v5.15/admin-guide/dynamic-debug-howto.html). I think you will find the syntax has changed a little.
Doug Smythies avatar
gn flag
If I use the correct syntax for your 2nd method, `modprobe mceusb dyndbg==pmf` then it works for me and I can see it in the list, `cat /sys/kernel/debug/dynamic_debug/control | grep mceusb`. For example (one of many): `drivers/media/rc/mceusb.c:1711 [mceusb]mceusb_dev_probe =pmf "acceptable interrupt outbound endpoint found\n"`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.