Enable dynamic debug for multiple files at boot

2020-08-25 09:35发布

问题:

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?

回答1:

Separate control commands with semicolons.

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


回答2:

  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.