Cannot enable kernel dynamic debugging on linux

自古美人都是妖i 提交于 2019-12-24 02:35:29

问题


I have enabled the CONFIG_DYNAMIC_DEBUG flag in kernel config file, built & installed the kernel. Then, when I reboot, I can see /sys/kernel/debug/dynamic_debug/control.

However, when I tried to dynamically enable a module like so:

sudo echo 'module xhci_hcd +p' > /sys/kernel/debug/dynamic_debug/control

I got:

bash: /sys/kernel/debug/dynamic_debug/control: Permission denied

Notice that I'm using sudo.


回答1:


The redirection (with the > shell operator) is not performed as root. That's why you get a permission denied error. I suggest you run the whole command in a sub shell like:

sudo sh -c "echo 'module xhci_hcd +p' > /sys/kernel/debug/dynamic_debug/control"



回答2:


Just check if you have booted into the correct version of the kernel after enabling CONFIG_DYNAMIC_DEBUG ? Next check if debugfs is mounted.

Try with -n option (do not output the trailing newline)

echo -n 'module xhci_hcd +p' | sudo tee /sys/kernel/debug/dynamic_debug/control

Also try if you are able to debug a specific file for the ko:

echo -n 'file filename.c +p' | sudo tee /sys/kernel/debug/dynamic_debug/control


来源:https://stackoverflow.com/questions/26556246/cannot-enable-kernel-dynamic-debugging-on-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!