1. 程式人生 > >kernel檔案動態除錯功能 -- dynamic_debug 開啟及半閉

kernel檔案動態除錯功能 -- dynamic_debug 開啟及半閉

Kernel def_config中需要開啟以下兩個巨集

CONFIG_DEBUG_FS=y

CONFIG_DYNAMIC_DEBUG=y

(1)step1:open pr_debug
adb root
adb remount
adb shell

開啟動態除錯

#echo 'file sprdfb_main.c +p' > /sys/kernel/debug/dynamic_debug/control
#echo 'file lcdc.c 
+p' > /sys/kernel/debug/dynamic_debug/control
#echo 'file sprdfb_dispc.c 
+p

' > /sys/kernel/debug/dynamic_debug/control

#echo 'file sprd-core.c +p' > /sys/kernel/debug/dynamic_debug/control

關閉動態除錯

#echo 'file sprdfb_main.c -p' > /sys/kernel/debug/dynamic_debug/control
#echo 'file lcdc.c 
-p' > /sys/kernel/debug/dynamic_debug/control
#echo 'file sprd-corec.c 
-p' > /sys/kernel/debug/dynamic_debug/control

sprdfb_main.c

pr_debug(KERN_INFO "sprdfb: [%s]: FBIO_WAITFORVSYNC\n", __FUNCTION__);

Sprd-core.c

pr_debug("%s: starting CMD%u arg %08x flags %08x\n",

 mmc_hostname(host), mrq->cmd->opcode,

 mrq->cmd->arg, mrq->cmd->flags);

stop logs4android
(2)step2:save log
save both kernel log(cat proc/kmsg) && user log(logcat -v time)

Log:

[c0] sprdfb: 6sprdfb: [sprdfb_ioctl]: FBIO_WAITFORVSYNC

[c0] sprdfb: 6sprdfb: [sprdfb_ioctl]: return 0

[c0] mmc0: starting CMD13 arg 00010000 flags 00000195

[c0] mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000

如果需要修改Kernel log level

cat /proc/sys/kernel/printk

7 4 1 7

echo 8 4 1 7 > /proc/sys/kernel/printk

#define KERN_EMERG        KERN_SOH "0"        /* system is unusable */

#define KERN_ALERT        KERN_SOH "1"        /* action must be taken immediately */

#define KERN_CRIT        KERN_SOH "2"        /* critical conditions */

#define KERN_ERR        KERN_SOH "3"        /* error conditions */

#define KERN_WARNING        KERN_SOH "4"        /* warning conditions */

#define KERN_NOTICE        KERN_SOH "5"        /* normal but significant condition */

#define KERN_INFO        KERN_SOH "6"        /* informational */

#define KERN_DEBUG        KERN_SOH "7"        /* debug-level messages */