有关BUG_ON()的实现

看到一个crash dump

[17293.834304:1] kernel BUG at mm/slab.c:3072!
[17293.834311:1] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
[17293.834319:1] Modules linked in: memalloc hx280enc hx170dec mali ump
[17293.834338:1] CPU: 1    Not tainted  (3.4.0-g227f4c6-dirty #1)
[17293.834359:1] PC is at cache_free_debugcheck+0x234/0x388
[17293.834369:1] LR is at cache_free_debugcheck+0x90/0x388
[17293.834379:1] pc : [<c00adc74>]    lr : [<c00adad0>]    psr: 20000093
[17293.834384:1] sp : d799de58  ip : d799de58  fp : d799de9c
[17293.834392:1] r10: 00000000  r9 : 000ec83d  r8 : ffc00000
[17293.834400:1] r7 : c0222f30  r6 : 001328b8  r5 : c883e000  r4 : ee0001c0
[17293.834408:1] r3 : 00100000  r2 : dc000004  r1 : 00000001  r0 : c883e000

当前出问题的位置很明确

[17293.834304:1] kernel BUG at mm/slab.c:3072!

PC is at cache_free_debugcheck+0x234/0x388

3072: BUG_ON(objnr >= cachep->num);

但是,反汇编函数cache_free_debugcheck此时对应的指令是:

0xc00adc74 <cache_free_debugcheck+564>:                 ; <UNDEFINED> instruction: 0xe7f001f2

“<UNDEFINED> instruction: 0xe7f001f2”

难道是对应的指令有问题?RAM突然出现问题啦?


跟踪一下BUG_ON的实现,就是使用了undefined instruction 异常,上面的现象是正常的

3072: BUG_ON(objnr >= cachep->num);
include/asm-generic/bug.h
#ifndef HAVE_ARCH_BUG_ON
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
#endif

arch/arm/include/asm/bug.h
/*
 * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
 * We need to be careful not to conflict with those used by other modules and
 * the register_undef_hook() system.
 */
#ifdef CONFIG_THUMB2_KERNEL
#define BUG_INSTR_VALUE 0xde02
#define BUG_INSTR_TYPE ".hword "
#else
#define BUG_INSTR_VALUE 0xe7f001f2
#define BUG_INSTR_TYPE ".word "
#endif


#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
#define _BUG(file, line, value) __BUG(file, line, value)

#define __BUG(__file, __line, __value)                \
do {                                \
    asm volatile(BUG_INSTR_TYPE #__value);            \
    unreachable();                        \
} while (0)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值