Java Code Examples for com.android.dx.rop.code.SourcePosition#getLine()

The following examples show how to use com.android.dx.rop.code.SourcePosition#getLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RopperMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Sets or updates the information about the return block.
 *
 * @param op {@code non-null;} the opcode to use
 * @param pos {@code non-null;} the position to use
 */
private void updateReturnOp(Rop op, SourcePosition pos) {
    if (op == null) {
        throw new NullPointerException("op == null");
    }

    if (pos == null) {
        throw new NullPointerException("pos == null");
    }

    if (returnOp == null) {
        returnOp = op;
        returnPosition = pos;
    } else {
        if (returnOp != op) {
            throw new SimException("return op mismatch: " + op + ", " +
                                   returnOp);
        }

        if (pos.getLine() > returnPosition.getLine()) {
            // Pick the largest line number to be the "canonical" return.
            returnPosition = pos;
        }
    }
}
 
Example 2
Source File: RopperMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Sets or updates the information about the return block.
 *
 * @param op {@code non-null;} the opcode to use
 * @param pos {@code non-null;} the position to use
 */
private void updateReturnOp(Rop op, SourcePosition pos) {
    if (op == null) {
        throw new NullPointerException("op == null");
    }

    if (pos == null) {
        throw new NullPointerException("pos == null");
    }

    if (returnOp == null) {
        returnOp = op;
        returnPosition = pos;
    } else {
        if (returnOp != op) {
            throw new SimException("return op mismatch: " + op + ", " +
                                   returnOp);
        }

        if (pos.getLine() > returnPosition.getLine()) {
            // Pick the largest line number to be the "canonical" return.
            returnPosition = pos;
        }
    }
}
 
Example 3
Source File: RopperMachine.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Sets or updates the information about the return block.
 *
 * @param op {@code non-null;} the opcode to use
 * @param pos {@code non-null;} the position to use
 */
private void updateReturnOp(Rop op, SourcePosition pos) {
    if (op == null) {
        throw new NullPointerException("op == null");
    }

    if (pos == null) {
        throw new NullPointerException("pos == null");
    }

    if (returnOp == null) {
        returnOp = op;
        returnPosition = pos;
    } else {
        if (returnOp != op) {
            throw new SimException("return op mismatch: " + op + ", " +
                                   returnOp);
        }

        if (pos.getLine() > returnPosition.getLine()) {
            // Pick the largest line number to be the "canonical" return.
            returnPosition = pos;
        }
    }
}
 
Example 4
Source File: RopperMachine.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Sets or updates the information about the return block.
 *
 * @param op {@code non-null;} the opcode to use
 * @param pos {@code non-null;} the position to use
 */
private void updateReturnOp(Rop op, SourcePosition pos) {
    if (op == null) {
        throw new NullPointerException("op == null");
    }

    if (pos == null) {
        throw new NullPointerException("pos == null");
    }

    if (returnOp == null) {
        returnOp = op;
        returnPosition = pos;
    } else {
        if (returnOp != op) {
            throw new SimException("return op mismatch: " + op + ", " +
                                   returnOp);
        }

        if (pos.getLine() > returnPosition.getLine()) {
            // Pick the largest line number to be the "canonical" return.
            returnPosition = pos;
        }
    }
}
 
Example 5
Source File: OutputFinisher.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #add} and {@link #insert},
 * which updates the position and local info flags.
 *
 * @param insn {@code non-null;} an instruction that was just introduced
 */
private void updateInfo(DalvInsn insn) {
    if (! hasAnyPositionInfo) {
        SourcePosition pos = insn.getPosition();
        if (pos.getLine() >= 0) {
            hasAnyPositionInfo = true;
        }
    }

    if (! hasAnyLocalInfo) {
        if (hasLocalInfo(insn)) {
            hasAnyLocalInfo = true;
        }
    }
}
 
Example 6
Source File: OutputFinisher.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #add} and {@link #insert},
 * which updates the position and local info flags.
 *
 * @param insn {@code non-null;} an instruction that was just introduced
 */
private void updateInfo(DalvInsn insn) {
    if (! hasAnyPositionInfo) {
        SourcePosition pos = insn.getPosition();
        if (pos.getLine() >= 0) {
            hasAnyPositionInfo = true;
        }
    }

    if (! hasAnyLocalInfo) {
        if (hasLocalInfo(insn)) {
            hasAnyLocalInfo = true;
        }
    }
}
 
Example 7
Source File: OutputFinisher.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #add},
 * which updates the position and local info flags.
 *
 * @param insn {@code non-null;} an instruction that was just introduced
 */
private void updateInfo(DalvInsn insn) {
    if (! hasAnyPositionInfo) {
        SourcePosition pos = insn.getPosition();
        if (pos.getLine() >= 0) {
            hasAnyPositionInfo = true;
        }
    }

    if (! hasAnyLocalInfo) {
        if (hasLocalInfo(insn)) {
            hasAnyLocalInfo = true;
        }
    }
}
 
Example 8
Source File: OutputFinisher.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@link #add} and {@link #insert},
 * which updates the position and local info flags.
 *
 * @param insn {@code non-null;} an instruction that was just introduced
 */
private void updateInfo(DalvInsn insn) {
    if (! hasAnyPositionInfo) {
        SourcePosition pos = insn.getPosition();
        if (pos.getLine() >= 0) {
            hasAnyPositionInfo = true;
        }
    }

    if (! hasAnyLocalInfo) {
        if (hasLocalInfo(insn)) {
            hasAnyLocalInfo = true;
        }
    }
}
 
Example 9
Source File: DebugInfoEncoder.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Emits the necessary byte sequences to emit the given position table
 * entry. This will typically be a single special opcode, although
 * it may also require DBG_ADVANCE_PC or DBG_ADVANCE_LINE.
 *
 * @param entry position entry to emit.
 * @throws IOException
 */
private void emitPosition(PositionList.Entry entry)
        throws IOException {

    SourcePosition pos = entry.getPosition();
    int newLine = pos.getLine();
    int newAddress = entry.getAddress();

    int opcode;

    int deltaLines = newLine - line;
    int deltaAddress = newAddress - address;

    if (deltaAddress < 0) {
        throw new RuntimeException(
                "Position entries must be in ascending address order");
    }

    if ((deltaLines < DBG_LINE_BASE)
            || (deltaLines > (DBG_LINE_BASE + DBG_LINE_RANGE -1))) {
        emitAdvanceLine(deltaLines);
        deltaLines = 0;
    }

    opcode = computeOpcode (deltaLines, deltaAddress);

    if ((opcode & ~0xff) > 0) {
        emitAdvancePc(deltaAddress);
        deltaAddress = 0;
        opcode = computeOpcode (deltaLines, deltaAddress);

        if ((opcode & ~0xff) > 0) {
            emitAdvanceLine(deltaLines);
            deltaLines = 0;
            opcode = computeOpcode (deltaLines, deltaAddress);
        }
    }

    output.writeByte(opcode);

    line += deltaLines;
    address += deltaAddress;

    if (annotateTo != null || debugPrint != null) {
        annotate(1,
                String.format("%04x: line %d", address, line));
    }
}
 
Example 10
Source File: DebugInfoEncoder.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Emits the necessary byte sequences to emit the given position table
 * entry. This will typically be a single special opcode, although
 * it may also require DBG_ADVANCE_PC or DBG_ADVANCE_LINE.
 *
 * @param entry position entry to emit.
 * @throws IOException
 */
private void emitPosition(PositionList.Entry entry)
        throws IOException {

    SourcePosition pos = entry.getPosition();
    int newLine = pos.getLine();
    int newAddress = entry.getAddress();

    int opcode;

    int deltaLines = newLine - line;
    int deltaAddress = newAddress - address;

    if (deltaAddress < 0) {
        throw new RuntimeException(
                "Position entries must be in ascending address order");
    }

    if ((deltaLines < DBG_LINE_BASE)
            || (deltaLines > (DBG_LINE_BASE + DBG_LINE_RANGE -1))) {
        emitAdvanceLine(deltaLines);
        deltaLines = 0;
    }

    opcode = computeOpcode (deltaLines, deltaAddress);

    if ((opcode & ~0xff) > 0) {
        emitAdvancePc(deltaAddress);
        deltaAddress = 0;
        opcode = computeOpcode (deltaLines, deltaAddress);

        if ((opcode & ~0xff) > 0) {
            emitAdvanceLine(deltaLines);
            deltaLines = 0;
            opcode = computeOpcode (deltaLines, deltaAddress);
        }
    }

    output.writeByte(opcode);

    line += deltaLines;
    address += deltaAddress;

    if (annotateTo != null || debugPrint != null) {
        annotate(1,
                String.format("%04x: line %d", address, line));
    }
}
 
Example 11
Source File: DebugInfoEncoder.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/**
 * Emits the necessary byte sequences to emit the given position table
 * entry. This will typically be a single special opcode, although
 * it may also require DBG_ADVANCE_PC or DBG_ADVANCE_LINE.
 *
 * @param entry position entry to emit.
 * @throws IOException
 */
private void emitPosition(PositionList.Entry entry)
        throws IOException {

    SourcePosition pos = entry.getPosition();
    int newLine = pos.getLine();
    int newAddress = entry.getAddress();

    int opcode;

    int deltaLines = newLine - line;
    int deltaAddress = newAddress - address;

    if (deltaAddress < 0) {
        throw new RuntimeException(
                "Position entries must be in ascending address order");
    }

    if ((deltaLines < DBG_LINE_BASE)
            || (deltaLines > (DBG_LINE_BASE + DBG_LINE_RANGE -1))) {
        emitAdvanceLine(deltaLines);
        deltaLines = 0;
    }

    opcode = computeOpcode (deltaLines, deltaAddress);

    if ((opcode & ~0xff) > 0) {
        emitAdvancePc(deltaAddress);
        deltaAddress = 0;
        opcode = computeOpcode (deltaLines, deltaAddress);

        if ((opcode & ~0xff) > 0) {
            emitAdvanceLine(deltaLines);
            deltaLines = 0;
            opcode = computeOpcode (deltaLines, deltaAddress);
        }
    }

    output.writeByte(opcode);

    line += deltaLines;
    address += deltaAddress;

    if (annotateTo != null || debugPrint != null) {
        annotate(1,
                String.format("%04x: line %d", address, line));
    }
}
 
Example 12
Source File: DebugInfoEncoder.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Emits the necessary byte sequences to emit the given position table
 * entry. This will typically be a single special opcode, although
 * it may also require DBG_ADVANCE_PC or DBG_ADVANCE_LINE.
 *
 * @param entry position entry to emit.
 * @throws IOException
 */
private void emitPosition(PositionList.Entry entry)
        throws IOException {

    SourcePosition pos = entry.getPosition();
    int newLine = pos.getLine();
    int newAddress = entry.getAddress();

    int opcode;

    int deltaLines = newLine - line;
    int deltaAddress = newAddress - address;

    if (deltaAddress < 0) {
        throw new RuntimeException(
                "Position entries must be in ascending address order");
    }

    if ((deltaLines < DBG_LINE_BASE)
            || (deltaLines > (DBG_LINE_BASE + DBG_LINE_RANGE -1))) {
        emitAdvanceLine(deltaLines);
        deltaLines = 0;
    }

    opcode = computeOpcode (deltaLines, deltaAddress);

    if ((opcode & ~0xff) > 0) {
        emitAdvancePc(deltaAddress);
        deltaAddress = 0;
        opcode = computeOpcode (deltaLines, deltaAddress);

        if ((opcode & ~0xff) > 0) {
            emitAdvanceLine(deltaLines);
            deltaLines = 0;
            opcode = computeOpcode (deltaLines, deltaAddress);
        }
    }

    output.writeByte(opcode);

    line += deltaLines;
    address += deltaAddress;

    if (annotateTo != null || debugPrint != null) {
        annotate(1,
                String.format("%04x: line %d", address, line));
    }
}