Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable dynamic debug for multiple files at boot

How to enable dynamic debugging (pr_debug) at boot for multiple files by supplying a command line argument to the linux kernel?

I tried to provide the following as an argument -

dyndbg='file drivers/<filename1> +p file drivers/<filename2> +p file drivers/<filename3> +p'

However the dynamic debugging was not enabled.

Is my syntax correct?

like image 997
Raj Avatar asked Jan 02 '15 15:01

Raj


People also ask

How to enable dynamic debug in kernel?

To activate debug messages for core code and built-in modules during the boot process, even before userspace and debugfs exists, use dyndbg="QUERY" , module. dyndbg="QUERY" , or ddebug_query="QUERY" ( ddebug_query is obsoleted by dyndbg , and deprecated).

What is Pr_debug?

pr_debug() Some files call pr_debug(), which is ordinarily an empty macro that discards its arguments at compile time. To enable debugging output, build the appropriate file with -DDEBUG by adding CFLAGS_[filename].o := -DDEBUG. to the makefile.

How do I enable debug logs in kernel?

upon the kernel booted and the prompt appear to enable debug level messages by executing either dmesg -n 8 or echo 8 > /proc/sys/kernel/printk.

How does Debugfs work?

Debugfs exists as a simple way for kernel developers to make information available to user space. Unlike /proc, which is only meant for information about a process, or sysfs, which has strict one-value-per-file rules, debugfs has no rules at all. Developers can put any information they want there.


2 Answers

Separate control commands with semicolons.

dyndbg='file drivers/<filename1> +p; file drivers/<filename2> +p; file drivers/<filename3> +p'
like image 154
Peng Avatar answered Sep 25 '22 03:09

Peng


  1. First, check if you have enabled CONFIG_DYNAMIC_DEBUG=y this in the .config file

  2. Test if this works properly when the kernel is booted.

    echo -n 'module module_name +p' > /debugfs/dynamic_debug/control
    
  3. Make sure the QUERY is in correct format (where the path to the module/folder is correct) when specified with dyndbg=QUERY

For built-in module use dyndbg='module module_name +p'

For loadable module use module_name.dyndbg=<query> ex: xhci_hcd.dyndbg=+p

You can add it to your Linux default command line by writing the /etc/default/grub file as follows:

GRUB_CMDLINE_LINUX_DEFAULT="xhci_hcd.dyndbg=+p"

Refer link:

Debug messages during Boot Process

To activate debug messages for core code and built-in modules during the boot process, even before userspace and debugfs exists, use dyndbg="QUERY", module.dyndbg="QUERY", or ddebug_query="QUERY" (ddebug_query is obsoleted by dyndbg, and deprecated). QUERY follows the syntax described above, but must not exceed 1023 characters. Your bootloader may impose lower limits.

These dyndbg params are processed just after the ddebug tables are processed, as part of the arch_initcall. Thus you can enable debug messages in all code run after this arch_initcall via this boot parameter.

like image 34
askb Avatar answered Sep 25 '22 03:09

askb