Tobin
Tobin

Reputation: 389

View kernel printk debug messages

When using pr_debug("blah\n") messages do not appear in output of dmesg. I have /proc/sys/kernel/printk set to 8 4 1 7. pr_alert messages show up just fine. Any ideas please?

Upvotes: 3

Views: 2756

Answers (2)

Tsyvarev
Tsyvarev

Reputation: 65860

You need to define DEBUG macro for make pr_debug to actually print.

E.g., if add the line

ccflags-y := -DDEBUG=1

into the module's Makefile, then pr_debug called by any source file of that module will actually print information.


Alternatively, if DEBUG macro is not defined but the kernel is built with option CONFIG_DYNAMIC_DEBUG enabled, you may dynamically control which pr_debug call should actually print.

E.g. after executing (from root)

echo 'module my_module' > /sys/kernel/debug/dynamic_debug/control

all pr_debug called from the module my_module will actually print information.

For more information about dynamic debugging see documentation.

Upvotes: 2

Tobin
Tobin

Reputation: 389

If inserting a module use option e.g insmod hello.ko dyndbg=+p. See Documentation/dynamic-debug-howto.txt in the kernel tree.

You also may need CONFIG_DEBUG_KERNEL=y

Upvotes: 1

Related Questions