(cls, instr, fmt)
| 127 | |
| 128 | @classmethod |
| 129 | def format_instr(cls, instr, fmt): |
| 130 | uimm = ct.c_uint32(instr.imm).value |
| 131 | return (fmt.replace("%dst", "r%d" % (instr.dst)) |
| 132 | .replace("%src", "r%d" % (instr.src)) |
| 133 | .replace("%imm", "%d" % (instr.imm)) |
| 134 | .replace("%ibw", "0x%x" % (uimm)) |
| 135 | .replace("%sim", "%+d" % (instr.imm)) |
| 136 | .replace("%off", "%+d" % (instr.offset)) |
| 137 | .replace("%jmp", "%d" % (instr.offset + 1))) |
| 138 | |
| 139 | def test_func(self): |
| 140 | b = BPF(text=b""" |