ROSE 2.15.0
Loading...
Searching...
No Matches
SymbolicSemantics.h
1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_SymbolicSemantics_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_SymbolicSemantics_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/BasicTypes.h>
6
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/Formatter.h>
8#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/FrameState.h>
9#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryCellList.h>
10#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryCellMap.h>
11#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryState.h>
12#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/Merger.h>
13#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/RegisterStateGeneric.h>
14#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/RiscOperators.h>
15#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/State.h>
16#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/SValue.h>
17#include <Rose/BinaryAnalysis/SymbolicExpression.h>
18
19#include <Cxx_GrammarSerialization.h>
20
21#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
22#include <boost/serialization/access.hpp>
23#include <boost/serialization/base_object.hpp>
24#include <boost/serialization/export.hpp>
25#include <boost/serialization/set.hpp>
26#endif
27
28#include <inttypes.h>
29#include <map>
30#include <vector>
31
32namespace Rose {
33namespace BinaryAnalysis {
34namespace InstructionSemantics {
35
55namespace SymbolicSemantics {
56
63using InsnSet = std::set<SgAsmInstruction*>;
64
66// Boolean flags
68
70namespace AllowSideEffects {
71 enum Flag {NO, YES};
72}
73
74
76// Merging symbolic values
78
81
84 size_t setSizeLimit_ = 1;
85protected:
86 Merger();
87
88public:
90 typedef MergerPtr Ptr;
91
93 static Ptr instance();
94
96 static Ptr instance(size_t);
97
109 size_t setSizeLimit() const { return setSizeLimit_; }
110 void setSizeLimit(size_t n) { setSizeLimit_ = n; }
112};
113
114
115
117// Semantic values
119
122
125public:
126 SymbolicExpression::Formatter expr_formatter;
127};
128
198public:
201
203 using Ptr = SValuePtr;
204
205protected:
208
211 InsnSet defs;
212
214 // Serialization
215#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
216private:
217 friend class boost::serialization::access;
218
219 template<class S>
220 void serialize(S &s, const unsigned /*version*/) {
221 roseAstSerializationRegistration(s); // "defs" has SgAsmInstruction ASTs
222 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
223 s & BOOST_SERIALIZATION_NVP(expr);
224 s & BOOST_SERIALIZATION_NVP(defs);
225 }
226#endif
227
229 // Real constructors
230protected:
231 SValue(); // needed for serialization
232 explicit SValue(size_t nbits);
233 SValue(size_t nbits, uint64_t number);
235
237 // Static allocating constructors
238public:
241
243 static SValuePtr instance_bottom(size_t nbits);
244
246 static SValuePtr instance_undefined(size_t nbits);
247
249 static SValuePtr instance_unspecified(size_t nbits);
250
252 static SValuePtr instance_integer(size_t nbits, uint64_t value);
253
256
258 // Virtual allocating constructors
259public:
260 BaseSemantics::SValuePtr bottom_(size_t nbits) const override;
261 BaseSemantics::SValuePtr undefined_(size_t nbits) const override;
262 BaseSemantics::SValuePtr unspecified_(size_t nbits) const override;
263 BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const override;
264 BaseSemantics::SValuePtr boolean_(bool value) const override;
265 BaseSemantics::SValuePtr copy(size_t new_width=0) const override;
266
269 const SmtSolverPtr&) const override;
270
272 // Dynamic pointer casts
273public:
276
278 // Override virtual methods...
279public:
280 bool isBottom() const override;
281 void print(std::ostream&, BaseSemantics::Formatter&) const override;
282 void hash(Combinatorics::Hasher&) const override;
283
284protected: // when implementing use these names; but when calling, use the camelCase names
286 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
288 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
289
290 // It's not possible to change the size of a symbolic expression in place. That would require that we recursively change
291 // the size of the SymbolicExpression, which might be shared with many unrelated values whose size we don't want to affect.
292 void set_width(size_t nbits) override;
293 bool is_number() const override;
294 uint64_t get_number() const override;
295 std::string get_comment() const override;
296 void set_comment(const std::string&) const override;
297
299 // Additional methods first declared in this class...
300public:
308 virtual SValuePtr substitute(const SValuePtr &from, const SValuePtr &to, const SmtSolverPtr &solver) const;
309
316 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2, const InsnSet &set3);
317 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2);
318 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1);
319 virtual void defined_by(SgAsmInstruction *insn);
325 virtual const ExprPtr& get_expression() const;
326
329 virtual void set_expression(const ExprPtr &new_expr);
330 virtual void set_expression(const SValuePtr &source);
347 virtual const InsnSet& get_defining_instructions() const;
348
354 virtual size_t add_defining_instructions(const InsnSet &to_add);
355 virtual size_t add_defining_instructions(const SValuePtr &source);
364 virtual void set_defining_instructions(const InsnSet &new_defs);
365 virtual void set_defining_instructions(const SValuePtr &source);
368};
369
370
372// Register state
374
376typedef BaseSemantics::RegisterStateGenericPtr RegisterStatePtr;
377
378
380// Frame state
382
384typedef BaseSemantics::FrameStatePtr FrameStatePtr;
385
386
388// List-based Memory state
390
392typedef boost::shared_ptr<class MemoryListState> MemoryListStatePtr;
393
411public:
414
417
420 public:
422 protected:
423 CellCompressor() {}
424 public:
425 virtual ~CellCompressor() {}
426
428 virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
430 const BaseSemantics::CellList &cells) = 0;
431 };
432
447 public:
448 static Ptr instance();
451 const BaseSemantics::CellList &cells) override;
452 };
453
456 public:
457 static Ptr instance();
460 const BaseSemantics::CellList &cells) override;
461 };
462
467 CellCompressor::Ptr mccarthy_;
468 CellCompressor::Ptr simple_;
469 protected:
471 public:
472 static Ptr instance();
475 const BaseSemantics::CellList &cells) override;
476 };
477
482 public:
483 static Ptr instance();
486 const BaseSemantics::CellList &cells) override;
487 };
488
489private:
490 CellCompressor::Ptr cellCompressor_; // Callback when a memory read aliases multiple memory cells.
491
493 // Serialization
494#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
495private:
496 friend class boost::serialization::access;
497
498 template<class S>
499 void serialize(S &s, const unsigned /*version*/) {
500 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
501 }
502#endif
503
504
506 // Real constructors
507protected:
508 MemoryListState(); // for serialization
509 explicit MemoryListState(const BaseSemantics::MemoryCellPtr &protocell);
510 MemoryListState(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
511 MemoryListState(const MemoryListState &other);
512
514 // Static allocating constructors
515public:
518
521 static MemoryListStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
522
525
527 // Virtual constructors
528public:
532 const BaseSemantics::SValuePtr &valProtoval) const override;
533
536
539
541 // Dynamic pointer casts
542public:
546
548 // Methods we inherited
549public:
555 BaseSemantics::RiscOperators *valOps) override;
556
562 BaseSemantics::RiscOperators *valOps) override;
563
569
570protected:
571 BaseSemantics::SValuePtr readOrPeekMemory(const BaseSemantics::SValuePtr &address,
572 const BaseSemantics::SValuePtr &dflt,
575 AllowSideEffects::Flag allowSideEffects);
576
578 // Methods first declared in this class
579public:
589 // Deprecated [Robb Matzke 2021-12-15]
590 CellCompressor::Ptr get_cell_compressor() const ROSE_DEPRECATED("use cellCompressor");
591 void set_cell_compressor(const CellCompressor::Ptr&) ROSE_DEPRECATED("use cellCompressor");
592};
593
594
596// Map-based Memory state
598
600typedef boost::shared_ptr<class MemoryMapState> MemoryMapStatePtr;
601
619class MemoryMapState: public BaseSemantics::MemoryCellMap {
620public:
623
626
628 // Serialization
629#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
630private:
631 friend class boost::serialization::access;
632
633 template<class S>
634 void serialize(S &s, const unsigned /*version*/) {
635 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
636 }
637#endif
638
640 // Real constructors
641protected:
642 MemoryMapState(); // for serialization
643
644 explicit MemoryMapState(const BaseSemantics::MemoryCellPtr &protocell);
645
646 MemoryMapState(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
647
649 // Static allocating constructors
650public:
653
656 static MemoryMapStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
657
660
662 // Virtual constructors
663public:
667 const BaseSemantics::SValuePtr &valProtoval) const override;
668
671
674
676 // Dynamic pointer casts
677public:
681
683 // Methods we override from the super class (documented in the super class)
684public:
686};
687
688
689
691// Default memory state
693
694// List-base memory was the type originally used by this domain. We must keep it that way because some analysis, including 3rd
695// party, assumes that the state is list-based. New analysis can use the map-based state by instantiating it when the symbolic
696// risc operators are constructed.
698typedef MemoryListStatePtr MemoryStatePtr;
699
701// Complete state
703
705typedef BaseSemantics::StatePtr StatePtr;
706
707
709// RISC operators
711
718
725
727typedef boost::shared_ptr<class RiscOperators> RiscOperatorsPtr;
728
749public:
752
755
756protected:
757 bool omit_cur_insn; // if true, do not include cur_insn as a definer
758 DefinersMode computingDefiners_; // whether to track definers (instruction VAs) of SValues
759 WritersMode computingMemoryWriters_; // whether to track writers (instruction VAs) to memory.
760 WritersMode computingRegisterWriters_; // whether to track writers (instruction VAs) to registers.
761 uint64_t trimThreshold_; // max size of expressions (zero means no maximimum)
762 bool reinterpretMemoryReads_; // cast data to unsigned integer when reading from memory
763 bool reinterpretRegisterReads_; // cast data to unsigned integer when reading from registers
764 size_t nTrimmed_ = 0; // number of expressions trimmed down to a new variable
765
766
768 // Serialization
769#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
770private:
771 friend class boost::serialization::access;
772
773 template<class S>
774 void serialize(S &s, const unsigned /*version*/) {
775 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
776 s & BOOST_SERIALIZATION_NVP(omit_cur_insn);
777 s & BOOST_SERIALIZATION_NVP(computingDefiners_);
778 s & BOOST_SERIALIZATION_NVP(computingMemoryWriters_);
779 s & BOOST_SERIALIZATION_NVP(computingRegisterWriters_);
780 s & BOOST_SERIALIZATION_NVP(trimThreshold_);
781 }
782#endif
783
785 // Real constructors
786protected:
787 RiscOperators(); // for serialization
788
789 explicit RiscOperators(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver);
790
791 explicit RiscOperators(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver);
792
794 // Static allocating constructors
795public:
797
801
805 const SmtSolverPtr &solver = SmtSolverPtr());
806
810
812 // Virtual constructors
813public:
815 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
816
818 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
819
821 // Dynamic pointer casts
822public:
826
828 // Inherited methods for constructing values.
829public:
831 BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) override;
832
834 // New methods for constructing values, so we don't have to write so many SValue::promote calls in the RiscOperators
835 // implementations.
836 SValuePtr svalueExpr(const ExprPtr &expr, const InsnSet &defs=InsnSet());
837
838protected:
839 SValuePtr svalueUndefined(size_t nbits);
840 SValuePtr svalueBottom(size_t nbits);
841 SValuePtr svalueUnspecified(size_t nbits);
842 SValuePtr svalueNumber(size_t nbits, uint64_t value);
843 SValuePtr svalueBoolean(bool b);
844
846 // Configuration properties
847public:
848
866 void computingDefiners(DefinersMode m) { computingDefiners_ = m; }
867 DefinersMode computingDefiners() const { return computingDefiners_; }
888 void computingMemoryWriters(WritersMode m) { computingMemoryWriters_ = m; }
889 WritersMode computingMemoryWriters() const { return computingMemoryWriters_; }
913 void computingRegisterWriters(WritersMode m) { computingRegisterWriters_ = m; }
914 WritersMode computingRegisterWriters() const { return computingRegisterWriters_; }
917 // Used internally to control whether cur_insn should be omitted from the list of definers.
918 bool getset_omit_cur_insn(bool b) { bool retval = omit_cur_insn; omit_cur_insn=b; return retval; }
919
926 void trimThreshold(uint64_t n) { trimThreshold_ = n; }
927 uint64_t trimThreshold() const { return trimThreshold_; }
936 size_t nTrimmed() const { return nTrimmed_; }
937 void nTrimmed(size_t n) { nTrimmed_ = n; }
947 bool reinterpretMemoryReads() const { return reinterpretMemoryReads_; }
948 void reinterpretMemoryReads(bool b) { reinterpretMemoryReads_ = b; }
949 bool reinterpretRegisterReads() const { return reinterpretRegisterReads_; }
950 void reinterpretRegisterReads(bool b) { reinterpretRegisterReads_ = b; }
954 // Methods first defined at this level of the class hierarchy
955public:
1017 virtual void substitute(const SValuePtr &from, const SValuePtr &to);
1018
1024
1030
1035
1037 // Override methods from base class. These are the RISC operators that are invoked by a Dispatcher.
1038public:
1039 void interrupt(int majr, int minr) override;
1041 const BaseSemantics::SValuePtr &b_) override;
1043 const BaseSemantics::SValuePtr &b_) override;
1045 const BaseSemantics::SValuePtr &b_) override;
1048 size_t begin_bit, size_t end_bit) override;
1050 const BaseSemantics::SValuePtr &b_) override;
1054 const BaseSemantics::SValuePtr &sa_) override;
1056 const BaseSemantics::SValuePtr &sa_) override;
1058 const BaseSemantics::SValuePtr &sa_) override;
1060 const BaseSemantics::SValuePtr &sa_) override;
1062 const BaseSemantics::SValuePtr &sa_) override;
1065 const BaseSemantics::SValuePtr &a_,
1066 const BaseSemantics::SValuePtr &b_,
1067 IteStatus&) override;
1069 BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override;
1071 const BaseSemantics::SValuePtr &b_) override;
1073 const BaseSemantics::SValuePtr &b_,
1074 const BaseSemantics::SValuePtr &c_,
1075 BaseSemantics::SValuePtr &carry_out/*out*/) override;
1078 const BaseSemantics::SValuePtr &b_) override;
1080 const BaseSemantics::SValuePtr &b_) override;
1082 const BaseSemantics::SValuePtr &b_) override;
1084 const BaseSemantics::SValuePtr &b_) override;
1086 const BaseSemantics::SValuePtr &b_) override;
1088 const BaseSemantics::SValuePtr &b_) override;
1089
1093
1094 template<class FloatOp>
1096 fpBinaryOp(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b, FloatOp operation);
1097
1103
1105 SgAsmFloatType *retType) override;
1108 const BaseSemantics::SValuePtr &dflt) override;
1110 const BaseSemantics::SValuePtr &dflt) override;
1113 const BaseSemantics::SValuePtr &addr,
1114 const BaseSemantics::SValuePtr &dflt,
1115 const BaseSemantics::SValuePtr &cond) override;
1117 const BaseSemantics::SValuePtr &addr,
1118 const BaseSemantics::SValuePtr &dflt) override;
1120 const BaseSemantics::SValuePtr &addr,
1121 const BaseSemantics::SValuePtr &data,
1122 const BaseSemantics::SValuePtr &cond) override;
1123
1124 BaseSemantics::SValuePtr readLocal(size_t index) override;
1125 void writeLocal(size_t index, const BaseSemantics::SValuePtr &value) override;
1126
1128 void pushOperand(const BaseSemantics::SValuePtr &value) override;
1129
1130public:
1131 BaseSemantics::SValuePtr readOrPeekMemory(RegisterDescriptor segreg,
1132 const BaseSemantics::SValuePtr &addr,
1133 const BaseSemantics::SValuePtr &dflt,
1134 AllowSideEffects::Flag);
1135};
1136
1137} // namespace
1138} // namespace
1139} // namespace
1140} // namespace
1141
1142#include <Rose/BinaryAnalysis/InstructionSemantics/SymbolicSemantics.tpp>
1143
1144#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
1149#endif
1150
1151#endif
1152#endif
Base class for most instruction semantics RISC operators.
Base class for semantics machine states.
Definition State.h:47
Functor for handling a memory read whose address matches more than one memory cell.
SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps, const BaseSemantics::CellList &cells) override
Compress the cells into a single value.
Functor for handling a memory read whose address matches more than one memory cell.
SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps, const BaseSemantics::CellList &cells) override
Compress the cells into a single value.
Functor for handling a memory read whose address matches more than one memory cell.
SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps, const BaseSemantics::CellList &cells) override
Compress the cells into a single value.
Functor for handling a memory read whose address matches more than one memory cell.
SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps, const BaseSemantics::CellList &cells) override
Compress the cells into a single value.
Functor for handling a memory read that found more than one cell that might alias the requested addre...
virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps, const BaseSemantics::CellList &cells)=0
Compress the cells into a single value.
BaseSemantics::MemoryStatePtr create(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const override
Virtual constructor.
static MemoryListStatePtr instance(const MemoryListStatePtr &other)
Instantiates a new deep copy of an existing state.
void writeMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &value, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) override
Write a byte to memory.
static MemoryListStatePtr instance(const BaseSemantics::MemoryCellPtr &protocell)
Instantiates a new memory state having specified prototypical cells and value.
static MemoryListStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
Instantiates a new memory state having specified prototypical value.
BaseSemantics::SValuePtr readMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) override
Read a byte from memory.
static MemoryListStatePtr promote(const BaseSemantics::AddressSpacePtr &)
Recasts a base pointer to a symbolic memory state.
CellCompressor::Ptr cellCompressor() const
Callback for handling a memory read whose address matches more than one memory cell.
BaseSemantics::MemoryStatePtr create(const BaseSemantics::MemoryCellPtr &protocell) const override
Virtual constructor.
BaseSemantics::AddressSpacePtr clone() const override
Virtual copy constructor.
BaseSemantics::SValuePtr peekMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) override
Read a byte from memory with no side effects.
void cellCompressor(const CellCompressor::Ptr &)
Callback for handling a memory read whose address matches more than one memory cell.
BaseSemantics::AddressSpacePtr clone() const override
Virtual copy constructor.
static MemoryMapStatePtr instance(const BaseSemantics::MemoryCellPtr &protocell)
Instantiates a new memory state having specified prototypical cells and value.
virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::MemoryCellPtr &protocell) const
Virtual constructor.
CellKey generateCellKey(const BaseSemantics::SValuePtr &addr_) const override
Generate a cell lookup key.
static MemoryMapStatePtr promote(const BaseSemantics::AddressSpacePtr &)
Recasts a base pointer to a symbolic memory state.
static MemoryMapStatePtr instance(const MemoryMapStatePtr &other)
Instantiates a new deep copy of an existing state.
BaseSemantics::MemoryStatePtr create(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const override
Virtual constructor.
static MemoryMapStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
Instantiates a new memory state having specified prototypical value.
MergerPtr Ptr
Shared-ownership pointer for a Merger object.
Defines RISC operators for the SymbolicSemantics domain.
BaseSemantics::SValuePtr unsignedExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override
Extend (or shrink) operand a so it is nbits wide by adding or removing high-order bits.
BaseSemantics::SValuePtr fpDivide(const BaseSemantics::SValuePtr &lhs, const BaseSemantics::SValuePtr &rhs) override
Divide one floating-point value by another.
static RiscOperatorsPtr instanceFromProtoval(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object with specified prototypical values.
void computingDefiners(DefinersMode m)
Property: Track which instructions define a semantic value.
BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) override
Returns a number of the specified bit width.
BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Rotate bits to the left.
BaseSemantics::SValuePtr fpMultiply(const BaseSemantics::SValuePtr &lhs, const BaseSemantics::SValuePtr &rhs) override
Multiply two floating-point values.
BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted right logically (no sign bit).
static SgAsmFloatType * sgIsIeee754(SgAsmType *)
Tests whether a SgAsmType is an IEEE-754 floating-point type.
BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Adds two integers of equal size.
BaseSemantics::SValuePtr fpSubtract(const BaseSemantics::SValuePtr &lhs, const BaseSemantics::SValuePtr &rhs) override
Subtract one floating-point value from another.
void computingMemoryWriters(WritersMode m)
Property: Track which instructions write to each memory location.
BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Divides two unsigned values.
BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a_) override
Determines whether a value is equal to zero.
void interrupt(int majr, int minr) override
Unconditionally raise an interrupt.
BaseSemantics::SValuePtr invert(const BaseSemantics::SValuePtr &a_) override
One's complement.
size_t nTrimmed() const
Property: Number of symbolic expressions trimmed.
BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a_, size_t begin_bit, size_t end_bit) override
Extracts bits from a value.
BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise AND of two values.
BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise OR of two values.
BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Rotate bits to the right.
BaseSemantics::SValuePtr boolean_(bool b) override
Returns a Boolean value.
BaseSemantics::SValuePtr iteWithStatus(const BaseSemantics::SValuePtr &sel_, const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_, IteStatus &) override
If-then-else with status.
BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted right arithmetically (with sign bit).
BaseSemantics::SValuePtr fpConvert(const BaseSemantics::SValuePtr &, BaseSemantics::ValueKind) override
Convert from one floating-point type to another.
WritersMode computingRegisterWriters() const
Property: Track latest writer to each register.
BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Divides two signed values.
BaseSemantics::SValuePtr fpFromInteger(const BaseSemantics::SValuePtr &, BaseSemantics::ValueKind) override
Constructs a floating-point value from an integer value.
BaseSemantics::SValuePtr peekMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt) override
Read memory without side effects.
BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a_) override
Returns position of least significant set bit; zero when no bits are set.
BaseSemantics::SValuePtr readRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) override
Reads a value from a register.
BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::StatePtr &, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual allocating constructor.
BaseSemantics::SValuePtr reinterpret(const BaseSemantics::SValuePtr &, SgAsmType *) override
Reinterpret an expression as a different type.
BaseSemantics::SValuePtr readLocal(size_t index) override
Reads a value from the local variable table in the current frame.
virtual BaseSemantics::SValuePtr filterResult(const BaseSemantics::SValuePtr &)
Filters results from RISC operators.
static RiscOperatorsPtr promote(const BaseSemantics::RiscOperatorsPtr &)
Run-time promotion of a base RiscOperators pointer to symbolic operators.
void nTrimmed(size_t n)
Property: Number of symbolic expressions trimmed.
void computingRegisterWriters(WritersMode m)
Property: Track latest writer to each register.
void reinterpretMemoryReads(bool b)
Property: Reinterpret data as unsigned integers when reading from memory or registers.
BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise XOR of two values.
static RiscOperatorsPtr instanceFromState(const BaseSemantics::StatePtr &, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object with specified state.
void trimThreshold(uint64_t n)
Property: Maximum size of expressions.
BaseSemantics::SValuePtr fpModulo(const BaseSemantics::SValuePtr &lhs, const BaseSemantics::SValuePtr &rhs) override
Computes the floating-point remainder of a divided by b.
void writeRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &a_) override
Writes a value to a register.
BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted left.
void pushOperand(const BaseSemantics::SValuePtr &value) override
Pushes a value to the Frame Operand Stack.
BaseSemantics::SValuePtr popOperand() override
Pops a value from the Frame Operand Stack.
BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Calculates modulo with unsigned values.
BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Calculates modulo with signed values.
bool reinterpretRegisterReads() const
Property: Reinterpret data as unsigned integers when reading from memory or registers.
BaseSemantics::SValuePtr addWithCarries(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_, const BaseSemantics::SValuePtr &c_, BaseSemantics::SValuePtr &carry_out) override
Add two values of equal size and a carry bit.
BaseSemantics::SValuePtr fpToInteger(const BaseSemantics::SValuePtr &, BaseSemantics::ValueKind) override
Converts a floating-point value to an integer value.
BaseSemantics::SValuePtr mostSignificantSetBit(const BaseSemantics::SValuePtr &a_) override
Returns position of most significant set bit; zero when no bits are set.
WritersMode computingMemoryWriters() const
Property: Track which instructions write to each memory location.
virtual void substitute(const SValuePtr &from, const SValuePtr &to)
Substitute all occurrences of from with to in the current state.
DefinersMode computingDefiners() const
Property: Track which instructions define a semantic value.
BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a_) override
Two's complement.
void reinterpretRegisterReads(bool b)
Property: Reinterpret data as unsigned integers when reading from memory or registers.
BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual allocating constructor.
BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override
Sign extends a value.
BaseSemantics::SValuePtr readMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, const BaseSemantics::SValuePtr &cond) override
Reads a value from memory.
void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) override
Writes a value to memory.
BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Multiply two unsigned values.
BaseSemantics::SValuePtr concat(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Concatenates the bits of two values.
bool reinterpretMemoryReads() const
Property: Reinterpret data as unsigned integers when reading from memory or registers.
BaseSemantics::SValuePtr peekRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) override
Obtain a register value without side effects.
uint64_t trimThreshold() const
Property: Maximum size of expressions.
BaseSemantics::SValuePtr fpAdd(const BaseSemantics::SValuePtr &lhs, const BaseSemantics::SValuePtr &rhs) override
Add two floating-point values.
BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Multiplies two signed values.
static RiscOperatorsPtr instanceFromRegisters(const RegisterDictionaryPtr &, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object and configures it to use semantic values and states that are ...
virtual SymbolicExpression::Type sgTypeToSymbolicType(SgAsmType *)
Convert a SgAsmType to a symbolic type.
Type of values manipulated by the SymbolicSemantics domain.
virtual const InsnSet & get_defining_instructions() const
Returns the set of instructions that defined this value.
virtual size_t add_defining_instructions(const InsnSet &to_add)
Adds definitions to the list of defining instructions.
static SValuePtr instance()
Instantiate a new prototypical value.
BaseSemantics::SValuePtr undefined_(size_t nbits) const override
Create a new undefined semantic value.
virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2)
Adds instructions to the list of defining instructions.
static SValuePtr instance_integer(size_t nbits, uint64_t value)
Instantiate a new concrete value.
virtual void set_expression(const ExprPtr &new_expr)
Changes the expression stored in the value.
static SValuePtr promote(const BaseSemantics::SValuePtr &)
Promote a base value to a SymbolicSemantics value.
virtual void defined_by(SgAsmInstruction *insn)
Adds instructions to the list of defining instructions.
void hash(Combinatorics::Hasher &) const override
Hash this semantic value.
static SValuePtr instance_symbolic(const SymbolicExpression::Ptr &value)
Instantiate a new symbolic value.
BaseSemantics::SValuePtr bottom_(size_t nbits) const override
Data-flow bottom value.
Sawyer::Optional< BaseSemantics::SValuePtr > createOptionalMerge(const BaseSemantics::SValuePtr &other, const BaseSemantics::MergerPtr &, const SmtSolverPtr &) const override
Possibly create a new value by merging two existing values.
bool must_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual API.
bool isBottom() const override
Determines whether a value is a data-flow bottom.
static SValuePtr instance_undefined(size_t nbits)
Instantiate a new undefined value of specified width.
BaseSemantics::SValuePtr copy(size_t new_width=0) const override
Create a new value from an existing value, changing the width if new_width is non-zero.
BaseSemantics::SValuePtr unspecified_(size_t nbits) const override
Create a new unspecified semantic value.
BaseSemantics::SValuePtr boolean_(bool value) const override
Create a new, Boolean value.
virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2, const InsnSet &set3)
Adds instructions to the list of defining instructions.
static SValuePtr instance_unspecified(size_t nbits)
Instantiate a new unspecified value of specified width.
virtual size_t add_defining_instructions(const SValuePtr &source)
Adds definitions to the list of defining instructions.
virtual void set_defining_instructions(SgAsmInstruction *insn)
Set defining instructions.
virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1)
Adds instructions to the list of defining instructions.
std::string get_comment() const override
Some subclasses support the ability to add comments to values.
BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const override
Create a new concrete semantic value.
virtual size_t add_defining_instructions(SgAsmInstruction *insn)
Adds definitions to the list of defining instructions.
static SValuePtr instance_bottom(size_t nbits)
Instantiate a new data-flow bottom value of specified width.
bool may_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual API.
virtual void set_defining_instructions(const InsnSet &new_defs)
Set defining instructions.
void print(std::ostream &, BaseSemantics::Formatter &) const override
Print a value to a stream using default format.
virtual void set_expression(const SValuePtr &source)
Changes the expression stored in the value.
virtual const ExprPtr & get_expression() const
Returns the expression stored in this value.
virtual SValuePtr substitute(const SValuePtr &from, const SValuePtr &to, const SmtSolverPtr &solver) const
Substitute one value for another throughout a value.
void set_comment(const std::string &) const override
Some subclasses support the ability to add comments to values.
virtual void set_defining_instructions(const SValuePtr &source)
Set defining instructions.
Describes (part of) a physical CPU register.
Controls formatting of expression trees when printing.
Interior node of an expression tree for instruction semantics.
Leaf node of an expression tree for instruction semantics.
Base class for symbolic expression nodes.
Holds a value or nothing.
Definition Optional.h:54
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
Floating point types.
Base class for machine instructions.
Base class for binary types.
Base classes for instruction semantics.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
boost::shared_ptr< MemoryCell > MemoryCellPtr
Shared-ownership pointer to a memory cell.
std::list< MemoryCellPtr > CellList
List of memory cells.
Definition MemoryCell.h:280
ValueKind
Kind of an SValue for emulating JVM and CIL instructions.
Definition SValue.h:28
boost::shared_ptr< class RegisterStateGeneric > RegisterStateGenericPtr
Shared-ownership pointer to generic register states.
boost::shared_ptr< AddressSpace > AddressSpacePtr
Shared-ownership pointer for AddressSpace objects.
boost::shared_ptr< FrameState > FrameStatePtr
Shared-ownership pointer to a frame state.
WritersMode
How to update the list of writers stored at each abstract location.
boost::shared_ptr< class MemoryMapState > MemoryMapStatePtr
Shared-ownership pointer to symbolic memory state.
boost::shared_ptr< class MemoryListState > MemoryListStatePtr
Shared-ownership pointer for symbolic list-based memory state.
Sawyer::SharedPointer< class SValue > SValuePtr
Shared-ownership pointer for symbolic semantic value.
DefinersMode
How to update the list of definers stored in each semantic value.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to symbolic RISC operations.
Sawyer::SharedPointer< Interior > InteriorPtr
Reference counting pointer.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
Sawyer::SharedPointer< Leaf > LeafPtr
Reference counting pointer.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.
The ROSE library.