, si_addr ( , ) , /.
, .. , ucontext_t*. , , , void *; GDB (, info registers ) , .
, ARM, , 64- x86, :
volatile char *ptr = (char*)0x1234567890abcdef;
char crashme = *ptr;
, si_addr 0x1234567890abcdef. , #GPF not #PF, x86. , ucontext_t/struct sigcontext ( ), , .
:
void SigBusHandler(
int signum,
siginfo_t *pAct,
void *context
)
{
struct sigcontext *ctx = &(((ucontext_t*)context)->uc_mcontext);
uintptr_t fault_address = ctx->arm_pc;
...
}
, , , CPU , . /, , :
define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext.eip)
define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext.rip)
uintptr_t instr_address = GET_PC_FROM_CONTEXT(context);
, !