在启动时为多个文件启用动态调试

Enable dynamic debug for multiple files at boot

如何通过向 linux 内核提供命令行参数在启动时为多个文件启用动态调试 (pr_debug)?

我尝试提供以下内容作为论据 -

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

但是没有启用动态调试。

我的语法正确吗?

  1. 首先,检查您是否在.config文件中启用了CONFIG_DYNAMIC_DEBUG=y这个

  2. 测试内核启动时是否正常工作。

    echo -n 'module module_name +p' > /debugfs/dynamic_debug/control
    
  3. 当使用 dyndbg=QUERY

  4. 指定时,确保 QUERY 格式正确(module/folder 的路径正确)

内置模块使用dyndbg='module module_name +p'

对于可加载模块使用 module_name.dyndbg=<query> 例如:xhci_hcd.dyndbg=+p

您可以通过编写 /etc/default/grub 文件将其添加到 Linux 默认命令行,如下所示:

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.

用分号分隔控制命令。

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