首页 > 代码库 > Tricks about debug
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。