Chinaunix首页 | 论坛 | 博客
  • 博客访问: 569266
  • 博文数量: 169
  • 博客积分: 2656
  • 博客等级: 少校
  • 技术积分: 1685
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-30 13:03
文章分类

全部博文(169)

文章存档

2011年(1)

2010年(135)

2009年(33)

我的朋友

分类: 嵌入式

2010-05-14 13:13:53

问题:
用excHookAdd挂接了一个处理函数,发现不能正常捕获异常,比如在shell上输入一个非法地址,会出现
->d 0x80000000
80000000:
data access
Exception current instruction address: 0x0026df60
Machine Status Register: 0x0000b032
Data Access Register: 0x80000000
Condition Register: 0x20004084
Data storage interrupt Register: 0x0000b032

1e3e08 vxTaskEntry    +68 : shell ()
26a398 shell          +190: 26a3c4 ()
26a5c4 shell          +3bc: execute ()
26a748 execute        +d8 : yyparse ()
27e7f4 yyparse        +6fc: 27cbb8 ()
27cd3c yystart        +96c: d ()
shell restarted.
               
但是查看并没有进入挂接的异常处理函数,然后用sp起一个任务执行该操作,能够进入异常处理函数
->sp d,0x80000000
task spawned: id = 0x3fff0b0, name = t1
value = 67104944 = 0x3fff0b0
-> 80000000:
data access
Exception current instruction address: 0x0026df60
Machine Status Register: 0x0000b032
Data Access Register: 0x80000000
Condition Register: 0x20000084
Data storage interrupt Register: 0x0000b032
Task: 0x3fff0b0 "t1"
 
答复:
shell任务是有特殊性的,它不能被挂起。正常情况下,发生异常以后,需要先用signal通知任务,然后调用hook,最后挂起任务。
shell任务在收到signal的时候就执行退出程序,然后重启了,exception的进度不能继续。其他任务不会出现这种情况。
下面是代码:
/* task caused exception */

taskIdCurrent->pExcRegSet = pRegs;  /* for taskRegs[GS]et */

taskIdDefault ((int)taskIdCurrent);  /* update default tid */

bcopy ((char *) &excInfo, (char *) &(taskIdCurrent->excInfo),
        sizeof (EXC_INFO));   /* copy in exc info */

if (_func_sigExcKill != NULL)
     _func_sigExcKill((int) vecNum, vecNum, pRegs);             //shell任务执行到这里,就进行任务重启,里面包含了windExit操作,重新调度,所以后面的hook执行不到

if (_func_excInfoShow != NULL)   /* default show rtn? */
     (*_func_excInfoShow) (&excInfo, TRUE);

if (excExcepHook != NULL)                                      //其他任务如果不对signal做处理,都能够执行下来
    (* excExcepHook) (taskIdCurrent, vecNum, pEsf);

taskSuspend (0);    /* whoa partner... */

taskIdCurrent->pExcRegSet = (REG_SET *) NULL; /* invalid after rts */
阅读(1124) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~