libTriton  version 0.4 build 1353
SymbolicExpression

Table of Contents

[python api] All information about the SymbolicExpression python object.

Description


This object is used to represent a symbolic expression.

>>> from triton import *
>>> setArchitecture(ARCH.X86_64)
>>> opcodes = "\x48\x31\xD0"
>>> inst = Instruction()
>>> inst.setOpcodes(opcodes)
>>> inst.setAddress(0x400000)
>>> inst.updateContext(Register(REG.RAX, 12345))
>>> inst.updateContext(Register(REG.RDX, 67890))
>>> processing(inst)
>>> print inst
400000: xor rax, rdx
>>> for expr in inst.getSymbolicExpressions():
... print expr
...
ref!0 = (bvxor ((_ extract 63 0) (_ bv12345 64)) ((_ extract 63 0) (_ bv67890 64))) ; XOR operation
ref!1 = (_ bv0 1) ; Clears carry flag
ref!2 = (_ bv0 1) ; Clears overflow flag
ref!3 = (bvxor (bvxor (bvxor (bvxor (bvxor (bvxor (bvxor (bvxor (_ bv1 1) ((_ extract 0 0) [... skipped ...] ; Parity flag
ref!4 = (ite (= ((_ extract 63 63) ref!0) (_ bv1 1)) (_ bv1 1) (_ bv0 1)) ; Sign flag
ref!5 = (ite (= ((_ extract 63 0) ref!0) (_ bv0 64)) (_ bv1 1) (_ bv0 1)) ; Zero flag
ref!6 = (_ bv4194307 64) ; Program Counter
>>> expr_1 = inst.getSymbolicExpressions()[0]
>>> expr_1
<SymbolicExpression object at 0x7f93ddeb3b40>
>>> print expr_1
ref!0 = (bvxor ((_ extract 63 0) (_ bv12345 64)) ((_ extract 63 0) (_ bv67890 64))) ; XOR operation
>>> print expr_1.getId()
0
>>> ast = expr_1.getAst()
>>> ast
<AstNode object at 0x7f93ddeb3c00>
>>> print ast
(bvxor ((_ extract 63 0) (_ bv12345 64)) ((_ extract 63 0) (_ bv67890 64)))
>>> expr_1.isMemory()
False
>>> expr_1.isRegister()
True
>>> print expr_1.getOriginRegister()
rax:64 bv[63..0]

Python API - Methods of the SymbolicExpression class