Esempio n. 1
0
void accessors() {
    Map map;
    map.insert("aaa", 1);
    map.insert("bbb", 2);
    const Map &cmap = map;

    // Array-like
    ASSERT_always_require(map["aaa"] == 1);
    ASSERT_always_require(map["bbb"] == 2);
    try {
        map["ccc"];
        ASSERT_not_reachable("should have thrown std::domain_error");
    } catch (const std::domain_error&) {
    }
    ASSERT_always_require(cmap["aaa"] == 1);
    ASSERT_always_require(cmap["bbb"] == 2);
    try {
        cmap["ccc"];
        ASSERT_not_reachable("should have thrown std::domain_error");
    } catch (const std::domain_error&) {
    }

    // get
    ASSERT_always_require(map.get("aaa") == 1);
    ASSERT_always_require(map.get("bbb") == 2);
    try {
        map.get("ccc");
        ASSERT_not_reachable("should have thrown std::domain_error");
    } catch (const std::domain_error&) {
    }
    ASSERT_always_require(cmap.get("aaa") == 1);
    ASSERT_always_require(cmap.get("bbb") == 2);
    try {
        cmap.get("ccc");
        ASSERT_not_reachable("should have thrown std::domain_error");
    } catch (const std::domain_error&) {
    }

    // getOrElse
    int dflt = 911;
    const int cdflt = 911;
    ASSERT_always_require(map.getOrElse("aaa", dflt) == 1);
    ASSERT_always_require(map.getOrElse("bbb", dflt) == 2);
    ASSERT_always_require(map.getOrElse("ccc", dflt) == 911);
    ASSERT_always_require(map.getOrElse("ccc", cdflt) == 911);
    ASSERT_always_require(cmap.getOrElse("aaa", dflt) == 1);
    ASSERT_always_require(cmap.getOrElse("bbb", dflt) == 2);
    ASSERT_always_require(cmap.getOrElse("ccc", dflt) == 911);
    ASSERT_always_require(cmap.getOrElse("ccc", cdflt) == 911);
}
    vector<CFGEdge> CFGNode::inEdges() const {
#if 1
    ASSERT_not_reachable("no longer supported");
#else
        ROSE_ASSERT (node);
        return node->cfgBinInEdges(info);
#endif
    }
Esempio n. 3
0
uint64_t
SValue::get_number() const
{
    for (size_t i=0; i<subvalues.size(); ++i) {
        if (is_valid(i))
            return subvalues[i]->get_number();
    }
    ASSERT_not_reachable("not a number");
}
boost::any
InstructionListModel::data(const Wt::WModelIndex &index, int role) const {
    ASSERT_require(index.isValid());
    ASSERT_require(index.row()>=0 && (size_t)index.row() < insns_.size());
    SgAsmInstruction *insn = insns_[index.row()];
    if (Wt::DisplayRole == role) {
        switch (index.column()) {
            case C_ADDR: {
                return Wt::WString(StringUtility::addrToString(insn->get_address()));
            }
            case C_BYTES: {
                std::string s;
                for (size_t i=0; i<insn->get_raw_bytes().size(); ++i) {
                    uint8_t byte = insn->get_raw_bytes()[i];
                    char buf[32];
                    sprintf(buf, "%02x", byte);
                    s += std::string(i?" ":"") + buf;
                }
                return Wt::WString(s);
            }
            case C_CHARS: {
                std::string s;
                for (size_t i=0; i<insn->get_raw_bytes().size(); ++i) {
                    char ch = insn->get_raw_bytes()[i];
                    s += std::string(i?" ":"") + (isgraph(ch) ? std::string(1, ch) : std::string(" "));
                }
                return Wt::WString(s);
            }
            case C_STACKDELTA: {
                int64_t delta = insn->get_stackDelta();
                if (delta == SgAsmInstruction::INVALID_STACK_DELTA)
                    return Wt::WString("");
                std::string s = (delta >= 0 ? "+" : "") + boost::lexical_cast<std::string>(delta);
                return Wt::WString(s);
            }
            case C_NAME: {
                return Wt::WString(unparseMnemonic(insn));
            }
            case C_ARGS: {
                std::string s;
                const RegisterDictionary *regs = ctx_.partitioner.instructionProvider().registerDictionary();
                const SgAsmExpressionPtrList &operands = insn->get_operandList()->get_operands();
                for (size_t i=0; i<operands.size(); ++i)
                    s += (i?", ":"") + unparseExpression(operands[i], NULL, regs);
                return Wt::WString(s);
            }
            case C_COMMENT: {
                return Wt::WString(insn->get_comment());
            }
            default:
                ASSERT_not_reachable("invalid column number");
        }
    }
    return boost::any();
}
boost::any
InstructionListModel::headerData(int column, Wt::Orientation orientation, int role) const {
    if (Wt::Horizontal == orientation && Wt::DisplayRole == role) {
        switch (column) {
            case C_ADDR:       return Wt::WString("Address");
            case C_BYTES:      return Wt::WString("Bytes");
            case C_CHARS:      return Wt::WString("ASCII");
            case C_STACKDELTA: return Wt::WString("StackDelta");
            case C_NAME:       return Wt::WString("Mnemonic");
            case C_ARGS:       return Wt::WString("Operands");
            case C_COMMENT:    return Wt::WString("Comments");
            default:           ASSERT_not_reachable("invalid column");
        }
    }
    return boost::any();
}
Esempio n. 6
0
void
WMemoryMap::updateRowGroupEditWidgets(RowGroup &rg, MemoryMap::NodeIterator mmNode) {
    if (isEditable_) {
        rg.wDelete->setHidden(rg.editingColumn==DeleteColumn);
        rg.wMove->setHidden(rg.editingColumn==MoveColumn);
        rg.wSplit->setHidden(rg.editingColumn==SplitColumn || !canSplit(rg, mmNode));
        rg.wMerge->setHidden(rg.editingColumn==MergeColumn || !canMerge(rg, mmNode));
        rg.wReadable->setEnabled(true);
        rg.wWritable->setEnabled(true);
        rg.wExecutable->setEnabled(true);

        switch (rg.editingColumn) {
            case ZeroColumn:
                rg.wEditStack->hide();
                break;
            case DeleteColumn:
                rg.wEditStack->setCurrentWidget(rg.wDeleteConfirm);
                rg.wEditStack->show();
                break;
            case MoveColumn:
                rg.wEditStack->setCurrentWidget(rg.wMoveSegment);
                rg.wEditStack->show();
                break;
            case MergeColumn:
                rg.wEditStack->setCurrentWidget(rg.wMergeConfirm);
                rg.wEditStack->show();
                break;
            case SplitColumn:
            case LeastVaColumn:
            case GreatestVaColumn:
            case SizeColumn:
                rg.wEditStack->setCurrentWidget(rg.wHexValueEdit);
                rg.wEditStack->show();
                break;
            default:
                ASSERT_not_reachable("don't know how to edit column " + StringUtility::numberToString(rg.editingColumn));
        }
    } else {
        rg.wDelete->hide();
        rg.wMove->hide();
        rg.wSplit->hide();
        rg.wMerge->hide();
        rg.wReadable->setEnabled(false);
        rg.wWritable->setEnabled(false);
        rg.wExecutable->setEnabled(false);
    }
}
            virtual void visit(SgNode* n) {
                SgAsmInstruction* insn = isSgAsmInstruction(n);
                if (!insn) return;
#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
#if 1
                ASSERT_not_reachable("no longer supported");
#else
                vector<CFGEdge> outEdgesSoFar = insn->cfgBinOutEdges(info);
                for (size_t i = 0; i < outEdgesSoFar.size(); ++i) {
                    info->incomingEdges[outEdgesSoFar[i].target().getNode()].insert(insn->get_address());
                }
#endif
#else
                printf ("This function is not supported in the ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT mode.\n");
                ROSE_ASSERT(false);
#endif
            }
Esempio n. 8
0
bool
StringFinder::String::isRunLengthEncoded() const {
    switch (lengthEncoding_) {
        case MAP_TERMINATED:
        case NUL_TERMINATED:
        case SEQUENCE_TERMINATED:
            return true;
        case BYTE_LENGTH:
        case LE16_LENGTH:
        case BE16_LENGTH:
        case LE32_LENGTH:
        case BE32_LENGTH:
            switch (characterEncoding_) {
                case ASCII:
                    return false;
            }
            break;
    }
    ASSERT_not_reachable("unexpected encoding");
}
Esempio n. 9
0
bool
StringFinder::String::isValid() const {
    switch (lengthEncoding_) {
        case MAP_TERMINATED:
            return true;

        case NUL_TERMINATED:
        case SEQUENCE_TERMINATED:
        case BYTE_LENGTH:
            return nBytes_ >= 1;

        case LE16_LENGTH:
        case BE16_LENGTH:
            return nBytes_ >= 2;

        case LE32_LENGTH:
        case BE32_LENGTH:
            return nBytes_ >= 4;
    }
    ASSERT_not_reachable("unexpected length encoding");
}