R_API int r_debug_step_hard(RDebug *dbg) { if (r_debug_is_dead (dbg)) return R_FALSE; if (!dbg->h->step (dbg)) return R_FALSE; return r_debug_wait (dbg); }
R_API int r_debug_step_hard(RDebug *dbg) { dbg->reason.type = R_DEBUG_REASON_STEP; if (r_debug_is_dead (dbg)) return R_FALSE; if (!dbg->h->step (dbg)) return R_FALSE; return r_debug_wait (dbg); }
R_API int r_debug_step_hard(RDebug *dbg) { if (r_debug_is_dead (dbg)) return R_FALSE; if (!dbg->h->step (dbg)) return R_FALSE; r_debug_wait (dbg); /* return value ignored? */ return R_TRUE; }
R_API int r_debug_continue_syscalls(RDebug *dbg, int *sc, int n_sc) { int i, reg, ret = R_FALSE; if (!dbg || !dbg->h || r_debug_is_dead (dbg)) return R_FALSE; if (!dbg->h->contsc) { /* user-level syscall tracing */ r_debug_continue_until_optype (dbg, R_ANAL_OP_TYPE_SWI, 0); return show_syscall (dbg, "a0"); } if (!r_debug_reg_sync (dbg, R_REG_TYPE_GPR, R_FALSE)) { eprintf ("--> cannot read registers\n"); return -1; } { int err; reg = (int)r_debug_reg_get_err (dbg, "sn", &err); if (err) { eprintf ("Cannot find 'sn' register for current arch-os.\n"); return -1; } } for (;;) { if (r_cons_singleton()->breaked) break; #if __linux__ // step is needed to avoid dupped contsc results r_debug_step (dbg, 1); #endif dbg->h->contsc (dbg, dbg->pid, 0); // TODO handle return value // wait until continuation r_debug_wait (dbg); if (!r_debug_reg_sync (dbg, R_REG_TYPE_GPR, R_FALSE)) { eprintf ("--> cannot sync regs, process is probably dead\n"); return -1; } reg = show_syscall (dbg, "sn"); if (n_sc == -1) continue; if (n_sc == 0) { break; } for (i=0; i<n_sc; i++) { if (sc[i] == reg) return reg; } // TODO: must use r_core_cmd(as)..import code from rcore } return ret; }
R_API int r_debug_continue_kill(RDebug *dbg, int sig) { int ret = R_FALSE; if (r_debug_is_dead (dbg)) return R_FALSE; if (dbg && dbg->h && dbg->h->cont) { r_bp_restore (dbg->bp, R_FALSE); // set sw breakpoints ret = dbg->h->cont (dbg, dbg->pid, dbg->tid, sig); r_debug_wait (dbg); r_bp_restore (dbg->bp, R_TRUE); // unset sw breakpoints r_debug_recoil (dbg); #if 0 #if __UNIX__ /* XXX Uh? */ if (dbg->stop_all_threads && dbg->pid>0) r_sandbox_kill (dbg->pid, SIGSTOP); #endif #endif r_debug_select (dbg, dbg->pid, ret); } return ret; }
R_API int r_debug_continue_kill(RDebug *dbg, int sig) { ut64 pc; int retwait, ret = R_FALSE; if (!dbg) return R_FALSE; #if __WINDOWS__ r_cons_break(w32_break_process, dbg); #endif repeat: if (r_debug_is_dead (dbg)) return R_FALSE; if (dbg->h && dbg->h->cont) { r_bp_restore (dbg->bp, R_TRUE); // set sw breakpoints ret = dbg->h->cont (dbg, dbg->pid, dbg->tid, sig); dbg->reason.signum = 0; retwait = r_debug_wait (dbg); #if __WINDOWS__ if (retwait != R_DEBUG_REASON_DEAD) { ret = dbg->tid; } #endif r_bp_restore (dbg->bp, R_FALSE); // unset sw breakpoints //r_debug_recoil (dbg); if (r_debug_recoil (dbg) || (dbg->reason.type == R_DEBUG_REASON_BREAKPOINT)) { /* check if cur bp demands tracing or not */ pc = r_debug_reg_get (dbg, dbg->reg->name[R_REG_NAME_PC]); RBreakpointItem *b = r_bp_get_at (dbg->bp, pc); if (b) { /* check if cur bp demands tracing or not */ if (b->trace) { eprintf("hit tracepoit at: %"PFMT64x"\n",pc); } else { eprintf("hit breakpoint at: %"PFMT64x"\n",pc); } if (dbg->trace->enabled) r_debug_trace_pc (dbg); // TODO: delegate this to RCore.bphit(RCore, RBreakopintItem) if (dbg->corebind.core && dbg->corebind.bphit) { dbg->corebind.bphit (dbg->corebind.core, b); } if (b->trace) { r_debug_step (dbg, 1); goto repeat; } } } #if 0 #if __UNIX__ /* XXX Uh? */ if (dbg->stop_all_threads && dbg->pid>0) r_sandbox_kill (dbg->pid, SIGSTOP); #endif #endif r_debug_select (dbg, dbg->pid, ret); sig = 0; // clear continuation after signal if needed if (retwait == R_DEBUG_REASON_SIGNAL && dbg->reason.signum != -1) { int what = r_debug_signal_what (dbg, dbg->reason.signum); if (what & R_DBG_SIGNAL_CONT) { sig = dbg->reason.signum; eprintf ("Continue into the signal %d handler\n", sig); goto repeat; } else if (what & R_DBG_SIGNAL_SKIP) { // skip signal. requires skipping one instruction ut8 buf[64]; RAnalOp op = {0}; ut64 pc = r_debug_reg_get (dbg, "pc"); dbg->iob.read_at (dbg->iob.io, pc, buf, sizeof (buf)); r_anal_op (dbg->anal, &op, pc, buf, sizeof (buf)); if (op.size>0) { const char *signame = r_debug_signal_resolve_i (dbg, dbg->reason.signum); r_debug_reg_set (dbg, "pc", pc+op.size); eprintf ("Skip signal %d handler %s\n", dbg->reason.signum, signame); goto repeat; } else { ut64 pc = r_debug_reg_get (dbg, "pc"); eprintf ("Stalled with an exception at 0x%08"PFMT64x"\n", pc); } } } } return ret; }