内核中有用pr_debug及dev_debug的log输出, 可以使用内核动态调试开关来选择。
具体操作如下:
1. make menconfig 使能 dynamic_debug相关配置
2. cat /sys/kernel/debug/dynamic_debug/control | grep "dwc3/gadget.c"
-
debug/control :/run/media/mmcblk0p1
# cat /sys/kernel/debug/dynamic_debug/control | grep "dwc3/gadget.c"
-
drivers/usb/dwc3/gadget.c:
814 [dwc3]dwc3_gadget_ep_enable =_
"dwc3: invalid parameters\012"_d
-
drivers/usb/dwc3/gadget.c:
819 [dwc3]dwc3_gadget_ep_enable =_
"dwc3: missing wMaxPacketSize\012"
-
drivers/usb/dwc3/gadget.c:
846 [dwc3]dwc3_gadget_ep_disable =_
"dwc3: invalid parameters\012"
-
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 即可
查看有啥区别
-
debug/control :/run/media/mmcblk0p1
# cat /sys/kernel/debug/dynamic_debug/control | grep "dwc3/gadget.c"
-
drivers/usb/dwc3/gadget.c:
814 [dwc3]dwc3_gadget_ep_enable =p
"dwc3: invalid parameters\012"_d
-
drivers/usb/dwc3/gadget.c:
819 [dwc3]dwc3_gadget_ep_enable =p
"dwc3: missing wMaxPacketSize\012"
-
drivers/usb/dwc3/gadget.c:
846 [dwc3]dwc3_gadget_ep_disable =p
"dwc3: invalid parameters\012"
-
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
摘录一些内容:
-
208 The flags specification comprises a change operation followed
-
209 by one
or more flag characters. The change operation is one
-
210 of the characters::
-
211
-
212 - remove the given flags
-
213 + add the given flags
-
214 = set the flags to the given flags
-
215
-
216 The flags are::
-
217
-
218 p enables the
pr_debug() callsite.
-
219 f Include the function name in the printed message
-
220 l Include line number in the printed message
-
221 m Include
module name in the printed message
-
222 t Include thread ID in messages
not generated from interrupt context
-
223 _ No flags are set. (Or
'd with others on input)
-
308 Examples
-
309 ========
-
310
-
311 ::
-
312
-
313
// enable the message at line 1603 of file svcsock.c
-
314 nullarbor:~
# echo -n 'file svcsock.c line 1603 +p' >
-
315 › › › › <debugfs>/dynamic_debug/control
-
316
-
317
// enable all the messages in file svcsock.c
-
318 nullarbor:~
# echo -n 'file svcsock.c +p' >
-
319 › › › › <debugfs>/dynamic_debug/control
-
320
-
321
// enable all the messages in the NFS server module
-
322 nullarbor:~
# echo -n 'module nfsd +p' >
-
323 › › › › <debugfs>/dynamic_debug/control
-
324
-
325
// enable all 12 messages in the function svc_process()
-
326 nullarbor:~
# echo -n 'func svc_process +p' >
-
327 › › › › <debugfs>/dynamic_debug/control
-
328
-
329
// disable all 12 messages in the function svc_process()
-
330 nullarbor:~
# echo -n 'func svc_process -p' >
-
331 › › › › <debugfs>/dynamic_debug/control
-
332
-
333
// enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
-
334 nullarbor:~
# echo -n 'format "nfsd: READ" +p' >
-
335 › › › › <debugfs>/dynamic_debug/control
ok, that's it.