libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
pathConstraint.cpp
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
10
11
12
13namespace triton {
14 namespace engines {
15 namespace symbolic {
16
18 this->tid = static_cast<triton::uint32>(-1);
19 }
20
21
23 this->branches = other.branches;
24 this->comment = other.comment;
25 this->tid = other.tid;
26 }
27
28
30 /* See #828: Release ownership before calling container destructor */
31 this->branches.clear();
32 }
33
34
36 this->branches = other.branches;
37 this->comment = other.comment;
38 this->tid = other.tid;
39 return *this;
40 }
41
42
44 if (pc == nullptr)
45 throw triton::exceptions::PathConstraint("PathConstraint::addBranchConstraint(): The PC node cannot be null.");
46 this->branches.push_back(std::make_tuple(taken, srcAddr, dstAddr, pc));
47 }
48
49
50 const std::vector<std::tuple<bool, triton::uint64, triton::uint64, triton::ast::SharedAbstractNode>>& PathConstraint::getBranchConstraints(void) const {
51 return this->branches;
52 }
53
54
56 for (auto it = this->branches.begin(); it != this->branches.end(); it++) {
57 if (std::get<0>(*it) == true)
58 return std::get<1>(*it);
59 }
60 throw triton::exceptions::PathConstraint("PathConstraint::getSourceAddress(): Something wrong, no branch.");
61 }
62
63
65 for (auto it = this->branches.begin(); it != this->branches.end(); it++) {
66 if (std::get<0>(*it) == true)
67 return std::get<2>(*it);
68 }
69 throw triton::exceptions::PathConstraint("PathConstraint::getTakenAddress(): Something wrong, no branch taken.");
70 }
71
72
74 for (auto it = this->branches.begin(); it != this->branches.end(); it++) {
75 if (std::get<0>(*it) == true)
76 return std::get<3>(*it);
77 }
78 throw triton::exceptions::PathConstraint("PathConstraint::getTakenPredicate(): Something wrong, no branch taken.");
79 }
80
81
83 if (this->branches.size() == 0)
84 throw triton::exceptions::PathConstraint("PathConstraint::isMultipleBranches(): Path Constraint is empty.");
85 else if (this->branches.size() == 1)
86 return false;
87 return true;
88 }
89
90
92 return this->tid;
93 }
94
95
97 this->tid = tid;
98 }
99
100
101 const std::string& PathConstraint::getComment(void) const {
102 return this->comment;
103 }
104
105
106 void PathConstraint::setComment(const std::string& comment) {
107 this->comment = comment;
108 }
109
110 }; /* symbolic namespace */
111 }; /* engines namespace */
112}; /*triton namespace */
TRITON_EXPORT triton::uint64 getTakenAddress(void) const
Returns the address of the taken branch.
TRITON_EXPORT void setComment(const std::string &comment)
Sets a comment to the path constraint.
TRITON_EXPORT const std::string & getComment(void) const
Returns the comment of the path constraint.
TRITON_EXPORT bool isMultipleBranches(void) const
Returns true if it is not a direct jump.
TRITON_EXPORT PathConstraint()
Constructor.
TRITON_EXPORT ~PathConstraint()
Destructor.
std::string comment
The comment of the path constraint.
TRITON_EXPORT triton::uint32 getThreadId(void) const
Returns the thread id of the constraint. Returns -1 if thread id is undefined.
triton::uint32 tid
The thread id of the constraint. -1 if it's undefined.
TRITON_EXPORT void setThreadId(triton::uint32 tid)
Sets the thread id of the constraint.
TRITON_EXPORT PathConstraint & operator=(const PathConstraint &other)
Operator.
TRITON_EXPORT triton::uint64 getSourceAddress(void) const
Returns the address of the jump instruction (eg.: "A: jz B", returns A).
TRITON_EXPORT void addBranchConstraint(bool taken, triton::uint64 srdAddr, triton::uint64 dstAddr, const triton::ast::SharedAbstractNode &pc)
Adds a branch to the path constraint.
TRITON_EXPORT triton::ast::SharedAbstractNode getTakenPredicate(void) const
Returns the predicate of the taken branch.
std::vector< std::tuple< bool, triton::uint64, triton::uint64, triton::ast::SharedAbstractNode > > branches
The branches constraints.
TRITON_EXPORT const std::vector< std::tuple< bool, triton::uint64, triton::uint64, triton::ast::SharedAbstractNode > > & getBranchConstraints(void) const
Returns the branch constraints.
The exception class used by path constraints.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition ast.hpp:59
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
The Triton namespace.