Linux的内核调试打印输出? [英] Linux-kernel debug printouts?
本文介绍了Linux的内核调试打印输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有更好的方法来调试Linux内核打印?
Is there a better way to debug printouts in the Linux kernel?
现在乱扔垃圾的code有:
Right now littering the code with:
printk(KERN_DBG "%s:%d - %s() <message>", __FILE__, __LINE__, __FUNCTION__ );
这是不是很干净。
Which isn't very clean.
有应该是一种方式,整行是 #IFDEF
:在编一些不错的方式。
There ought to be a way for the whole row to be #ifdef
:ed in some nice way.
推荐答案
使用
/* At the top of the file, before any includes */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/printk.h>
/* in code... */
pr_devel("foobar happened\n");
为基础(标准的做法)。然后,您可以添加 __ FILE __
或 __ LINE __
到 pr_fmt
定义如果你需要的。
as a basis (the standard practice). You can then add __FILE__
or __LINE__
to the pr_fmt
definition if you need.
这篇关于Linux的内核调试打印输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文