Code: Select all
void debug_postmortem_hook(void *state, size_t state_size, void *instr_addr)
{
uint32_t eip = (uint32_t) instr_addr;
i386_pusha_registers_t *regs = (i386_pusha_registers_t *) state;
if (state_size != sizeof(i386_pusha_registers_t)) {
earlycon_puts("CORRUPT STATE STRUCT\n");
return;
}
asm("movl %0, %%esp;push %1;push %2;mov %%esp, %%ebp;cli;hlt"::"r"(regs->esp), "r"(eip), "r"(regs->ebp));
}
Code: Select all
; Switch to faulting thread's stack
mov esp, <esp-from-pusha>
; Create fake call frame from exception instr to here
push <eip-from-exception>
push <ebp-from-pusha>
mov ebp, esp
; Halt processor so debugger can attach at any time from now on
cli
hlt