Bug trap in Linux on ARM
时间:2009-04-25 来源:chriscross
During the developing of Linux, kernel hackers may sometimes have the feeling that there are be loopholes in their logic, and the loophole may possibly give rise to potential bugs in the code. Nevertheless, they are not able to totally figure out the mistake and weed out the bug profoundly at that point.
In this case, one can leave a bug trap in the code, so that in debugging the bug can be discovered at the first time.
The bug trap is written as below on ARM:
/* include/asm-arm/bug.h */
#ifdef CONFIG_BUG
#ifdef CONFIG_DEBUG_BUGVERBOSE
extern void __bug(const char *file, int line) __attribute__((noreturn));
/* give file/line information */
#define BUG() __bug(__FILE__, __LINE__)
/* arch/arm/kernel/traps.c */
printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
*(int *)0 = 0;
/* Avoid "noreturn function does return" */
for (;;);
}
EXPORT_SYMBOL(__bug);
In this case, one can leave a bug trap in the code, so that in debugging the bug can be discovered at the first time.
The bug trap is written as below on ARM:
/* include/asm-arm/bug.h */
#ifdef CONFIG_BUG
#ifdef CONFIG_DEBUG_BUGVERBOSE
extern void __bug(const char *file, int line) __attribute__((noreturn));
/* give file/line information */
#define BUG() __bug(__FILE__, __LINE__)
/* arch/arm/kernel/traps.c */
printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
*(int *)0 = 0;
/* Avoid "noreturn function does return" */
for (;;);
}
EXPORT_SYMBOL(__bug);
相关阅读 更多 +