Add __repr__ for capstone.CsInsn (#1625)
* Add __repr__ for capstone.CsInsn Currently, a `print(instruction)` displays a not very useful string like `<capstone.CsInsn object at 0x7f3759d88128>`. This PR enhances adds a `__repr__` magic method to the `capstone.CsInsn` class so it displays as follows: ``` <cs.CsInsn: address=0x5555555545fa, size=1, mnemonic=push, op_str=rbp> ``` * Update __init__.py
This commit is contained in:
parent
ff859083e5
commit
1b5014515d
|
@ -539,6 +539,9 @@ class CsInsn(object):
|
|||
self._raw.detail = ctypes.pointer(all_info.detail._type_())
|
||||
ctypes.memmove(ctypes.byref(self._raw.detail[0]), ctypes.byref(all_info.detail[0]), ctypes.sizeof(type(all_info.detail[0])))
|
||||
|
||||
def __repr__(self):
|
||||
return '<CsInsn 0x%x [%s]: %s %s>' % (self.address, self.bytes.hex(), self.mnemonic, self.op_str)
|
||||
|
||||
# return instruction's ID.
|
||||
@property
|
||||
def id(self):
|
||||
|
|
Loading…
Reference in New Issue