void __unwind_start(struct unwind_state *state, struct task_struct *task, struct pt_regs *regs, unsigned long *first_frame) { unsigned long *bp; memset(state, 0, sizeof(*state)); state->task = task; state->got_irq = (regs); /* Don't even attempt to start from user mode regs: */ if (regs && user_mode(regs)) { state->stack_info.type = STACK_TYPE_UNKNOWN; return; } bp = get_frame_pointer(task, regs); /* Initialize stack info and make sure the frame data is accessible: */ get_stack_info(bp, state->task, &state->stack_info, &state->stack_mask); update_stack_state(state, bp); /* * The caller can provide the address of the first frame directly * (first_frame) or indirectly (regs->sp) to indicate which stack frame * to start unwinding at. Skip ahead until we reach it. */ while (!unwind_done(state) && (!on_stack(&state->stack_info, first_frame, sizeof(long)) || state->bp < first_frame)) unwind_next_frame(state); }
struct gdb_frame_id luajit_get_frame_id (struct gdb_reader_funcs *self, struct gdb_unwind_callbacks *cb) { struct gdb_frame_id fid; GDB_CORE_ADDR frame_pointer, code_pointer; fid.code_address = 0; fid.stack_address = 0; if(!get_frame_pointer(cb,&frame_pointer) || !get_code_pointer(cb,&code_pointer)) return fid; fid.code_address = code_pointer; fid.stack_address = frame_pointer; }
enum gdb_status luajit_unwind_frame (struct gdb_reader_funcs *self, struct gdb_unwind_callbacks *cb) { GDB_CORE_ADDR frame_pointer; if(!get_frame_pointer(cb,&frame_pointer)) return GDB_FAIL; struct gdb_reg_value* new_sp = malloc(sizeof(struct gdb_reg_value) + sizeof(frame_pointer) - 1); // 4byte value new_sp->free = &luajit_reg_value_free; new_sp->defined = 1; new_sp->size = 4; memcpy(new_sp->value,&frame_pointer,sizeof(frame_pointer)); cb->reg_set(cb, TILE64_REG_SP, new_sp); return GDB_SUCCESS; }
void __unwind_start(struct unwind_state *state, struct task_struct *task, struct pt_regs *regs, unsigned long *first_frame) { unsigned long *bp, *frame; size_t len; memset(state, 0, sizeof(*state)); state->task = task; /* don't even attempt to start from user mode regs */ if (regs && user_mode(regs)) { state->stack_info.type = STACK_TYPE_UNKNOWN; return; } /* set up the starting stack frame */ bp = get_frame_pointer(task, regs); regs = decode_frame_pointer(bp); if (regs) { state->regs = regs; frame = (unsigned long *)regs; len = sizeof(*regs); } else { state->bp = bp; frame = bp; len = FRAME_HEADER_SIZE; } /* initialize stack info and make sure the frame data is accessible */ get_stack_info(frame, state->task, &state->stack_info, &state->stack_mask); update_stack_state(state, frame, len); /* * The caller can provide the address of the first frame directly * (first_frame) or indirectly (regs->sp) to indicate which stack frame * to start unwinding at. Skip ahead until we reach it. */ while (!unwind_done(state) && (!on_stack(&state->stack_info, first_frame, sizeof(long)) || state->bp < first_frame)) unwind_next_frame(state); }