void MonitorSettingDialog::onMonitorResolutionSelected(const int index)
{
    const bool intersect = m_primary && m_model->monitorsIsIntersect();

    if (intersect)
    {
        const ResolutionList modeList = m_model->monitorsSameModeList();
        Q_ASSERT(modeList.size() > index);
        const Resolution mode = modeList[index];

        for (Monitor* mon : m_model->monitorList()) {
            const ResolutionList& list = mon->modeList();
            for (auto it = list.cbegin(); it != list.cend(); ++it) {
                if (it->width() == mode.width() && it->height() == mode.height()) {
                    Q_EMIT requestSetMonitorResolution(mon, it->id());
                    break;
                }
            }
        }
    } else {
        const auto modeList = m_monitor->modeList();
        Q_ASSERT(modeList.size() > index);

        Q_EMIT requestSetMonitorResolution(m_monitor, modeList[index].id());
    }
}
void MonitorSettingDialog::onMonitorModeChanged()
{
    const bool intersect = m_primary && m_model->monitorsIsIntersect();
    if (intersect)
        updateModeList(m_model->monitorsSameModeList());
    else
        updateModeList(m_monitor->modeList());

    if (!intersect)
    {
        m_resolutionsModel->setSelectedIndex(m_resolutionsModel->index(m_monitor->modeList().indexOf(m_monitor->currentMode())));
    }
    else
    {
        const ResolutionList list = m_model->monitorsSameModeList();
        const Resolution mode = m_model->monitorList().first()->currentMode();

        for (auto it = list.cbegin(); it != list.cend(); ++it) {
            if (it->id() == mode.id()) {
                m_resolutionsModel->setSelectedIndex(m_resolutionsModel->index(it - list.cbegin()));
                break;
            }
        }
    }
}
Beispiel #3
0
int32_t ErrorRegister::Lookup(STEP_CODE_DATA_STRUCT & sdc, BitKey & bl)
{
    int32_t rc = SUCCESS;
    ResolutionList rList;
    rc = rMap.LookUp( rList,bl,sdc );
    for( ResolutionList::iterator i = rList.begin(); i != rList.end(); ++i )
    {
        rc |= (*i)->Resolve( sdc );
    }

    return rc;
}
Beispiel #4
0
bool AddressSpace::resolve(ExecutionState &state,
                           TimingSolver *solver,
                           ref<Expr> p,
                           ResolutionList &rl,
                           unsigned maxResolutions,
                           double timeout) {
  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(p)) {
    ObjectPair res;
    if (resolveOne(CE, res))
      rl.push_back(res);
    return false;
  } else {
    TimerStatIncrementer timer(stats::resolveTime);
    uint64_t timeout_us = (uint64_t) (timeout*1000000.);

    std::string TmpStr;
    llvm::raw_string_ostream os(TmpStr);
    os<<p;
    klee_message("[resolveAll]Resolving address expr: %s",os.str().c_str());

    // XXX in general this isn't exactly what we want... for
    // a multiple resolution case (or for example, a \in {b,c,0})
    // we want to find the first object, find a cex assuming
    // not the first, find a cex assuming not the second...
    // etc.

    // XXX how do we smartly amortize the cost of checking to
    // see if we need to keep searching up/down, in bad cases?
    // maybe we don't care?

    // XXX we really just need a smart place to start (although
    // if its a known solution then the code below is guaranteed
    // to hit the fast path with exactly 2 queries). we could also
    // just get this by inspection of the expr.

    ref<ConstantExpr> cex;
    if (!solver->getValue(state, p, cex))
      return true;
    uint64_t example = cex->getZExtValue();
    MemoryObject hack(example);

    MemoryMap::iterator oi = objects.upper_bound(&hack);
    MemoryMap::iterator begin = objects.begin();
    MemoryMap::iterator end = objects.end();

    MemoryMap::iterator start = oi;

    // XXX in the common case we can save one query if we ask
    // mustBeTrue before mayBeTrue for the first result. easy
    // to add I just want to have a nice symbolic test case first.

    // search backwards, start with one minus because this
    // is the object that p *should* be within, which means we
    // get write off the end with 4 queries (XXX can be better,
    // no?)
    while (oi!=begin) {
      --oi;
      const MemoryObject *mo = oi->first;
      if (timeout_us && timeout_us < timer.check())
        return true;
      // klee_message("[resolveAll]checking MemoryObject %s at %p, size %d", oi->first->name.c_str(), oi->first->address,oi->first->size);
      // XXX I think there is some query wasteage here?
      ref<Expr> inBounds = mo->getBoundsCheckPointer(p);
      bool mayBeTrue;
      if (!solver->mayBeTrue(state, inBounds, mayBeTrue))
        return true;
      if (mayBeTrue) {
        rl.push_back(*oi);
        klee_message("[resolveAll]Found MemoryObject %s at %p, size %d", oi->first->name.c_str(), oi->first->address,oi->first->size);

        // fast path check
        unsigned size = rl.size();
        if (size==1) {
          bool mustBeTrue;
          if (!solver->mustBeTrue(state, inBounds, mustBeTrue))
            return true;
          if (mustBeTrue)
            return false;
        } else if (size==maxResolutions) {
          return true;
        }
      }

      bool mustBeTrue;
      if (!solver->mustBeTrue(state,
                              UgeExpr::create(p, mo->getBaseExpr()),
                              mustBeTrue))
        return true;
      if (mustBeTrue)
        break;
    }
    // search forwards
    for (oi=start; oi!=end; ++oi) {
      const MemoryObject *mo = oi->first;
      if (timeout_us && timeout_us < timer.check())
        return true;

      bool mustBeTrue;
      if (!solver->mustBeTrue(state,
                              UltExpr::create(p, mo->getBaseExpr()),
                              mustBeTrue))
        return true;
      if (mustBeTrue)
        break;

      // XXX I think there is some query wasteage here?
      ref<Expr> inBounds = mo->getBoundsCheckPointer(p);
      bool mayBeTrue;
      if (!solver->mayBeTrue(state, inBounds, mayBeTrue))
        return true;
      if (mayBeTrue) {
        rl.push_back(*oi);
        klee_message("[resolveAll]Found MemoryObject %s at %p, size %d", oi->first->name.c_str(), oi->first->address,oi->first->size);
        // fast path check
        unsigned size = rl.size();
        if (size==1) {
          bool mustBeTrue;
          if (!solver->mustBeTrue(state, inBounds, mustBeTrue))
            return true;
          if (mustBeTrue)
            return false;
        } else if (size==maxResolutions) {
          return true;
        }
      }
    }
  }

  return false;
}