libTriton version 1.0 build 1590
Loading...
Searching...
No Matches
symbolicExpression.hpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
8#ifndef TRITON_SYMBOLICEXPRESSION_H
9#define TRITON_SYMBOLICEXPRESSION_H
10
11#include <memory>
12#include <string>
13
14#include <triton/ast.hpp>
15#include <triton/dllexport.hpp>
17#include <triton/register.hpp>
20
21
22
24namespace triton {
31 namespace engines {
39 namespace symbolic {
47
49 protected:
52
55
57 std::string comment;
58
61
63 std::string disassembly;
64
67
70
73
74 private:
76 TRITON_EXPORT std::string getBitvectorDefine(void) const;
77
79 TRITON_EXPORT std::string getArrayDefine(void) const;
80
81 public:
84
89 const std::string& comment="");
90
92 TRITON_EXPORT SymbolicExpression(const SymbolicExpression& other);
93
95 TRITON_EXPORT SymbolicExpression& operator=(const SymbolicExpression& other);
96
98 TRITON_EXPORT triton::usize getId(void) const;
99
101 TRITON_EXPORT bool isMemory(void) const;
102
104 TRITON_EXPORT bool isRegister(void) const;
105
107 TRITON_EXPORT bool isSymbolized(void) const;
108
110 TRITON_EXPORT triton::engines::symbolic::expression_e getType(void) const;
111
113 TRITON_EXPORT const triton::ast::SharedAbstractNode& getAst(void) const;
114
116 TRITON_EXPORT triton::ast::SharedAbstractNode getNewAst(void) const;
117
119 TRITON_EXPORT const std::string& getComment(void) const;
120
122 TRITON_EXPORT std::string getFormattedId(void) const;
123
125 TRITON_EXPORT std::string getFormattedComment(void) const;
126
128 TRITON_EXPORT std::string getFormattedExpression(void) const;
129
131 TRITON_EXPORT const triton::arch::MemoryAccess& getOriginMemory(void) const;
132
134 TRITON_EXPORT const triton::arch::Register& getOriginRegister(void) const;
135
137 TRITON_EXPORT void setAst(const triton::ast::SharedAbstractNode& node);
138
140 TRITON_EXPORT void setComment(const std::string& comment);
141
144
146 TRITON_EXPORT void setAddress(triton::uint64 address);
147
149 TRITON_EXPORT triton::uint64 getAddress(void) const;
150
152 TRITON_EXPORT void setOriginMemory(const triton::arch::MemoryAccess& mem);
153
155 TRITON_EXPORT void setOriginRegister(const triton::arch::Register& reg);
156
158 TRITON_EXPORT void writeBackDisassembly(const std::string& disassembly);
159
161 TRITON_EXPORT const std::string& getDisassembly(void);
162 };
163
165 using SharedSymbolicExpression = std::shared_ptr<triton::engines::symbolic::SymbolicExpression>;
166
168 using WeakSymbolicExpression = std::weak_ptr<triton::engines::symbolic::SymbolicExpression>;
169
171 TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const SymbolicExpression& symExpr);
172
174 TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const SymbolicExpression* symExpr);
175
177 };
179 };
181};
182
183#endif /* TRITON_SYMBOLICEXPRESSION_H */
This class is used to represent a memory access.
This class is used when an instruction has a register operand.
Definition register.hpp:44
TRITON_EXPORT bool isMemory(void) const
Returns true if the symbolic expression is assigned to a memory.
TRITON_EXPORT triton::usize getId(void) const
Returns the symbolic expression id.
TRITON_EXPORT triton::uint64 getAddress(void) const
Get the address of the symbolic expression, if any.
TRITON_EXPORT const std::string & getDisassembly(void)
Gets the instruction disassembly where the symbolic expression comes from.
triton::usize id
The symbolic expression id. This id is unique.
TRITON_EXPORT std::string getFormattedId(void) const
Returns the id as string of the symbolic expression according the mode of the AST representation.
TRITON_EXPORT std::string getFormattedComment(void) const
Returns the comment as string of the symbolic expression according the mode of the AST representation...
TRITON_EXPORT void setAddress(triton::uint64 address)
Sets the symbolic expression address.
TRITON_EXPORT void setAst(const triton::ast::SharedAbstractNode &node)
Sets a root node.
TRITON_EXPORT void setType(triton::engines::symbolic::expression_e type)
Sets the kind of the symbolic expression.
TRITON_EXPORT const triton::ast::SharedAbstractNode & getAst(void) const
Returns the SMT AST root node of the symbolic expression. This is the semantics.
TRITON_EXPORT std::string getFormattedExpression(void) const
Returns the symbolic expression representation as string according the mode of the AST representation...
TRITON_EXPORT const triton::arch::Register & getOriginRegister(void) const
Returns the origin register if kind is equal to triton::engines::symbolic::REGISTER_EXPRESSION,...
TRITON_EXPORT const std::string & getComment(void) const
Returns the comment of the symbolic expression.
bool isTainted
True if the symbolic expression is tainted.
TRITON_EXPORT const triton::arch::MemoryAccess & getOriginMemory(void) const
Returns the origin memory access if kind is equal to triton::engines::symbolic::MEMORY_EXPRESSION,...
TRITON_EXPORT void setComment(const std::string &comment)
Sets a comment to the symbolic expression.
std::string disassembly
The instruction disassembly where the symbolic expression comes from.
TRITON_EXPORT bool isSymbolized(void) const
Returns true if the expression contains a symbolic variable.
triton::arch::Register originRegister
The origin register if type is equal to triton::engines::symbolic::REG, REG_INVALID otherwise.
TRITON_EXPORT void setOriginRegister(const triton::arch::Register &reg)
Sets the origin register.
triton::uint64 address
The address of the instruction behind the symbolic expression. -1 if not defined.
TRITON_EXPORT triton::engines::symbolic::expression_e getType(void) const
Returns the type of the symbolic expression assignment.
triton::ast::SharedAbstractNode ast
The root node (AST) of the symbolic expression.
triton::arch::MemoryAccess originMemory
The origin memory address if type is equal to triton::engines::symbolic::MEM, invalid memory otherwis...
TRITON_EXPORT triton::ast::SharedAbstractNode getNewAst(void) const
Returns a new SMT AST root node of the symbolic expression. This new instance is a duplicate of the o...
TRITON_EXPORT bool isRegister(void) const
Returns true if the symbolic expression is assigned to a register.
TRITON_EXPORT void setOriginMemory(const triton::arch::MemoryAccess &mem)
Sets the origin memory acccess.
triton::engines::symbolic::expression_e type
The type of the symbolic expression assignment.
TRITON_EXPORT void writeBackDisassembly(const std::string &disassembly)
Writes back the instruction disassembly where the symbolic expression comes from.
std::string comment
The comment of the symbolic expression.
TRITON_EXPORT SymbolicExpression & operator=(const SymbolicExpression &other)
Operator.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition ast.hpp:59
std::weak_ptr< triton::engines::symbolic::SymbolicExpression > WeakSymbolicExpression
Weak Symbolic Expression.
expression_e
Type of symbolic expressions.
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition ast.hpp:40
std::ostream & operator<<(std::ostream &stream, const SymbolicExpression &symExpr)
Displays a symbolic expression.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
The Triton namespace.