码迷,mamicode.com
首页 > 其他好文 > 详细

Tricks about debug

时间:2017-01-18 16:12:58      阅读:328      评论:0      收藏:0      [点我收藏+]

标签:macros   tde   bug   his   cas   stderr   and   debugging   pre   

  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

标签:macros   tde   bug   his   cas   stderr   and   debugging   pre   

原文地址:http://www.cnblogs.com/adera/p/6296888.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!