linux设备调试信息输出
来源:互联网 发布:linux创建一个文件夹 编辑:程序博客网 时间:2024/05/22 03:16
linux设备驱动调试,我们在内核中看到内核使用dev_dbg来控制输出信息,这个函数的实质是调用printk(KERN_DEBUG )来输出打印信息。要打开这个开关需要下面两步。
1、打开调试开关:你调试的文件中必然包含了<linux/device.h>,或者《linux/paltforam_device.h》,后者包含了前者,在包含此头文件之前,使用#define DEBUG 1 来打开调试开关:例如
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/clk.h>
#include <linux/module.h>
#define DEBUG 1
#include <linux/platform_device.h>
在linux/device.h文件中:
#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
但是这个打开了之后,也不能顺利的输出信息,原因是printk有默认的信息级别。
linux/kernel文件中
#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 */
可以看到KERN_DEBUG是级别最低的。
2、修改文件kernel/printk文件
/* printk's without a loglevel use this.. */
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */
/* We show everything that is MORE important than this.. */
#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
#define DEFAULT_CONSOLE_LOGLEVEL 8 /* anything MORE serious than KERN_DEBUG */
其中DEFAULT_CONSOLE_LOGLEVEL为终端console输出的最低级别,比这严重的都将输出。原来该值为7,则调试信息无法输出,修改为8则全部有输出。
1、打开调试开关:你调试的文件中必然包含了<linux/device.h>,或者《linux/paltforam_device.h》,后者包含了前者,在包含此头文件之前,使用#define DEBUG 1 来打开调试开关:例如
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/clk.h>
#include <linux/module.h>
#define DEBUG 1
#include <linux/platform_device.h>
在linux/device.h文件中:
#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
但是这个打开了之后,也不能顺利的输出信息,原因是printk有默认的信息级别。
linux/kernel文件中
#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 */
可以看到KERN_DEBUG是级别最低的。
2、修改文件kernel/printk文件
/* printk's without a loglevel use this.. */
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */
/* We show everything that is MORE important than this.. */
#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
#define DEFAULT_CONSOLE_LOGLEVEL 8 /* anything MORE serious than KERN_DEBUG */
其中DEFAULT_CONSOLE_LOGLEVEL为终端console输出的最低级别,比这严重的都将输出。原来该值为7,则调试信息无法输出,修改为8则全部有输出。
0 0
- linux设备调试信息输出
- linux设备调试信息输出
- linux设备调试信息输出
- Linux调试信息输出串口设备号的设置
- linux中输出调试信息
- linux输出信息调试信息重定向
- 调试信息输出
- vc 调试信息输出
- OutputDebugString输出调试信息
- VC 调试 信息输出
- 开启调试信息输出
- 格式化输出调试信息
- 黑莓调试信息输出
- 调试输出信息OutPutDebugString
- 调试输出信息OutPutDebugString
- makefile输出调试信息
- 输出调试信息
- 输出调试信息宏
- 多线程练习--请用多线程显示,每三个数字为一组,直到30.
- [Leetcode]Construct Binary Tree from Inorder and Postorder Traversal
- mybatis快速入门
- 千锋科技为软件工程和软件专业学生开展实训
- 好习惯
- linux设备调试信息输出
- sleep() 和 yield()方法的区别
- nyoj 44 子串和 【DP】
- 如果要使用复杂功能查询,请使用存储过程
- Q3.1 Describe how you could use a single array to implement three stacks
- Homogeneous Coordinates(齐次坐标)
- cocos2d-js环境配置
- 【UGUI】Canvas
- 精心挑选8本期货类图书推荐给新手