//-------------------------------------------------------------------------- // returns true-lowcnd was false, resumed the application // nb: recursive calls to this function are not handled in any special way! bool debmod_t::handle_lowcnd(lowcnd_t *lc, debug_event_t *event, int elc_flags) { if ( (debugger_flags & DBG_FLAG_CAN_CONT_BPT) == 0 ) { // difficult case: we have to reset pc, remove the bpt, single step, and resume the app QASSERT(616, !handling_lowcnds.has(lc->ea)); handling_lowcnds.push_back(lc->ea); int code; if ( (elc_flags & ELC_KEEP_EIP) == 0 ) { regval_t rv; rv._set_int(lc->ea); code = dbg_write_register(event->tid, pc_idx, &rv); if ( code <= 0 ) { handling_lowcnds.del(lc->ea); return false; } } code = dbg_freeze_threads_except(event->tid); if ( code > 0 ) { int bptlen = lc->type == BPT_SOFT ? lc->orgbytes.size() : lc->size; code = dbg_del_bpt(lc->type, lc->ea, lc->orgbytes.begin(), bptlen); if ( code > 0 ) { code = dbg_perform_single_step(event, lc->cmd); if ( code <= 0 ) dmsg("%a: failed to single step\n", event->ea); // may happen if ( dbg_add_bpt(lc->type, lc->ea, bptlen) <= 0 ) { // if this fails, it may be because the breakpoint is invalid // at this time so we should notify IDA it isn't available // any more code = 0; dwarning("%a: could not restore deleted bpt\n", lc->ea); // odd } } if ( dbg_thaw_threads_except(event->tid) <= 0 ) { dwarning("%d: could not resume suspended threads\n", event->tid); // odd code = 0; } } handling_lowcnds.del(lc->ea); if ( code <= 0 || event->eid != STEP ) return false; // did not resume } if ( (elc_flags & ELC_KEEP_SUSP) != 0 ) return true; return dbg_continue_after_event(event) > 0; }
//-------------------------------------------------------------------------- // returns true-lowcnd was false, resumed the application // nb: recursive calls to this function are not handled in any special way! bool debmod_t::handle_lowcnd(lowcnd_t *lc, debug_event_t *event) { if ( (debugger_flags & DBG_FLAG_CAN_CONT_BPT) == 0 ) { // difficult case: we have to reset pc, remove the bpt, single step, and resume the app handling_lowcnd = true; regval_t rv; rv._set_int(lc->ea); int code = dbg_write_register(event->tid, pc_idx, &rv); if ( code <= 0 ) { handling_lowcnd = false; return false; } code = dbg_freeze_threads_except(event->tid); if ( code > 0 ) { code = dbg_del_bpt(lc->type, lc->ea, lc->orgbytes.begin(), lc->orgbytes.size()); if ( code > 0 ) { code = dbg_perform_single_step(event, lc->cmd); if ( code <= 0 ) dmsg("%a: failed to single step\n", event->ea); // may happen if ( dbg_add_bpt(lc->type, lc->ea, lc->orgbytes.size()) <= 0 ) { code = 0; dwarning("%a: could not restore deleted bpt\n", lc->cmd.ea); // odd } } if ( dbg_thaw_threads_except(event->tid) <= 0 ) { dwarning("%d: could not resume suspended threads\n", event->tid); // odd code = 0; } } handling_lowcnd = false; if ( code <= 0 || event->eid != STEP ) return false; // did not resume } return dbg_continue_after_event(event); }