修改点:
1. 所有vrs[7]都要改成vrs[11],
2. unwind_frame()
/* We are done if current frame pc is equal to the virtual pc, prevent infinite loop */
if(pc == ucb.vrs[15]) {
return 0;
}
如果C代码函数有递归调用,可能不会push pc,所以pop时pc是没有改变的,递归虽然调用的是同一个函数,但不能只认为只有一次调用,
(这里同时也是3.)
3. unwind_frame()
/* Set the virtual pc to the virtual lr if this is the first unwind */ if(ucb.vrs[15] == 0) { ucb.vrs[15] = ucb.vrs[14]; }
init初始化时,
/* Initialize the virtual register set */ if(frame) { ucb->vrs[11] = frame->fp; ucb->vrs[13] = frame->sp; ucb->vrs[14] = frame->lr; ucb->vrs[15] = frame->pc; } 这里当时没注意,原出处是ucb->vrs[15] = 0;
但同样的是递归时不更新PC同