void CaptureFilterEdit::checkFilter(const QString& filter) { setSyntaxState(Busy); popFilterSyntaxStatus(); bool empty = filter.isEmpty(); setConflict(false); if (bookmark_button_) { bool match = false; for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = g_list_next(cf_item)) { if (!cf_item->data) continue; filter_def *cf_def = (filter_def *) cf_item->data; if (!cf_def->name || !cf_def->strval) continue; if (filter.compare(cf_def->strval) == 0) { match = true; } } if (match) { bookmark_button_->setStockIcon("x-filter-matching-bookmark"); if (remove_action_) { remove_action_->setData(text()); remove_action_->setVisible(true); } } else { bookmark_button_->setStockIcon("x-capture-filter-bookmark"); if (remove_action_) { remove_action_->setVisible(false); } } enable_save_action_ = (!match && !filter.isEmpty()); if (save_action_) { save_action_->setEnabled(false); } } if (apply_button_) { apply_button_->setEnabled(false); } if (clear_button_) { clear_button_->setVisible(!empty); } if (empty) { setFilterSyntaxState(filter, Empty, QString()); } else { syntax_worker_->checkFilter(filter); } }
CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) : SyntaxLineEdit(parent), plain_(plain), field_name_only_(false), enable_save_action_(false), save_action_(NULL), remove_action_(NULL), bookmark_button_(NULL), clear_button_(NULL), apply_button_(NULL) { setAccessibleName(tr("Capture filter entry")); completion_model_ = new QStringListModel(this); setCompleter(new QCompleter(completion_model_, this)); setCompletionTokenChars(libpcap_primitive_chars_); setConflict(false); if (!plain_) { bookmark_button_ = new StockIconToolButton(this, "x-capture-filter-bookmark"); bookmark_button_->setCursor(Qt::ArrowCursor); bookmark_button_->setMenu(new QMenu()); bookmark_button_->setPopupMode(QToolButton::InstantPopup); bookmark_button_->setToolTip(tr("Manage saved bookmarks.")); bookmark_button_->setIconSize(QSize(14, 14)); bookmark_button_->setStyleSheet( "QToolButton {" " border: none;" " background: transparent;" // Disables platform style on Windows. " padding: 0 0 0 0;" "}" "QToolButton::menu-indicator { image: none; }" ); connect(bookmark_button_, SIGNAL(clicked()), this, SLOT(bookmarkClicked())); } if (!plain_) { clear_button_ = new StockIconToolButton(this, "x-filter-clear"); clear_button_->setCursor(Qt::ArrowCursor); clear_button_->setToolTip(QString()); clear_button_->setIconSize(QSize(14, 14)); clear_button_->setStyleSheet( "QToolButton {" " border: none;" " background: transparent;" // Disables platform style on Windows. " padding: 0 0 0 0;" " margin-left: 1px;" "}" ); connect(clear_button_, SIGNAL(clicked()), this, SLOT(clearFilter())); } connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkFilter(const QString&))); #if 0 // Disable the apply button for now if (!plain_) { apply_button_ = new StockIconToolButton(this, "x-filter-apply"); apply_button_->setCursor(Qt::ArrowCursor); apply_button_->setEnabled(false); apply_button_->setToolTip(tr("Apply this filter string to the display.")); apply_button_->setIconSize(QSize(24, 14)); apply_button_->setStyleSheet( "QToolButton {" " border: none;" " background: transparent;" // Disables platform style on Windows. " padding: 0 0 0 0;" "}" ); connect(apply_button_, SIGNAL(clicked()), this, SLOT(applyCaptureFilter())); } #endif connect(this, SIGNAL(returnPressed()), this, SLOT(applyCaptureFilter())); int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); QSize bksz; if (bookmark_button_) bksz = bookmark_button_->sizeHint(); QSize cbsz; if (clear_button_) cbsz = clear_button_->sizeHint(); QSize apsz; if (apply_button_) apsz = apply_button_->sizeHint(); setStyleSheet(QString( "CaptureFilterEdit {" " padding-left: %1px;" " margin-left: %2px;" " margin-right: %3px;" "}" ) .arg(frameWidth + 1) .arg(bksz.width()) .arg(cbsz.width() + apsz.width() + frameWidth + 1) ); QComboBox *cf_combo = qobject_cast<QComboBox *>(parent); if (cf_combo) { connect(cf_combo, SIGNAL(activated(QString)), this, SIGNAL(textEdited(QString))); } QThread *syntax_thread = new QThread; syntax_worker_ = new CaptureFilterSyntaxWorker; syntax_worker_->moveToThread(syntax_thread); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(updateBookmarkMenu())); connect(wsApp, SIGNAL(captureFilterListChanged()), this, SLOT(updateBookmarkMenu())); connect(syntax_thread, SIGNAL(started()), syntax_worker_, SLOT(start())); connect(syntax_thread, SIGNAL(started()), this, SLOT(checkFilter())); connect(syntax_worker_, SIGNAL(syntaxResult(QString,int,QString)), this, SLOT(setFilterSyntaxState(QString,int,QString))); connect(syntax_thread, SIGNAL(finished()), syntax_worker_, SLOT(deleteLater())); syntax_thread->start(); }
bool BitblastSolver::check(Theory::Effort e) { Debug("bv-bitblast") << "BitblastSolver::check (" << e << ")\n"; Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY); ++(d_statistics.d_numCallstoCheck); Debug("bv-bitblast-debug") << "...process queue" << std::endl; //// Lazy bit-blasting // bit-blast enqueued nodes bitblastQueue(); // Processing assertions while (!done()) { TNode fact = get(); d_validModelCache = false; Debug("bv-bitblast") << " fact " << fact << ")\n"; if (options::bvAbstraction()) { // skip atoms that are the result of abstraction lemmas if (d_abstractionModule->isLemmaAtom(fact)) { d_lemmaAtomsQueue.push_back(fact); continue; } } // skip facts involving integer equalities (from bv2nat) if (!utils::isBitblastAtom(fact)) { continue; } if (!d_bv->inConflict() && (!d_bv->wasPropagatedBySubtheory(fact) || d_bv->getPropagatingSubtheory(fact) != SUB_BITBLAST)) { // Some atoms have not been bit-blasted yet d_bitblaster->bbAtom(fact); // Assert to sat bool ok = d_bitblaster->assertToSat(fact, d_useSatPropagation); if (!ok) { std::vector<TNode> conflictAtoms; d_bitblaster->getConflict(conflictAtoms); setConflict(utils::mkAnd(conflictAtoms)); return false; } } } Debug("bv-bitblast-debug") << "...do propagation" << std::endl; // We need to ensure we are fully propagated, so propagate now if (d_useSatPropagation) { d_bv->spendResource(1); bool ok = d_bitblaster->propagate(); if (!ok) { std::vector<TNode> conflictAtoms; d_bitblaster->getConflict(conflictAtoms); setConflict(utils::mkAnd(conflictAtoms)); return false; } } // Solving Debug("bv-bitblast-debug") << "...do solving" << std::endl; if (e == Theory::EFFORT_FULL) { Assert(!d_bv->inConflict()); Debug("bitvector::bitblaster") << "BitblastSolver::addAssertions solving. \n"; bool ok = d_bitblaster->solve(); if (!ok) { std::vector<TNode> conflictAtoms; d_bitblaster->getConflict(conflictAtoms); Node conflict = utils::mkAnd(conflictAtoms); setConflict(conflict); return false; } } Debug("bv-bitblast-debug") << "...do abs bb" << std::endl; if (options::bvAbstraction() && e == Theory::EFFORT_FULL && d_lemmaAtomsQueue.size()) { // bit-blast lemma atoms while (!d_lemmaAtomsQueue.empty()) { TNode lemma_atom = d_lemmaAtomsQueue.front(); d_lemmaAtomsQueue.pop(); if (!utils::isBitblastAtom(lemma_atom)) { continue; } d_bitblaster->bbAtom(lemma_atom); // Assert to sat and check for conflicts bool ok = d_bitblaster->assertToSat(lemma_atom, d_useSatPropagation); if (!ok) { std::vector<TNode> conflictAtoms; d_bitblaster->getConflict(conflictAtoms); setConflict(utils::mkAnd(conflictAtoms)); return false; } } Assert(!d_bv->inConflict()); bool ok = d_bitblaster->solve(); if (!ok) { std::vector<TNode> conflictAtoms; d_bitblaster->getConflict(conflictAtoms); Node conflict = utils::mkAnd(conflictAtoms); setConflict(conflict); ++(d_statistics.d_numBBLemmas); return false; } } return true; }