rizin/r2-bindings/python/test-r_anal.py
pancake 1e52015eee Add px[QW], fix segmented io and handle ! pipes
Handle `!` with r_core_cmd_str_pipe
Fix 'afl' output
Add help for 'px' command
Add pxQ and pxW to show one word per line
Fix segmented io with maps and sections
Some test cases got fixed
Add test-r_anal.py
2012-10-25 12:55:28 +02:00

37 lines
932 B
Python
Executable file

from r2 import r_core
rc = r_core.RCore()
rc.file_open("/bin/ls", 0, 0)
rc.bin_load("")
rc.anal_all()
funcs = rc.anal.get_fcns()
for f in funcs:
blocks = f.get_bbs()
print("+" + (72 * "-"))
print("| FUNCTION: %s @ 0x%x" % (f.name, f.addr))
print("| (%d blocks)" % (len (blocks)))
print("+" + (72 * "-"))
for b in blocks:
print("---[ Block @ 0x%x ]---" % (b.addr))
print(" | size: %d" % (b.size))
print(" | jump: 0x%x" % (b.jump))
print(" | conditional: %d" % (b.conditional))
print(" | return: %d" % (b.returnbb))
end_byte = b.addr + b.size
cur_byte = b.addr
while (cur_byte < end_byte):
#anal_op = rc.op_anal(cur_byte)
asm_op = rc.disassemble(cur_byte)
if asm_op.inst_len == 0:
print("Bogus op")
break
#print("0x%x %s" % (anal_op.addr, anal_op.mnemonic))
print("0x%x %s %s" % (cur_byte, asm_op.buf_hex, asm_op.buf_asm))
cur_byte += asm_op.inst_len