最終更新:2016-04-08 (金) 17:30:50 (1636d)  

CONFIG_DYNAMIC_DEBUG
Top / CONFIG_DYNAMIC_DEBUG

Enable dynamic printk() support

ドキュメント

関数

help

  • Compiles debug level messages into the kernel, which would not
    otherwise be available at runtime. These messages can then be
    enabled/disabled based on various levels of scope - per source file,
    function, module, format string, and line number. This mechanism
    implicitly compiles in all pr_debug() and dev_dbg() calls, which
    enlarges the kernel text size by about 2%.
    
    If a source file is compiled with DEBUG flag set, any
    pr_debug() calls in it are enabled by default, but can be
    disabled at runtime as below.  Note that DEBUG flag is
    turned on by many CONFIG_*DEBUG* options.
    
    Usage:
    
    Dynamic debugging is controlled via the 'dynamic_debug/control' file,
    which is contained in the 'debugfs' filesystem. Thus, the debugfs
    filesystem must first be mounted before making use of this feature.
    We refer the control file as: <debugfs>/dynamic_debug/control. This
    file contains a list of the debug statements that can be enabled. The
    format for each line of the file is:
    
          filename:lineno [module]function flags format
    
    filename : source file of the debug statement
    lineno : line number of the debug statement
    module : module that contains the debug statement
    function : function that contains the debug statement
    flags : '=p' means the line is turned 'on' for printing
    format : the format used for the debug statement
    
    From a live system:
    
          nullarbor:~ # cat <debugfs>/dynamic_debug/control
          # filename:lineno [module]function flags format
          fs/aio.c:222 [aio]__put_ioctx =_ "__put_ioctx:\040freeing\040%p\012"
          fs/aio.c:248 [aio]ioctx_alloc =_ "ENOMEM:\040nr_events\040too\040high\012"
          fs/aio.c:1770 [aio]sys_io_cancel =_ "calling\040cancel\012"
    
    Example usage:
    
          // enable the message at line 1603 of file svcsock.c
          nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
                                          <debugfs>/dynamic_debug/control
    
          // enable all the messages in file svcsock.c
          nullarbor:~ # echo -n 'file svcsock.c +p' >
                                          <debugfs>/dynamic_debug/control
    
          // enable all the messages in the NFS server module
          nullarbor:~ # echo -n 'module nfsd +p' >
                                          <debugfs>/dynamic_debug/control
    
          // enable all 12 messages in the function svc_process()
          nullarbor:~ # echo -n 'func svc_process +p' >
                                          <debugfs>/dynamic_debug/control
    
          // disable all 12 messages in the function svc_process()
          nullarbor:~ # echo -n 'func svc_process -p' >
                                          <debugfs>/dynamic_debug/control
    
    See Documentation/dynamic-debug-howto.txt for additional information.

メモ

対応

debugfs

  • For example, if you want to enable printing from source file 'svcsock.c', line 1603 you simply do:
    nullarbor:~ # echo 'file svcsock.c line 1603 +p' > <debugfs>/dynamic_debug/control
    有効化/無効化の方法はいくつかあります。
    
    例えば、
    
    svcsock.cの全てのpr_debug()を有効化
    echo -n 'file svcsock.c +p' > <debugfs>/dynamic_debug/control
    svcsock.cの1603行目のpr_debug()を有効化
    echo -n 'file svcsock.c line 1603 +p' > <debugfs>/dynamic_debug/control
    imx.cのimx_int()内の全てのpr_debug()を有効化
    echo -n 'file imx.c func imx_int +p' > /sys/kernel/debug/dynamic_debug/control
    ※ 無効化の際は、最後の"+p"を"-p"と指定してください

参考