内核dynamic_debug调试相关

内核中有用pr_debug及dev_debug的log输出, 可以使用内核动态调试开关来选择。

 

具体操作如下:

1. make menconfig 使能 dynamic_debug相关配置

2. cat /sys/kernel/debug/dynamic_debug/control  | grep "dwc3/gadget.c"


   
   
  1. debug/control :/run/media/mmcblk0p1 # cat /sys/kernel/debug/dynamic_debug/control | grep "dwc3/gadget.c"
  2. drivers/usb/dwc3/gadget.c: 814 [dwc3]dwc3_gadget_ep_enable =_ "dwc3: invalid parameters\012"_d
  3. drivers/usb/dwc3/gadget.c: 819 [dwc3]dwc3_gadget_ep_enable =_ "dwc3: missing wMaxPacketSize\012"
  4. drivers/usb/dwc3/gadget.c: 846 [dwc3]dwc3_gadget_ep_disable =_ "dwc3: invalid parameters\012"
  5. drivers/usb/dwc3/gadget.c: 2679 [dwc3]dwc3_endpoint_interrupt =_ "Stream %d found and started"

3. 此时动态打印时关闭的, 如何开启?

echo -n 'file gadget.c +p' > /sys/kernel/debug/dynamic_debug/control     即可

查看有啥区别


   
   
  1. debug/control :/run/media/mmcblk0p1 # cat /sys/kernel/debug/dynamic_debug/control | grep "dwc3/gadget.c"
  2. drivers/usb/dwc3/gadget.c: 814 [dwc3]dwc3_gadget_ep_enable =p "dwc3: invalid parameters\012"_d
  3. drivers/usb/dwc3/gadget.c: 819 [dwc3]dwc3_gadget_ep_enable =p "dwc3: missing wMaxPacketSize\012"
  4. drivers/usb/dwc3/gadget.c: 846 [dwc3]dwc3_gadget_ep_disable =p "dwc3: invalid parameters\012"
  5. drivers/usb/dwc3/gadget.c: 2679 [dwc3]dwc3_endpoint_interrupt =p "Stream %d found and started"

是滴...后面有个p...

 


ok, 不管咋样, 这样这个log就能输出了...

哦, 不对, 还是没看见相应log啊...

忘了一句 echo 8 > /proc/sys/kernel/printk

 


ok, 具体内容挺多, 也很灵活, 可参考内核文档:

Documentation/admin-guide/dynamic-debug-howto.rst

 

摘录一些内容:


   
   
  1. 208 The flags specification comprises a change operation followed
  2. 209 by one or more flag characters. The change operation is one
  3. 210 of the characters::
  4. 211
  5. 212 - remove the given flags
  6. 213 + add the given flags
  7. 214 = set the flags to the given flags
  8. 215
  9. 216 The flags are::
  10. 217
  11. 218 p enables the pr_debug() callsite.
  12. 219 f Include the function name in the printed message
  13. 220 l Include line number in the printed message
  14. 221 m Include module name in the printed message
  15. 222 t Include thread ID in messages not generated from interrupt context
  16. 223 _ No flags are set. (Or 'd with others on input)

   
   
  1. 308 Examples
  2. 309 ========
  3. 310
  4. 311 ::
  5. 312
  6. 313 // enable the message at line 1603 of file svcsock.c
  7. 314 nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
  8. 315 › › › › <debugfs>/dynamic_debug/control
  9. 316
  10. 317 // enable all the messages in file svcsock.c
  11. 318 nullarbor:~ # echo -n 'file svcsock.c +p' >
  12. 319 › › › › <debugfs>/dynamic_debug/control
  13. 320
  14. 321 // enable all the messages in the NFS server module
  15. 322 nullarbor:~ # echo -n 'module nfsd +p' >
  16. 323 › › › › <debugfs>/dynamic_debug/control
  17. 324
  18. 325 // enable all 12 messages in the function svc_process()
  19. 326 nullarbor:~ # echo -n 'func svc_process +p' >
  20. 327 › › › › <debugfs>/dynamic_debug/control
  21. 328
  22. 329 // disable all 12 messages in the function svc_process()
  23. 330 nullarbor:~ # echo -n 'func svc_process -p' >
  24. 331 › › › › <debugfs>/dynamic_debug/control
  25. 332
  26. 333 // enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
  27. 334 nullarbor:~ # echo -n 'format "nfsd: READ" +p' >
  28. 335 › › › › <debugfs>/dynamic_debug/control

ok, that's it.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值