驱动程序调试(四)————修改内核来定位系统僵死问题(例:死循环)

时间:2021-02-23 14:38:36
/*系统时钟*/
s3c2410_timer_interrupt:
static pid pre_pid;
static int cnt = 0;
if(pre_id == current->pid)
{
cnt++;
}
else
{
cnt = 0;
pre_id = current->pid;
}
if(cnt == 10*HZ)
{
cnt = 0;
printk("s3c2410_timer_interrupt: pid = %d,task = name = %s\n",current->pid,current->comm);
}

/*中断处理函数*/
asm_do_IRQ:
if(irq == 30 )
{
static pid pre_pid;
static int cnt = 0;
if(pre_id == current->pid)
{
cnt++;
}
else
{
cnt = 0;
pre_id = current->pid;
}
if(cnt == 10*HZ)
{
cnt = 0;
printk("s3c2410_timer_interrupt: pid = %d,task = name = %s\n",current->pid,current->comm);
/*打印PC*/
printk("pc = %08x\n",regs->ARM_pc);
}
}

./firstdrvtest on
asm_do_IRQ => s3c2410_timer_interrupt : pid = 752, task name = firstdrvtest
pc = bf000084
asm_do_IRQ => s3c2410_timer_interrupt : pid = 752, task name = firstdrvtest
pc = bf000084 // 对于中断, pc-4才是发生中断瞬间的地址

看/proc/kallsyms
first_drv.dis
00000000 : bf000000 t first_drv_open [first_drv]
0000003c :
3c: e1a0c00d mov ip, sp
40: e92dd800 stmdb sp!, {fp, ip, lr, pc}
44: e24cb004 sub fp, ip, #4 ; 0x4
48: e24dd004 sub sp, sp, #4 ; 0x4
4c: e3cd3d7f bic r3, sp, #8128 ; 0x1fc0
50: e3c3303f bic r3, r3, #63 ; 0x3f
54: e5933008 ldr r3, [r3, #8]
58: e0910002 adds r0, r1, r2
5c: 30d00003 sbcccs r0, r0, r3
60: 33a03000 movcc r3, #0 ; 0x0
64: e3530000 cmp r3, #0 ; 0x0
68: e24b0010 sub r0, fp, #16 ; 0x10
6c: 1a00001c bne e4