ROSE 2.20.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
205 virtual ~SValue();
206
207protected:
210
213 InsnSet defs;
214
216 // Serialization
217#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
218private:
219 friend class boost::serialization::access;
220
221 template<class S>
222 void serialize(S &s, const unsigned /*version*/) {
223 roseAstSerializationRegistration(s); // "defs" has SgAsmInstruction ASTs
224 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
225 s & BOOST_SERIALIZATION_NVP(expr);
226 s & BOOST_SERIALIZATION_NVP(defs);
227 }
228#endif
229
231 // Real constructors
232protected:
233 SValue(); // needed for serialization
234 SValue(size_t nbits, uint64_t number);
235 explicit SValue(size_t nbits);
236 explicit SValue(ExprPtr expr);
237
238 SValue(const SValue&) = default;
239 SValue& operator=(const SValue&) = default;
240
242 // Static allocating constructors
243public:
246
248 static SValuePtr instance_bottom(size_t nbits);
249
251 static SValuePtr instance_undefined(size_t nbits);
252
254 static SValuePtr instance_unspecified(size_t nbits);
255
257 static SValuePtr instance_integer(size_t nbits, uint64_t value);
258
261
263 // Virtual allocating constructors
264public:
265 BaseSemantics::SValuePtr bottom_(size_t nbits) const override;
266 BaseSemantics::SValuePtr undefined_(size_t nbits) const override;
267 BaseSemantics::SValuePtr unspecified_(size_t nbits) const override;
268 BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const override;
269 BaseSemantics::SValuePtr boolean_(bool value) const override;
270 BaseSemantics::SValuePtr copy(size_t new_width=0) const override;
271
274 const SmtSolverPtr&) const override;
275
277 // Dynamic pointer casts
278public:
281
283 // Override virtual methods...
284public:
285 bool isBottom() const override;
286 void print(std::ostream&, BaseSemantics::Formatter&) const override;
287 void hash(Combinatorics::Hasher&) const override;
288
289protected: // when implementing use these names; but when calling, use the camelCase names
291 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
293 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
294
295 // It's not possible to change the size of a symbolic expression in place. That would require that we recursively change
296 // the size of the SymbolicExpression, which might be shared with many unrelated values whose size we don't want to affect.
297 void set_width(size_t nbits) override;
298 bool is_number() const override;
299 uint64_t get_number() const override;
300 std::string get_comment() const override;
301 void set_comment(const std::string&) const override;
302
304 // Additional methods first declared in this class...
305public:
313 virtual SValuePtr substitute(const SValuePtr &from, const SValuePtr &to, const SmtSolverPtr &solver) const;
314
321 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2, const InsnSet &set3);
322 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2);
323 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1);
324 virtual void defined_by(SgAsmInstruction *insn);
330 virtual const ExprPtr& get_expression() const;
331
334 virtual void set_expression(const ExprPtr &new_expr);
335 virtual void set_expression(const SValuePtr &source);
352 virtual const InsnSet& get_defining_instructions() const;
353
359 virtual size_t add_defining_instructions(const InsnSet &to_add);
360 virtual size_t add_defining_instructions(const SValuePtr &source);
369 virtual void set_defining_instructions(const InsnSet &new_defs);
370 virtual void set_defining_instructions(const SValuePtr &source);
373};
374
375
377// Register state
379
381typedef BaseSemantics::RegisterStateGenericPtr RegisterStatePtr;
382
383
385// Frame state
387
389typedef BaseSemantics::FrameStatePtr FrameStatePtr;
390
391
393// List-based Memory state
395
397typedef boost::shared_ptr<class MemoryListState> MemoryListStatePtr;
398
416public:
419
422
425 public:
427 protected:
428 CellCompressor() {}
429 public:
430 virtual ~CellCompressor() {}
431
433 virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
435 const BaseSemantics::CellList &cells) = 0;
436 };
437
452 public:
453 static Ptr instance();
456 const BaseSemantics::CellList &cells) override;
457 };
458
461 public:
462 static Ptr instance();
465 const BaseSemantics::CellList &cells) override;
466 };
467
472 CellCompressor::Ptr mccarthy_;
473 CellCompressor::Ptr simple_;
474 protected:
476 public:
477 static Ptr instance();
480 const BaseSemantics::CellList &cells) override;
481 };
482
487 public:
488 static Ptr instance();
491 const BaseSemantics::CellList &cells) override;
492 };
493
494private:
495 CellCompressor::Ptr cellCompressor_; // Callback when a memory read aliases multiple memory cells.
496
498 // Serialization
499#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
500private:
501 friend class boost::serialization::access;
502
503 template<class S>
504 void serialize(S &s, const unsigned /*version*/) {
505 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
506 }
507#endif
508
509
511 // Real constructors
512protected:
513 MemoryListState(); // for serialization
514 explicit MemoryListState(const BaseSemantics::MemoryCellPtr &protocell);
515 MemoryListState(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
516 MemoryListState(const MemoryListState &other);
517
519 // Static allocating constructors
520public:
523
526 static MemoryListStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
527
530
532 // Virtual constructors
533public:
537 const BaseSemantics::SValuePtr &valProtoval) const override;
538
541
544
546 // Dynamic pointer casts
547public:
551
553 // Methods we inherited
554public:
560 BaseSemantics::RiscOperators *valOps) override;
561
567 BaseSemantics::RiscOperators *valOps) override;
568
574
575protected:
576 BaseSemantics::SValuePtr readOrPeekMemory(const BaseSemantics::SValuePtr &address,
577 const BaseSemantics::SValuePtr &dflt,
580 AllowSideEffects::Flag allowSideEffects);
581
583 // Methods first declared in this class
584public:
594 // Deprecated [Robb Matzke 2021-12-15]
595 CellCompressor::Ptr get_cell_compressor() const ROSE_DEPRECATED("use cellCompressor");
596 void set_cell_compressor(const CellCompressor::Ptr&) ROSE_DEPRECATED("use cellCompressor");
597};
598
599
601// Map-based Memory state
603
605typedef boost::shared_ptr<class MemoryMapState> MemoryMapStatePtr;
606
624class MemoryMapState: public BaseSemantics::MemoryCellMap {
625public:
628
631
633 // Serialization
634#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
635private:
636 friend class boost::serialization::access;
637
638 template<class S>
639 void serialize(S &s, const unsigned /*version*/) {
640 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
641 }
642#endif
643
645 // Real constructors
646protected:
647 MemoryMapState(); // for serialization
648
649 explicit MemoryMapState(const BaseSemantics::MemoryCellPtr &protocell);
650
651 MemoryMapState(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
652
654 // Static allocating constructors
655public:
658
661 static MemoryMapStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
662
665
667 // Virtual constructors
668public:
672 const BaseSemantics::SValuePtr &valProtoval) const override;
673
676
679
681 // Dynamic pointer casts
682public:
686
688 // Methods we override from the super class (documented in the super class)
689public:
691};
692
693
694
696// Default memory state
698
699// List-base memory was the type originally used by this domain. We must keep it that way because some analysis, including 3rd
700// party, assumes that the state is list-based. New analysis can use the map-based state by instantiating it when the symbolic
701// risc operators are constructed.
703typedef MemoryListStatePtr MemoryStatePtr;
704
706// Complete state
708
710typedef BaseSemantics::StatePtr StatePtr;
711
712
714// RISC operators
716
723
730
732typedef boost::shared_ptr<class RiscOperators> RiscOperatorsPtr;
733
754public:
757
760
761protected:
762 bool omit_cur_insn; // if true, do not include cur_insn as a definer
763 DefinersMode computingDefiners_; // whether to track definers (instruction VAs) of SValues
764 WritersMode computingMemoryWriters_; // whether to track writers (instruction VAs) to memory.
765 WritersMode computingRegisterWriters_; // whether to track writers (instruction VAs) to registers.
766 uint64_t trimThreshold_; // max size of expressions (zero means no maximimum)
767 bool reinterpretMemoryReads_; // cast data to unsigned integer when reading from memory
768 bool reinterpretRegisterReads_; // cast data to unsigned integer when reading from registers
769 size_t nTrimmed_ = 0; // number of expressions trimmed down to a new variable
770
771
773 // Serialization
774#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
775private:
776 friend class boost::serialization::access;
777
778 template<class S>
779 void serialize(S &s, const unsigned /*version*/) {
780 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
781 s & BOOST_SERIALIZATION_NVP(omit_cur_insn);
782 s & BOOST_SERIALIZATION_NVP(computingDefiners_);
783 s & BOOST_SERIALIZATION_NVP(computingMemoryWriters_);
784 s & BOOST_SERIALIZATION_NVP(computingRegisterWriters_);
785 s & BOOST_SERIALIZATION_NVP(trimThreshold_);
786 }
787#endif
788
790 // Real constructors
791protected:
792 RiscOperators(); // for serialization
793
794 explicit RiscOperators(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver);
795
796 explicit RiscOperators(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver);
797
799 // Static allocating constructors
800public:
802
806
810 const SmtSolverPtr &solver = SmtSolverPtr());
811
815
817 // Virtual constructors
818public:
820 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
821
823 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
824
826 // Dynamic pointer casts
827public:
831
833 // Inherited methods for constructing values.
834public:
836 BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) override;
837
839 // New methods for constructing values, so we don't have to write so many SValue::promote calls in the RiscOperators
840 // implementations.
841 SValuePtr svalueExpr(const ExprPtr &expr, const InsnSet &defs=InsnSet());
842
843protected:
844 SValuePtr svalueUndefined(size_t nbits);
845 SValuePtr svalueBottom(size_t nbits);
846 SValuePtr svalueUnspecified(size_t nbits);
847 SValuePtr svalueNumber(size_t nbits, uint64_t value);
848 SValuePtr svalueBoolean(bool b);
849
851 // Configuration properties
852public:
853
871 void computingDefiners(DefinersMode m) { computingDefiners_ = m; }
872 DefinersMode computingDefiners() const { return computingDefiners_; }
893 void computingMemoryWriters(WritersMode m) { computingMemoryWriters_ = m; }
894 WritersMode computingMemoryWriters() const { return computingMemoryWriters_; }
918 void computingRegisterWriters(WritersMode m) { computingRegisterWriters_ = m; }
919 WritersMode computingRegisterWriters() const { return computingRegisterWriters_; }
922 // Used internally to control whether cur_insn should be omitted from the list of definers.
923 bool getset_omit_cur_insn(bool b) { bool retval = omit_cur_insn; omit_cur_insn=b; return retval; }
924
931 void trimThreshold(uint64_t n) { trimThreshold_ = n; }
932 uint64_t trimThreshold() const { return trimThreshold_; }
941 size_t nTrimmed() const { return nTrimmed_; }
942 void nTrimmed(size_t n) { nTrimmed_ = n; }
952 bool reinterpretMemoryReads() const { return reinterpretMemoryReads_; }
953 void reinterpretMemoryReads(bool b) { reinterpretMemoryReads_ = b; }
954 bool reinterpretRegisterReads() const { return reinterpretRegisterReads_; }
955 void reinterpretRegisterReads(bool b) { reinterpretRegisterReads_ = b; }
959 // Methods first defined at this level of the class hierarchy
960public:
1022 virtual void substitute(const SValuePtr &from, const SValuePtr &to);
1023
1029
1035
1040
1042 // Override methods from base class. These are the RISC operators that are invoked by a Dispatcher.
1043public:
1044 void interrupt(int majr, int minr) override;
1046 const BaseSemantics::SValuePtr &b_) override;
1048 const BaseSemantics::SValuePtr &b_) override;
1050 const BaseSemantics::SValuePtr &b_) override;
1053 size_t begin_bit, size_t end_bit) override;
1055 const BaseSemantics::SValuePtr &b_) override;
1059 const BaseSemantics::SValuePtr &sa_) override;
1061 const BaseSemantics::SValuePtr &sa_) override;
1063 const BaseSemantics::SValuePtr &sa_) override;
1065 const BaseSemantics::SValuePtr &sa_) override;
1067 const BaseSemantics::SValuePtr &sa_) override;
1070 const BaseSemantics::SValuePtr &a_,
1071 const BaseSemantics::SValuePtr &b_,
1072 IteStatus&) override;
1074 BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override;
1076 const BaseSemantics::SValuePtr &b_) override;
1078 const BaseSemantics::SValuePtr &b_,
1079 const BaseSemantics::SValuePtr &c_,
1080 BaseSemantics::SValuePtr &carry_out/*out*/) override;
1083 const BaseSemantics::SValuePtr &b_) override;
1085 const BaseSemantics::SValuePtr &b_) override;
1087 const BaseSemantics::SValuePtr &b_) override;
1089 const BaseSemantics::SValuePtr &b_) override;
1091 const BaseSemantics::SValuePtr &b_) override;
1093 const BaseSemantics::SValuePtr &b_) override;
1094
1098
1099 template<class FloatOp>
1101 fpBinaryOp(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b, FloatOp operation);
1102
1104
1110
1112 SgAsmFloatType *retType) override;
1115 const BaseSemantics::SValuePtr &dflt) override;
1117 const BaseSemantics::SValuePtr &dflt) override;
1120 const BaseSemantics::SValuePtr &addr,
1121 const BaseSemantics::SValuePtr &dflt,
1122 const BaseSemantics::SValuePtr &cond) override;
1124 const BaseSemantics::SValuePtr &addr,
1125 const BaseSemantics::SValuePtr &dflt) override;
1127 const BaseSemantics::SValuePtr &addr,
1128 const BaseSemantics::SValuePtr &data,
1129 const BaseSemantics::SValuePtr &cond) override;
1130
1131 BaseSemantics::SValuePtr readLocal(size_t index) override;
1132 void writeLocal(size_t index, const BaseSemantics::SValuePtr &value) override;
1133
1135 void pushOperand(const BaseSemantics::SValuePtr &value) override;
1136
1137public:
1138 BaseSemantics::SValuePtr readOrPeekMemory(RegisterDescriptor segreg,
1139 const BaseSemantics::SValuePtr &addr,
1140 const BaseSemantics::SValuePtr &dflt,
1141 AllowSideEffects::Flag);
1142};
1143
1144} // namespace
1145} // namespace
1146} // namespace
1147} // namespace
1148
1149#include <Rose/BinaryAnalysis/InstructionSemantics/SymbolicSemantics.tpp>
1150
1151#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
1156#endif
1157
1158#endif
1159#endif
Base class for most instruction semantics RISC operators.
Base class for semantics machine states.
Definition State.h:50
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 fpLessThan(const BaseSemantics::SValuePtr &lhs, const BaseSemantics::SValuePtr &rhs) override
Compare two floating-point values.
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.