- 论坛徽章:
- 0
|
如题, 我知道在X86系统下, 可以利用ebp, esp打出stack frame, 以解析出all the variants, parameters and return address.
如果是PowerPC的CPU, 该如何打出stack frame呢? 请大牛们支招.
附在x86下dump stack frame 的代码:
......
frame = (DCF_REGISTER *) regs->ebp;
fcn_addr = regs->ra;
stk_addr = regs->esp;
for( cntr = 0; cntr < 2; cntr++ ) {
// Format captions for stack dump.
sprintf( out_bffr, "STACK: FCN ADDR = %lx", fcn_addr );
// Set up dump contol infor for stack dump.
stk_dump.caption = out_bffr;
stk_dump.data_ptr = (void *) stk_addr;
stk_dump.data_len = (char *) frame - (char *) stk_addr;
// Dump stack data.
DCF_Dump_Data( 1, &stk_dump, file, line, fmt_buf );
// Advance to next function on the stack.
if( frame == 0 ) {
break;
}
fcn_addr = *(frame+1);
stk_addr = ((DCF_REGISTER) frame)
+ 2 * sizeof( DCF_REGISTER );
frame = (DCF_REGISTER *) *frame;
}
... |
|