ROSE 0.11.145.147
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/MemoryCellList.h>
9#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryCellMap.h>
10#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryState.h>
11#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/Merger.h>
12#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/RegisterStateGeneric.h>
13#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/RiscOperators.h>
14#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/State.h>
15#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/SValue.h>
16#include <Rose/BinaryAnalysis/SymbolicExpression.h>
17
18#include <Cxx_GrammarSerialization.h>
19
20#include <boost/serialization/access.hpp>
21#include <boost/serialization/base_object.hpp>
22#include <boost/serialization/export.hpp>
23#include <boost/serialization/set.hpp>
24
25#include <inttypes.h>
26#include <map>
27#include <vector>
28
29namespace Rose {
30namespace BinaryAnalysis {
31namespace InstructionSemantics {
32
51namespace SymbolicSemantics {
52
59using InsnSet = std::set<SgAsmInstruction*>;
60
62// Boolean flags
64
66namespace AllowSideEffects {
67 enum Flag {NO, YES};
68}
69
70
72// Merging symbolic values
74
77
80 size_t setSizeLimit_ = 1;
81protected:
82 Merger();
83
84public:
86 typedef MergerPtr Ptr;
87
89 static Ptr instance();
90
92 static Ptr instance(size_t);
93
105 size_t setSizeLimit() const { return setSizeLimit_; }
106 void setSizeLimit(size_t n) { setSizeLimit_ = n; }
108};
109
110
111
113// Semantic values
115
118
121public:
122 SymbolicExpression::Formatter expr_formatter;
123};
124
194public:
197
199 using Ptr = SValuePtr;
200
201protected:
204
207 InsnSet defs;
208
210 // Serialization
211#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
212private:
213 friend class boost::serialization::access;
214
215 template<class S>
216 void serialize(S &s, const unsigned /*version*/) {
217 roseAstSerializationRegistration(s); // "defs" has SgAsmInstruction ASTs
218 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
219 s & BOOST_SERIALIZATION_NVP(expr);
220 s & BOOST_SERIALIZATION_NVP(defs);
221 }
222#endif
223
225 // Real constructors
226protected:
227 SValue(); // needed for serialization
228 explicit SValue(size_t nbits);
229 SValue(size_t nbits, uint64_t number);
231
233 // Static allocating constructors
234public:
237
239 static SValuePtr instance_bottom(size_t nbits);
240
242 static SValuePtr instance_undefined(size_t nbits);
243
245 static SValuePtr instance_unspecified(size_t nbits);
246
248 static SValuePtr instance_integer(size_t nbits, uint64_t value);
249
252
254 // Virtual allocating constructors
255public:
256 virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const override;
257 virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const override;
258 virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const override;
259 virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const override;
260 virtual BaseSemantics::SValuePtr boolean_(bool value) const override;
261 virtual BaseSemantics::SValuePtr copy(size_t new_width=0) const override;
262
265 const SmtSolverPtr&) const override;
266
268 // Dynamic pointer casts
269public:
272
274 // Override virtual methods...
275public:
276 virtual bool isBottom() const override;
277
278 virtual void print(std::ostream&, BaseSemantics::Formatter&) const override;
279
280 virtual void hash(Combinatorics::Hasher&) const override;
281
282protected: // when implementing use these names; but when calling, use the camelCase names
283 virtual bool may_equal(const BaseSemantics::SValuePtr &other,
284 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
285 virtual bool must_equal(const BaseSemantics::SValuePtr &other,
286 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
287
288 // It's not possible to change the size of a symbolic expression in place. That would require that we recursively change
289 // the size of the SymbolicExpression, which might be shared with many unrelated values whose size we don't want to affect.
290 virtual void set_width(size_t nbits) override;
291 virtual bool is_number() const override;
292 virtual uint64_t get_number() const override;
293 virtual std::string get_comment() const override;
294 virtual void set_comment(const std::string&) const override;
295
297 // Additional methods first declared in this class...
298public:
306 virtual SValuePtr substitute(const SValuePtr &from, const SValuePtr &to, const SmtSolverPtr &solver) const;
307
314 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2, const InsnSet &set3);
315 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2);
316 virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1);
317 virtual void defined_by(SgAsmInstruction *insn);
323 virtual const ExprPtr& get_expression() const;
324
327 virtual void set_expression(const ExprPtr &new_expr);
328 virtual void set_expression(const SValuePtr &source);
345 virtual const InsnSet& get_defining_instructions() const;
346
352 virtual size_t add_defining_instructions(const InsnSet &to_add);
353 virtual size_t add_defining_instructions(const SValuePtr &source);
362 virtual void set_defining_instructions(const InsnSet &new_defs);
363 virtual void set_defining_instructions(const SValuePtr &source);
366};
367
368
370// Register state
372
374typedef BaseSemantics::RegisterStateGenericPtr RegisterStatePtr;
375
376
378// List-based Memory state
380
382typedef boost::shared_ptr<class MemoryListState> MemoryListStatePtr;
383
401public:
404
407
410 public:
412 protected:
413 CellCompressor() {}
414 public:
415 virtual ~CellCompressor() {}
416
418 virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
420 const BaseSemantics::CellList &cells) = 0;
421 };
422
437 public:
438 static Ptr instance();
439 virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
441 const BaseSemantics::CellList &cells) override;
442 };
443
446 public:
447 static Ptr instance();
448 virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
450 const BaseSemantics::CellList &cells) override;
451 };
452
457 CellCompressor::Ptr mccarthy_;
458 CellCompressor::Ptr simple_;
459 protected:
461 public:
462 static Ptr instance();
463 virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
465 const BaseSemantics::CellList &cells) override;
466 };
467
472 public:
473 static Ptr instance();
474 virtual SValuePtr operator()(const SValuePtr &address, const BaseSemantics::SValuePtr &dflt,
476 const BaseSemantics::CellList &cells) override;
477 };
478
479private:
480 CellCompressor::Ptr cellCompressor_; // Callback when a memory read aliases multiple memory cells.
481
483 // Serialization
484#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
485private:
486 friend class boost::serialization::access;
487
488 template<class S>
489 void serialize(S &s, const unsigned /*version*/) {
490 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
491 }
492#endif
493
494
496 // Real constructors
497protected:
498 MemoryListState(); // for serialization
499 explicit MemoryListState(const BaseSemantics::MemoryCellPtr &protocell);
500 MemoryListState(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
501 MemoryListState(const MemoryListState &other);
502
504 // Static allocating constructors
505public:
508
511 static MemoryListStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
512
515
517 // Virtual constructors
518public:
522 const BaseSemantics::SValuePtr &valProtoval) const override;
523
525 virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::MemoryCellPtr &protocell) const override;
526
528 virtual BaseSemantics::MemoryStatePtr clone() const override;
529
531 // Dynamic pointer casts
532public:
536
538 // Methods we inherited
539public:
545 BaseSemantics::RiscOperators *valOps) override;
546
552 BaseSemantics::RiscOperators *valOps) override;
553
557 virtual void writeMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &value,
559
560protected:
561 BaseSemantics::SValuePtr readOrPeekMemory(const BaseSemantics::SValuePtr &address,
562 const BaseSemantics::SValuePtr &dflt,
565 AllowSideEffects::Flag allowSideEffects);
566
568 // Methods first declared in this class
569public:
579 // Deprecated [Robb Matzke 2021-12-15]
580 CellCompressor::Ptr get_cell_compressor() const ROSE_DEPRECATED("use cellCompressor");
581 void set_cell_compressor(const CellCompressor::Ptr&) ROSE_DEPRECATED("use cellCompressor");
582};
583
584
586// Map-based Memory state
588
590typedef boost::shared_ptr<class MemoryMapState> MemoryMapStatePtr;
591
609class MemoryMapState: public BaseSemantics::MemoryCellMap {
610public:
613
616
618 // Serialization
619#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
620private:
621 friend class boost::serialization::access;
622
623 template<class S>
624 void serialize(S &s, const unsigned /*version*/) {
625 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
626 }
627#endif
628
630 // Real constructors
631protected:
632 MemoryMapState(); // for serialization
633
634 explicit MemoryMapState(const BaseSemantics::MemoryCellPtr &protocell);
635
636 MemoryMapState(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
637
639 // Static allocating constructors
640public:
643
646 static MemoryMapStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval);
647
650
652 // Virtual constructors
653public:
657 const BaseSemantics::SValuePtr &valProtoval) const override;
658
661
663 virtual BaseSemantics::MemoryStatePtr clone() const override;
664
666 // Dynamic pointer casts
667public:
671
673 // Methods we override from the super class (documented in the super class)
674public:
675 virtual CellKey generateCellKey(const BaseSemantics::SValuePtr &addr_) const override;
676};
677
678
679
681// Default memory state
683
684// List-base memory was the type originally used by this domain. We must keep it that way because some analysis, including 3rd
685// party, assumes that the state is list-based. New analysis can use the map-based state by instantiating it when the symbolic
686// risc operators are constructed.
688typedef MemoryListStatePtr MemoryStatePtr;
689
691// Complete state
693
695typedef BaseSemantics::StatePtr StatePtr;
696
697
699// RISC operators
701
708
715
717typedef boost::shared_ptr<class RiscOperators> RiscOperatorsPtr;
718
739public:
742
745
746protected:
747 bool omit_cur_insn; // if true, do not include cur_insn as a definer
748 DefinersMode computingDefiners_; // whether to track definers (instruction VAs) of SValues
749 WritersMode computingMemoryWriters_; // whether to track writers (instruction VAs) to memory.
750 WritersMode computingRegisterWriters_; // whether to track writers (instruction VAs) to registers.
751 uint64_t trimThreshold_; // max size of expressions (zero means no maximimum)
752 bool reinterpretMemoryReads_; // cast data to unsigned integer when reading from memory
753 bool reinterpretRegisterReads_; // cast data to unsigned integer when reading from registers
754 size_t nTrimmed_ = 0; // number of expressions trimmed down to a new variable
755
756
758 // Serialization
759#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
760private:
761 friend class boost::serialization::access;
762
763 template<class S>
764 void serialize(S &s, const unsigned /*version*/) {
765 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
766 s & BOOST_SERIALIZATION_NVP(omit_cur_insn);
767 s & BOOST_SERIALIZATION_NVP(computingDefiners_);
768 s & BOOST_SERIALIZATION_NVP(computingMemoryWriters_);
769 s & BOOST_SERIALIZATION_NVP(computingRegisterWriters_);
770 s & BOOST_SERIALIZATION_NVP(trimThreshold_);
771 }
772#endif
773
775 // Real constructors
776protected:
777 RiscOperators(); // for serialization
778
779 explicit RiscOperators(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver);
780
781 explicit RiscOperators(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver);
782
784 // Static allocating constructors
785public:
787
791
795 const SmtSolverPtr &solver = SmtSolverPtr());
796
800
802 // Virtual constructors
803public:
805 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
806
808 const SmtSolverPtr &solver = SmtSolverPtr()) const override;
809
811 // Dynamic pointer casts
812public:
816
818 // Inherited methods for constructing values.
819public:
820 virtual BaseSemantics::SValuePtr boolean_(bool b) override;
821 virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) override;
822
824 // New methods for constructing values, so we don't have to write so many SValue::promote calls in the RiscOperators
825 // implementations.
826 SValuePtr svalueExpr(const ExprPtr &expr, const InsnSet &defs=InsnSet());
827
828protected:
829 SValuePtr svalueUndefined(size_t nbits);
830 SValuePtr svalueBottom(size_t nbits);
831 SValuePtr svalueUnspecified(size_t nbits);
832 SValuePtr svalueNumber(size_t nbits, uint64_t value);
833 SValuePtr svalueBoolean(bool b);
834
836 // Configuration properties
837public:
838
856 void computingDefiners(DefinersMode m) { computingDefiners_ = m; }
857 DefinersMode computingDefiners() const { return computingDefiners_; }
878 void computingMemoryWriters(WritersMode m) { computingMemoryWriters_ = m; }
879 WritersMode computingMemoryWriters() const { return computingMemoryWriters_; }
903 void computingRegisterWriters(WritersMode m) { computingRegisterWriters_ = m; }
904 WritersMode computingRegisterWriters() const { return computingRegisterWriters_; }
907 // Used internally to control whether cur_insn should be omitted from the list of definers.
908 bool getset_omit_cur_insn(bool b) { bool retval = omit_cur_insn; omit_cur_insn=b; return retval; }
909
916 void trimThreshold(uint64_t n) { trimThreshold_ = n; }
917 uint64_t trimThreshold() const { return trimThreshold_; }
926 size_t nTrimmed() const { return nTrimmed_; }
927 void nTrimmed(size_t n) { nTrimmed_ = n; }
937 bool reinterpretMemoryReads() const { return reinterpretMemoryReads_; }
938 void reinterpretMemoryReads(bool b) { reinterpretMemoryReads_ = b; }
939 bool reinterpretRegisterReads() const { return reinterpretRegisterReads_; }
940 void reinterpretRegisterReads(bool b) { reinterpretRegisterReads_ = b; }
944 // Methods first defined at this level of the class hierarchy
945public:
1007 virtual void substitute(const SValuePtr &from, const SValuePtr &to);
1008
1014
1020
1025
1027 // Override methods from base class. These are the RISC operators that are invoked by a Dispatcher.
1028public:
1029 virtual void interrupt(int majr, int minr) override;
1031 const BaseSemantics::SValuePtr &b_) override;
1033 const BaseSemantics::SValuePtr &b_) override;
1035 const BaseSemantics::SValuePtr &b_) override;
1038 size_t begin_bit, size_t end_bit) override;
1040 const BaseSemantics::SValuePtr &b_) override;
1044 const BaseSemantics::SValuePtr &sa_) override;
1046 const BaseSemantics::SValuePtr &sa_) override;
1048 const BaseSemantics::SValuePtr &sa_) override;
1050 const BaseSemantics::SValuePtr &sa_) override;
1052 const BaseSemantics::SValuePtr &sa_) override;
1055 const BaseSemantics::SValuePtr &a_,
1056 const BaseSemantics::SValuePtr &b_,
1057 IteStatus&) override;
1058 virtual BaseSemantics::SValuePtr unsignedExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override;
1059 virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override;
1061 const BaseSemantics::SValuePtr &b_) override;
1063 const BaseSemantics::SValuePtr &b_,
1064 const BaseSemantics::SValuePtr &c_,
1065 BaseSemantics::SValuePtr &carry_out/*out*/) override;
1068 const BaseSemantics::SValuePtr &b_) override;
1070 const BaseSemantics::SValuePtr &b_) override;
1072 const BaseSemantics::SValuePtr &b_) override;
1074 const BaseSemantics::SValuePtr &b_) override;
1076 const BaseSemantics::SValuePtr &b_) override;
1078 const BaseSemantics::SValuePtr &b_) override;
1080 SgAsmFloatType *retType) override;
1083 const BaseSemantics::SValuePtr &dflt) override;
1085 const BaseSemantics::SValuePtr &dflt) override;
1086 virtual void writeRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &a_) override;
1088 const BaseSemantics::SValuePtr &addr,
1089 const BaseSemantics::SValuePtr &dflt,
1090 const BaseSemantics::SValuePtr &cond) override;
1092 const BaseSemantics::SValuePtr &addr,
1093 const BaseSemantics::SValuePtr &dflt) override;
1094 virtual void writeMemory(RegisterDescriptor segreg,
1095 const BaseSemantics::SValuePtr &addr,
1096 const BaseSemantics::SValuePtr &data,
1097 const BaseSemantics::SValuePtr &cond) override;
1098
1099public:
1100 BaseSemantics::SValuePtr readOrPeekMemory(RegisterDescriptor segreg,
1101 const BaseSemantics::SValuePtr &addr,
1102 const BaseSemantics::SValuePtr &dflt,
1103 AllowSideEffects::Flag);
1104};
1105
1106} // namespace
1107} // namespace
1108} // namespace
1109} // namespace
1110
1111#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
1116#endif
1117
1118#endif
1119#endif
Base class for most instruction semantics RISC operators.
Base class for semantics machine states.
Definition State.h:41
Functor for handling a memory read whose address matches more than one memory cell.
virtual 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.
virtual 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.
virtual 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.
virtual 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.
static MemoryListStatePtr promote(const BaseSemantics::MemoryStatePtr &)
Recasts a base pointer to a symbolic memory state.
virtual void writeMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &value, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) override
Write a byte to memory.
virtual BaseSemantics::MemoryStatePtr clone() const override
Virtual copy constructor.
static MemoryListStatePtr instance(const MemoryListStatePtr &other)
Instantiates a new deep copy of an existing state.
virtual BaseSemantics::SValuePtr readMemory(const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *addrOps, BaseSemantics::RiscOperators *valOps) override
Read a byte from memory.
virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const override
Virtual constructor.
static MemoryListStatePtr instance(const BaseSemantics::MemoryCellPtr &protocell)
Instantiates a new memory state having specified prototypical cells and value.
virtual 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.
static MemoryListStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
Instantiates a new memory state having specified prototypical value.
CellCompressor::Ptr cellCompressor() const
Callback for handling a memory read whose address matches more than one memory cell.
void cellCompressor(const CellCompressor::Ptr &)
Callback for handling a memory read whose address matches more than one memory cell.
virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::MemoryCellPtr &protocell) const override
Virtual constructor.
virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const override
Virtual 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.
static MemoryMapStatePtr instance(const MemoryMapStatePtr &other)
Instantiates a new deep copy of an existing state.
static MemoryMapStatePtr promote(const BaseSemantics::MemoryStatePtr &)
Recasts a base pointer to a symbolic memory state.
static MemoryMapStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
Instantiates a new memory state having specified prototypical value.
virtual BaseSemantics::MemoryStatePtr clone() const override
Virtual copy constructor.
virtual CellKey generateCellKey(const BaseSemantics::SValuePtr &addr_) const override
Generate a cell lookup key.
MergerPtr Ptr
Shared-ownership pointer for a Merger object.
Defines RISC operators for the SymbolicSemantics domain.
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.
virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Calculates modulo with unsigned values.
static SgAsmFloatType * sgIsIeee754(SgAsmType *)
Tests whether a SgAsmType is an IEEE-754 floating-point type.
void computingMemoryWriters(WritersMode m)
Property: Track which instructions write to each memory location.
size_t nTrimmed() const
Property: Number of symbolic expressions trimmed.
virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Calculates modulo with signed values.
virtual BaseSemantics::SValuePtr invert(const BaseSemantics::SValuePtr &a_) override
One's complement.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::StatePtr &, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual allocating constructor.
virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Divides two signed values.
virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override
Sign extends a value.
virtual BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Rotate bits to the right.
virtual BaseSemantics::SValuePtr boolean_(bool b) override
Returns a Boolean value.
virtual BaseSemantics::SValuePtr readRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) override
Reads a value from a register.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual allocating constructor.
virtual BaseSemantics::SValuePtr peekRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &dflt) override
Obtain a register value without side effects.
WritersMode computingRegisterWriters() const
Property: Track latest writer to each register.
virtual BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted right logically (no sign bit).
virtual BaseSemantics::SValuePtr peekMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt) override
Read memory without side effects.
virtual BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Rotate bits to the left.
virtual BaseSemantics::SValuePtr readMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, const BaseSemantics::SValuePtr &cond) override
Reads a value from memory.
virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) override
Returns a number of the specified bit width.
virtual BaseSemantics::SValuePtr mostSignificantSetBit(const BaseSemantics::SValuePtr &a_) override
Returns position of most significant set bit; zero when no bits are set.
virtual BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted right arithmetically (with sign bit).
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.
virtual void writeRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &a_) override
Writes a value to a register.
virtual BaseSemantics::SValuePtr fpConvert(const BaseSemantics::SValuePtr &a, SgAsmFloatType *aType, SgAsmFloatType *retType) override
Convert from one floating-point type to another.
virtual void interrupt(int majr, int minr) override
Unconditionally raise an interrupt.
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.
virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Multiply two unsigned values.
virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Divides two unsigned values.
virtual BaseSemantics::SValuePtr reinterpret(const BaseSemantics::SValuePtr &, SgAsmType *) override
Reinterpret an expression as a different type.
virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) override
Writes a value to memory.
virtual BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a_) override
Determines whether a value is equal to zero.
virtual BaseSemantics::SValuePtr iteWithStatus(const BaseSemantics::SValuePtr &sel_, const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_, IteStatus &) override
If-then-else with status.
bool reinterpretRegisterReads() const
Property: Reinterpret data as unsigned integers when reading from memory or registers.
virtual BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a_) override
Returns position of least significant set bit; zero when no bits are set.
virtual 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.
virtual 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.
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.
virtual BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Adds two integers of equal size.
void reinterpretRegisterReads(bool b)
Property: Reinterpret data as unsigned integers when reading from memory or registers.
virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a_) override
Two's complement.
virtual BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise XOR of two values.
virtual 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.
virtual BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted left.
virtual BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a_, size_t begin_bit, size_t end_bit) override
Extracts bits from a value.
uint64_t trimThreshold() const
Property: Maximum size of expressions.
virtual BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise AND of two 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 BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Multiplies two signed values.
virtual BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise OR of two values.
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.
virtual bool may_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual API.
virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1, const InsnSet &set2)
Adds instructions to the list of defining instructions.
virtual 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.
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.
static SValuePtr instance_symbolic(const SymbolicExpression::Ptr &value)
Instantiate a new symbolic value.
virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const override
Data-flow bottom value.
static SValuePtr instance_undefined(size_t nbits)
Instantiate a new undefined value of specified width.
virtual 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.
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 bool must_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual API.
virtual void set_width(size_t nbits) override
Virtual API.
virtual void defined_by(SgAsmInstruction *insn, const InsnSet &set1)
Adds instructions to the list of defining instructions.
virtual std::string get_comment() const override
Some subclasses support the ability to add comments to values.
virtual void set_comment(const std::string &) const override
Some subclasses support the ability to add comments to values.
virtual BaseSemantics::SValuePtr boolean_(bool value) const override
Create a new, Boolean value.
virtual size_t add_defining_instructions(SgAsmInstruction *insn)
Adds definitions to the list of defining instructions.
virtual void print(std::ostream &, BaseSemantics::Formatter &) const override
Print a value to a stream using default format.
static SValuePtr instance_bottom(size_t nbits)
Instantiate a new data-flow bottom value of specified width.
virtual uint64_t get_number() const override
Virtual API.
virtual void hash(Combinatorics::Hasher &) const override
Hash this semantic value.
virtual void set_defining_instructions(const InsnSet &new_defs)
Set defining instructions.
virtual bool isBottom() const override
Determines whether a value is a data-flow bottom.
virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const override
Create a new concrete semantic value.
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.
virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const override
Create a new unspecified semantic value.
virtual void set_defining_instructions(const SValuePtr &source)
Set defining instructions.
virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const override
Create a new undefined semantic value.
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:56
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
Floating point types.
Base class for machine instructions.
Base class for binary types.
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:276
boost::shared_ptr< class RegisterStateGeneric > RegisterStateGenericPtr
Shared-ownership pointer to generic register states.
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.