Tricks about debug

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tricks about debug相关的知识,希望对你有一定的参考价值。

  Add macros in header files:

 1 #undef PDEBUG /* undef it, just in case */
 2 #ifdef SCULL_DEBUG
 3 # ifdef __KERNEL__
 4 /* This one if debugging is on, and kernel space */
 5 # define PDEBUG(fmt, args...) printk( KERN_DEBUG "scull: " fmt, ## args)
 6 # else
 7 /* This one for user space */
 8 # define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
 9 # endif
10 #else
11 # define PDEBUG(fmt, args...) /* not debugging: nothing */
12 #endif
13 #undef PDEBUGG
14 #define PDEBUGG(fmt, args...) /* nothing: it‘s a placeholder */

  Add following lines to makefile:

1 # Comment/uncomment the following line to disable/enable debugging
2 DEBUG = y
3 # Add your debugging flag (or not) to CFLAGS
4 ifeq ($(DEBUG),y)
5   DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
6 else
7   DEBFLAGS = -O2
8 endif
9 CFLAGS += $(DEBFLAGS)

 

以上是关于Tricks about debug的主要内容,如果未能解决你的问题,请参考以下文章