[][src]Function solana_rbpf::ebpf::to_insn_vec

pub fn to_insn_vec(prog: &[u8]) -> Vec<Insn>

Return a vector of struct Insn built from a program.

This is provided as a convenience for users wishing to manipulate a vector of instructions, for example for dumping the program instruction after instruction with a custom format.

Note that the two parts of LD_DW_IMM instructions (spanning on 64 bits) are considered as two distinct instructions.

Examples

use solana_rbpf::ebpf;

let prog = &[
    0x18, 0x00, 0x00, 0x00, 0x88, 0x77, 0x66, 0x55,
    0x00, 0x00, 0x00, 0x00, 0x44, 0x33, 0x22, 0x11,
    0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];

let v = ebpf::to_insn_vec(prog);
assert_eq!(v, vec![
    ebpf::Insn {
        opc: 0x18,
        dst: 0,
        src: 0,
        off: 0,
        imm: 0x55667788
    },
    ebpf::Insn {
        opc: 0,
        dst: 0,
        src: 0,
        off: 0,
        imm: 0x11223344
    },
    ebpf::Insn {
        opc: 0x95,
        dst: 0,
        src: 0,
        off: 0,
        imm: 0
    },
]);