1 //! \file 2 /* 3 ** Copyright (C) - Triton 4 ** 5 ** This program is under the terms of the Apache License 2.0. 6 */ 7 8 #ifndef TRITON_PATHCONSTRAINT_H 9 #define TRITON_PATHCONSTRAINT_H 10 11 #include <tuple> 12 #include <vector> 13 14 #include <triton/ast.hpp> 15 #include <triton/dllexport.hpp> 16 #include <triton/tritonTypes.hpp> 17 18 19 20 //! The Triton namespace 21 namespace triton { 22 /*! 23 * \addtogroup triton 24 * @{ 25 */ 26 27 //! The Engines namespace 28 namespace engines { 29 /*! 30 * \ingroup triton 31 * \addtogroup engines 32 * @{ 33 */ 34 35 //! The Symbolic Execution namespace 36 namespace symbolic { 37 /*! 38 * \ingroup engines 39 * \addtogroup symbolic 40 * @{ 41 */ 42 43 /*! \class PathConstraint 44 \brief The path constraint class. */ 45 class PathConstraint { 46 protected: 47 /*! 48 * \brief The branches constraints 49 * \details Vector of `<flag, source addr, dst addr, pc>`, `flag` is set to true if the branch is taken according the concrete 50 * execution. The source address is the location of the branch instruction and the destination address is the destination of the jump. 51 * E.g: `"0x11223344: jne 0x55667788"`, 0x11223344 is the source address and 0x55667788 is the destination if and only if the 52 * branch is taken, otherwise the destination is the next instruction address. The SharedAbstractNode is the expression which need to be 53 * true to take the branch. 54 */ 55 std::vector<std::tuple<bool, triton::uint64, triton::uint64, triton::ast::SharedAbstractNode>> branches; 56 57 public: 58 //! Constructor. 59 TRITON_EXPORT PathConstraint(); 60 61 //! Constructor by copy. 62 TRITON_EXPORT PathConstraint(const PathConstraint &other); 63 64 //! Destructor. 65 TRITON_EXPORT ~PathConstraint(); 66 67 //! Operator. 68 TRITON_EXPORT PathConstraint& operator=(const PathConstraint &other); 69 70 //! Adds a branch to the path constraint. 71 TRITON_EXPORT void addBranchConstraint(bool taken, triton::uint64 srdAddr, triton::uint64 dstAddr, const triton::ast::SharedAbstractNode& pc); 72 73 //! Returns the branch constraints. 74 TRITON_EXPORT const std::vector<std::tuple<bool, triton::uint64, triton::uint64, triton::ast::SharedAbstractNode>>& getBranchConstraints(void) const; 75 76 //! Returns the address of the taken branch. 77 TRITON_EXPORT triton::uint64 getTakenAddress(void) const; 78 79 //! Returns the predicate of the taken branch. 80 TRITON_EXPORT triton::ast::SharedAbstractNode getTakenPredicate(void) const; 81 82 //! Returns true if it is not a direct jump. 83 TRITON_EXPORT bool isMultipleBranches(void) const; 84 }; 85 86 /*! @} End of symbolic namespace */ 87 }; 88 /*! @} End of engines namespace */ 89 }; 90 /*! @} End of triton namespace */ 91 }; 92 93 #endif /* TRITON_PATHCONSTAINT_H */ 94