s1005056 发表于 2014-2-7 14:11:21

请问如何让dev_dbg的内容显示?

本帖最后由 s1005056 于 2014-2-17 14:42 编辑

版上各位大师门好,
在kernel 3.0.8内sound\soc\soc-core.c中使用了dev_dbg()来显示目前的注册状态,但是预设是不显示的,请问要加入哪些code才可以让他显示?


感谢回复{:2_131:}

TQ-ZQL 发表于 2014-2-10 13:42:46

本帖最后由 TQ-ZQL 于 2014-2-10 13:43 编辑

在文件<linux/device.h>,或者<linux /paltforam_device.h>前加#define DEBUG   ,如果还没有打印,可以将内核默然打印等级设置成4或者更大:
Prompt: Default message log level (1-7) lib/Kconfig.debug:13
Location:
    -> Kernel hacking

s1005056 发表于 2014-2-12 16:21:07

TQ-ZQL 发表于 2014-2-10 13:42
在文件,或者前加#define DEBUG   ,如果还没有打印,可以将内核默然打印等级设置成4或者更大:
Prompt: D ...

谢谢ZQL的帮忙,已经顺利可以印出信息了

[笔记]
1. 在sound\soc\soc-core.c文件中,于#include<linux/platform_device.h>前加入#define DEBUG变成:
#include <linux/debugfs.h>
#define DEBUG
#include <linux/platform_device.h>

2. 在kernel\printk.c中更改console log level,压到最底层
#define MINIMUM_CONSOLE_LOGLEVEL 1
#define DEFAULT_CONSOLE_LOGLEVEL 8 /* original was 7 */

s1005056 发表于 2014-2-14 10:58:43

[原因] (若有误还请指教)
由于dev_dbg在include\linux\device.h中定义为#if <font color="#ff0000">defined(DEBUG)</font>
#define dev_dbg(dev, format, arg...)                \
        dev_printk(<font color="#ff00ff">KERN_DEBUG</font>, dev, format, ##arg)
#elif defined(CONFIG_DYNAMIC_DEBUG)
...
1. define DEBUG
由于soc-core.c并非直接引用device.h,而是由platform_device.h去include device.h
因此在#include <linux/platform_device.h>前加入#define DEBUG才能将DEBUG参数加入
但是也发现有人在#include <linux/platform_device.h>后,加入了#undefine DEBUG,尚未确定其影响


2. 将printk级别降至最低的KERN_DEBUG
kernel中printk的级别在include\linux\printk.h中定义如下
#define KERN_EMERG        "<0>"        /* system is unusable                        */
#define KERN_ALERT        "<1>"        /* action must be taken immediately        */
#define KERN_CRIT        "<2>"        /* critical conditions                        */
#define KERN_ERR        "<3>"        /* error conditions                        */
#define KERN_WARNING        "<4>"        /* warning conditions                        */
#define KERN_NOTICE        "<5>"        /* normal but significant condition        */
#define KERN_INFO        "<6>"        /* informational                        */
#define KERN_DEBUG        "<7>"        /* debug-level messages                        */而dev_dbg则是属于最低层的log级别KERN_DEBUG
因此需要在include\linux\printk.c中更改log显示级别
printk.c中之原代码如下
/* We show everything that is MORE important than this.. */
#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
#define DEFAULT_CONSOLE_LOGLEVEL7/* anything MORE serious than KERN_DEBUG */因此需将DEFAULT_CONSOLE_LOGLEVEL改成8







页: [1]
查看完整版本: 请问如何让dev_dbg的内容显示?