void do_list(struct response *resp) { long long int start = resp->r_start; long long int length = resp->r_length; int conflict = false; if (resp->r_fpos != 0 && fno[resp->r_fpos] == 0) { strcpy(errdetail, "Invalid file number"); sprintf(badtoken, "%ld", resp->r_fpos); resp->r_status = STATUS_ERRNO; resp->r_errno = EBADF; return; } resp->r_lock_type = F_WRLCK; make_test_item(start, lock_end(start, length)); while (tl_head != NULL) { conflict |= list_locks(tl_head->tl_start, tl_head->tl_end, resp); remove_test_list_head(); } if (conflict) resp->r_status = STATUS_DENIED; else resp->r_status = STATUS_AVAILABLE; resp->r_lock_type = F_WRLCK; resp->r_start = start; resp->r_length = length; }
int list_locks(long long int start, long long int end, struct response *resp) { long long int conf_end; struct flock lock; int rc; lock.l_whence = SEEK_SET; lock.l_type = F_WRLCK; lock.l_start = start; if (end == INT64_MAX) lock.l_len = 0; else lock.l_len = end - start; rc = fcntl(fno[resp->r_fpos], F_GETLK, &lock); if (rc == -1) { strcpy(errdetail, "Test failed"); sprintf(badtoken, "%s %lld %lld", str_lock_type(lock.l_type), resp->r_start, resp->r_length); resp->r_errno = errno; resp->r_status = STATUS_ERRNO; respond(resp); return false; } /* Our test succeeded */ if (lock.l_type == F_UNLCK) return false; resp->r_status = STATUS_CONFLICT; resp->r_lock_type = lock.l_type; resp->r_pid = lock.l_pid; resp->r_start = lock.l_start; resp->r_length = lock.l_len; respond(resp); conf_end = lock_end(lock.l_start, lock.l_len); if (lock.l_start > start) make_test_item(start, lock.l_start); if (conf_end < end) make_test_item(conf_end, end); return true; }
void reception::start_scan () { scan_thread = new reception_thread(frontendfd , adapter_edit->text ().toStdString () , frontend_edit->text ().toStdString ()); scan_thread->start (); QObject::connect(this, SIGNAL(lock_frequency (unsigned int)), scan_thread , SLOT(lock_frequency(unsigned int)), Qt::QueuedConnection); QObject::connect(scan_thread, SIGNAL(lock_error_signal()), this , SLOT(lock_error()), Qt::QueuedConnection); QObject::connect(scan_thread, SIGNAL(network_found(std::string, unsigned int)), this , SLOT(network_found(std::string, unsigned int)), Qt::QueuedConnection); QObject::connect(scan_thread, SIGNAL(lock_end_signal()), this , SLOT(lock_end()), Qt::QueuedConnection); Q_EMIT lock_frequency(frequencies[current_frequency_index]); }
//-------------------------------------------------------------------------- // return lowcnd_t if its condition is not satisfied lowcnd_t *debmod_t::get_failed_lowcnd(thid_t tid, ea_t ea) { #ifndef ENABLE_LOWCNDS qnotused(tid); qnotused(ea); #else lowcnds_t::iterator p = cndmap.find(ea); if ( p != cndmap.end() ) { bool ok = true; idc_value_t rv; char name[32]; ::qsnprintf(name, sizeof(name), "__lc%a", ea); lowcnd_t &lc = p->second; lock_begin(); { idc_debmod = this; // is required by compiler/interpreter idc_thread = tid; // is required by interpreter if ( !lc.compiled ) { qstring func; func.sprnt("static %s() { return %s; }", name, lc.cndbody.begin()); ok = CompileLineEx(func.begin(), NULL, 0, NULL, true); if ( ok ) lc.compiled = true; } if ( ok ) ok = Run(name, 0, NULL, &rv, NULL, 0); } lock_end(); if ( !ok ) { report_idc_error(ea, get_qerrno(), get_error_data(0), get_error_string(0)); return NULL; } VarInt64(&rv); if ( rv.i64 == 0 ) return &lc; // condition is not satisfied, resume } #endif return NULL; }
//-------------------------------------------------------------------------- // since arm does not have a single step facility, we have to emulate it // with a temporary breakpoint. int arm_debmod_t::dbg_perform_single_step(debug_event_t *dev, const insn_t &insn) { // read register values regvals_t values; values.resize(nregs); int code = dbg_read_registers(dev->tid, ARM_RC_GENERAL, values.begin()); if ( code <= 0 ) return code; static const opinfo_helpers_t oh = { arm_getreg, arm_get_byte, arm_get_word, arm_get_long, arm_get_dtyp_size, NULL, // InstrIsSet not needed }; // calculate the address of the next executed instruction lock_begin(); ssmod = this; ea_t next = calc_next_exec_insn(insn, values.begin(), oh); ssmod = NULL; lock_end(); // BADADDR means that the execution flow is linear if ( next == BADADDR ) { next = insn.ea + insn.size; if ( (values[R_PSR].ival & BIT5) != 0 ) // thumb? next |= 1; } // safety check: self jumping instruction can not be single stepped if ( (next & ~1) == insn.ea ) return 0; // add a breakpoint there update_bpt_info_t ubi; ubi.ea = next; ubi.type = BPT_SOFT; ubi.code = 0; code = dbg_update_bpts(&ubi, 1, 0); if ( code <= 0 ) return code; code = resume_app_and_get_event(dev); // clean up: delete the temporary breakpoint ubi.ea &= ~1; // del_bpt requires an even address if ( dbg_update_bpts(&ubi, 0, 1) <= 0 ) { msg("%a: failed to remove single step bpt?!\n", ubi.ea); if ( code > 0 ) code = 0; } // the caller expects to see STEP after us: if ( code > 0 ) dev->eid = STEP; return code; }