Promise* ChainAdaptorWrapper::getDecision(QString owner, QString contestId)
{
    auto promise = _getDecision(kj::mv(owner), kj::mv(contestId));
    return promiseConverter.convert(kj::mv(promise), [](OwningWrapper<swv::DecisionWrapper>* d) -> QVariantList {
        return {QVariant::fromValue<QObject*>(d)};
    });
}
示例#2
0
bool preFunc(long llfi_index, unsigned opcode, unsigned my_reg_index, 
             unsigned total_reg_target_num) {
  assert(opcodecyclearray[opcode] >= 0 && 
          "opcode does not exist, need to update instructions.def");
  
   if (! fiFlag) return false;
   if (my_reg_index == 0)
    is_fault_injected_in_curr_dyn_inst = false;

  bool inst_selected = false;
  bool reg_selected = false;
  if (config.fi_accordingto_cycle) {
    if (config.fi_cycle >= curr_cycle && 
        config.fi_cycle < curr_cycle + opcodecyclearray[opcode])
      inst_selected = true;
  } else {
    // inject into every runtime instance of the specified instruction
    if (llfi_index == config.fi_index)
      inst_selected = true;
  }

  // each register target of the instruction get equal probability of getting
  // selected. the idea comes from equal probability of drawing lots
  if (inst_selected && (!is_fault_injected_in_curr_dyn_inst)) {
    // NOTE: if fi_reg_index specified, use it, otherwise, randomly generate
    if (config.fi_reg_index >= 0)
      reg_selected = (my_reg_index == config.fi_reg_index);
    else 
      reg_selected = _getDecision(1.0 / (total_reg_target_num - my_reg_index));

    if (reg_selected) {
      //debug(("selected reg index %u\n", my_reg_index));
      is_fault_injected_in_curr_dyn_inst = true;
    }
  }

  if (my_reg_index == total_reg_target_num - 1)
    curr_cycle += opcodecyclearray[opcode];

  return reg_selected;
}