uclinux内核的console(6):调试信息输出
来源:互联网 发布:常用的spc软件 编辑:程序博客网 时间:2024/06/08 04:47
快乐虾
http://blog.csdn.net/lights_joy/
lights@hb165.com
本文适用于
ADI bf561 DSP
优视BF561EVB开发板
uclinux-2008r1.5-rc3 (smp patch)
Visual DSP++ 5.0 (update 5)
欢迎转载,但请保留作者信息
在内核调试时通常要输出一些信息,这些信息的输出通常由一些宏来控制,下面列举内核中用到的几个宏:
1.1 pr_debug
这个宏定义为:
#ifdef DEBUG
/* If you are writing a driver, please use dev_dbg instead */
#define pr_debug(fmt,arg...) /
printk(KERN_DEBUG fmt,##arg)
#else
static /*inline*/ int __attribute__ ((format (printf, 1, 2))) pr_debug(const char * fmt, ...)
{
return 0;
}
#endif
要想输出pr_debug中的信息,首先要求定义DEBUG宏。此外由于它使用了KERN_DEBUG这一输出级别,还必须在内核参数中使用ignore_loglevel。再不然就直接修改pr_debug的定义!
和pr_debug在一起的还有一个叫pr_info的宏,这个宏总能输出信息:
#define pr_info(fmt,arg...) /
printk(KERN_INFO fmt,##arg)
1.2 dev_dbg
这个宏定义为:
#define dev_printk(level, dev, format, arg...) /
printk(level "%s %s: " format , dev_driver_string(dev) , (dev)->bus_id , ## arg)
#ifdef DEBUG
#define dev_dbg(dev, format, arg...) /
dev_printk(KERN_DEBUG , dev , format , ## arg)
#else
static /*inline*/ int __attribute__ ((format (printf, 2, 3)))
dev_dbg(struct device * dev, const char * fmt, ...)
{
return 0;
}
#endif
同样,要想输出dev_dbg中的信息,首先要求定义DEBUG宏。此外由于它使用了KERN_DEBUG这一输出级别,还必须在内核参数中使用ignore_loglevel。再不然就直接修改它的定义!
使用这个宏的好处在于它可以输出驱动或者相关信息的名称:
/**
* dev_driver_string - Return a device's driver name, if at all possible
* @dev: struct device to get the name of
*
* Will return the device's driver's name if it is bound to a device. If
* the device is not bound to a device, it will return the name of the bus
* it is attached to. If it is not attached to a bus either, an empty
* string will be returned.
*/
const char *dev_driver_string(struct device *dev)
{
return dev->driver ? dev->driver->name :
(dev->bus ? dev->bus->name :
(dev->class ? dev->class->name : ""));
}
其实意义不是很大。
还有几个相似的宏:
#define dev_err(dev, format, arg...) /
dev_printk(KERN_ERR , dev , format , ## arg)
#define dev_info(dev, format, arg...) /
dev_printk(KERN_INFO , dev , format , ## arg)
#define dev_warn(dev, format, arg...) /
dev_printk(KERN_WARNING , dev , format , ## arg)
#define dev_notice(dev, format, arg...) /
dev_printk(KERN_NOTICE , dev , format , ## arg)
只是其输出级别不一样而已。
1.3 dprintk
这个宏没什么广泛影响,因为它只定义在个别的c文件里面,其影响只局限在它所在的.c文件。估计是dprintk这个名称比较受欢迎,所以拥有不少的fans。
比如在saa711x.c这个驱动中就是这样定义它的:
#define dprintk(num, format, args...) /
do { /
if (debug >= num) /
printk(format, ##args); /
} while (0)
再想偷懒的就这样定义:
#if DEBUG > 1
#define dprintk printk
#else
#define dprintk(x...) do { ; } while (0)
#endif
哈哈!
1 参考资料
uclinux内核的console(1):数据结构(2009-1-31)
uclinux内核的console(2):early console(2009-1-31)
uclinux内核的console(3):console驱动初始化(2009-1-31)
uclinux内核的console(4):通过console输出信息(2009-1-31)
uclinux内核的console(5):printk相关的内核参数(2009-3-19)
- uclinux内核的console(6):调试信息输出
- uclinux内核的console(6):调试信息输出
- uclinux内核的console(4):通过console输出信息
- uclinux-2008r1-rc8(bf561)内核的console(3):通过console输出信息
- uclinux内核的console
- uclinux内核的console(2):early console
- 通过Console输出调试信息.
- uclinux内核的console(1):数据结构
- uclinux内核的console(1):数据结构
- uclinux内核的console(3):console驱动初始化
- Win32编程调试信息的输出(Console)
- uclinux内核的console(5):printk相关的内核参数
- uclinux-2008r1-rc8(bf561)内核的console(1):数据结构
- php在eclipse的控制台console输出调试信息功能实现
- Window下Qt中用qDebug()输出调试信息到Console控制台的设置方法
- vc6.0或者vs2008 MFC程序采用console输出调试信息的方法
- Window下Qt中用qDebug()输出调试信息到Console控制台的设置方法
- Window下Qt中用qDebug()输出调试信息到Console控制台的设置方法
- 重走C语言之路
- C语言程序100例之C#版-007
- 基于ping命令的服务器是否可连接探查器
- wordnet
- 关于unicode,mbcs,utf8,charset,encoding等相关概念的说明
- uclinux内核的console(6):调试信息输出
- sharepoint 域认证的时候给用户一个友好的登陆界面
- Eclipse常用快捷键分类总结
- IBM收购Sun,这是一种什么样的精神?
- Bash使用
- 文本乱码问题
- Dom4j 使用简介
- Coldfusion: CFC属性变量的自动初始化。
- 世界坐标和页面坐标