Esempio n. 1
0
/** Returns a list of parts of a single section that have been referenced.  The offsets are relative to the start of the
 *  section. */
AddressIntervalSet
SgAsmGenericSection::get_referenced_extents() const
{
    if (0==get_size())
        return AddressIntervalSet();

    AddressIntervalSet retval;
    AddressInterval segment = AddressInterval::baseSize(get_offset(), get_size());
    const AddressIntervalSet &fileExtents = get_file()->get_referenced_extents();
    BOOST_FOREACH (const AddressInterval &interval, fileExtents.intervals()) {
        if (segment.isContaining(interval)) {
            retval.insert(AddressInterval::baseSize(interval.least()-get_offset(), interval.size()));
        } else if (interval.isLeftOf(segment) || interval.isRightOf(segment)) {
            // no overlap
        } else if (interval.isContaining(segment)) {
            retval.insert(AddressInterval::baseSize(0, get_size()));
            break;                                      // no point in continuing since we've referenced whole segment now
        } else if (interval.least() < segment.least()) {
            retval.insert(AddressInterval::baseSize(0, interval.least()+interval.size()-get_offset()));
        } else if (interval.greatest() > segment.greatest()) {
            retval.insert(AddressInterval::baseSize(interval.least()-get_offset(), get_offset()+get_size()-interval.least()));
        } else {
            ASSERT_not_reachable("invalid extent overlap category");
        }
    }
    return retval;
}
Esempio n. 2
0
void
CfgEmitter::selectInterval(const AddressInterval &interval) {
    BOOST_FOREACH (const ControlFlowGraph::VertexNode &vertex, graph_.vertices()) {
        if (vertex.value().type() == V_BASIC_BLOCK && interval.isContaining(vertex.value().address())) {
            Organization &org = vertexOrganization(vertex);
            org.select();
            org.label(vertexLabelDetailed(vertex));
            org.attributes(vertexAttributes(vertex));
        }
    }

    BOOST_FOREACH (const ControlFlowGraph::EdgeNode &edge, graph_.edges()) {
        if (vertexOrganization(edge.source()).isSelected() && vertexOrganization(edge.target()).isSelected()) {
            Organization &org = edgeOrganization(edge);
            if (!org.isSelected()) {
                org.select();
                org.label(edgeLabel(edge));
                org.attributes(edgeAttributes(edge));
            }
        }
    }
}