ROSE  0.11.2.0
TestSemantics2.h
1 // Perform basic sanity checks on instruction semantics
2 #ifndef Rose_TestSemantics2_H
3 #define Rose_TestSemantics2_H
4 #include <rosePublicConfig.h>
5 #ifdef ROSE_BUILD_BINARY_ANALYSIS_SUPPORT
6 
7 #include "BaseSemantics2.h"
8 #include "CommandLine.h"
9 
10 namespace Rose {
11 namespace BinaryAnalysis { // documented elsewhere
12 namespace InstructionSemantics2 { // documented elsewhere
13 
26 template<class SValuePtr, class RegisterStatePtr, class MemoryStatePtr, class StatePtr, class RiscOperatorsPtr>
28 public:
29  typedef typename SValuePtr::Pointee SValue;
30  typedef typename RegisterStatePtr::element_type RegisterState;
31  typedef typename MemoryStatePtr::element_type MemoryState;
32  typedef typename StatePtr::element_type State;
33  typedef typename RiscOperatorsPtr::element_type RiscOperators;
34 
36  public:
37  Exception(const std::string &mesg): BaseSemantics::Exception(mesg, NULL) {}
38  };
39 
40  void require(bool assertion, const std::string &what_failed) {
41  if (!assertion)
42  throw Exception("failed assertion: "+what_failed);
43  }
44 
45  template<typename Pointer>
46  void nonnull(const Pointer &x, const std::string &what_failed) {
47  if (x==NULL)
48  throw Exception("must not be null: "+what_failed);
49  }
50 
51  // check boost smart pointers
52  template<class ToPtr, class FromPtr>
53  void check_type(const FromPtr &x, const std::string &what_failed) {
54  typedef typename ToPtr::element_type To;
55  nonnull(x, what_failed);
56  ToPtr y = boost::dynamic_pointer_cast<To>(x);
57  if (y==NULL)
58  throw Exception("wrong pointer type: "+what_failed);
59  }
60 
61  // check SValue smart pointers
62  void check_sval_type(const BaseSemantics::SValuePtr &x, const std::string &what_failed) {
63  nonnull(x, what_failed);
64  SValuePtr y = BaseSemantics::dynamic_pointer_cast<SValue>(x);
65  if (y==NULL)
66  throw Exception("wrong pointer type: "+what_failed);
67  }
68 
69  // Compile-time checks for SValue
70  class SValueSubclass: public SValue {
71  public:
72  explicit SValueSubclass(size_t nbits): SValue(nbits) {}
73  SValueSubclass(const SValueSubclass &other): SValue(other) {}
74  };
75 
76  // Compile-time checks for RegisterState
77  class RegisterStateSubclass: public RegisterState {
78  public:
79  explicit RegisterStateSubclass(const SValuePtr &protoval, const RegisterDictionary *regdict)
80  : RegisterState(protoval, regdict) {}
81  };
82 
83  // Compile-time checks for MemoryState
84  class MemoryStateSubclass: public MemoryState {
85  public:
86  explicit MemoryStateSubclass(const SValuePtr &protoval)
87  : MemoryState(protoval) {}
88  };
89 
90  // Compile-time checks for State
91  class StateSubclass: public State {
92  public:
93  StateSubclass(const RegisterStatePtr &registers, const MemoryStatePtr &memory)
94  : State(registers, memory) {}
95  StateSubclass(const StateSubclass &other)
96  : State(other) {}
97  };
98 
99  // Compile-time checks for RiscOperators
100  class RiscOperatorsSubclass: public RiscOperators {
101  public:
102  explicit RiscOperatorsSubclass(const SValuePtr &protoval, const SmtSolverPtr &solver = SmtSolverPtr())
103  : RiscOperators(protoval, solver) {}
104  explicit RiscOperatorsSubclass(const StatePtr &state, const SmtSolverPtr &solver = SmtSolverPtr())
105  : RiscOperators(state, solver) {}
106  };
107 
108  // Run-time checks
109  void test(const BaseSemantics::RiscOperatorsPtr &ops) {
110  ByteOrder::Endianness savedByteOrder = ops->currentState()->memoryState()->get_byteOrder();
111  ops->currentState()->memoryState()->set_byteOrder(ByteOrder::ORDER_LSB);
112  test(ops->protoval(), ops->currentState(), ops);
113  ops->currentState()->memoryState()->set_byteOrder(ByteOrder::ORDER_MSB);
114  test(ops->protoval(), ops->currentState(), ops);
115  ops->currentState()->memoryState()->set_byteOrder(savedByteOrder);
116  }
117 
118  void test(const BaseSemantics::SValuePtr &protoval,
119  const BaseSemantics::StatePtr &state,
120  const BaseSemantics::RiscOperatorsPtr &ops) {
121 
123  const RegisterDescriptor reg32 = regdict->findOrThrow("eip");
124  const RegisterDescriptor segreg = regdict->findOrThrow("ss");
126 
128  // SValue
130 
131  SValuePtr v0;
132  require(v0==NULL, "default SValue constructor");
133 
134  // Dynamic pointer casts
135  check_sval_type(SValue::promote(protoval), "SValue::promote()");
136 
137  // Virtual constructor: undefined_()
138  BaseSemantics::SValuePtr v1 = protoval->undefined_(8);
139  check_sval_type(v1, "SValue::undefined_()");
140  require(v1->get_width()==8, "SValue::undefined_() width");
141 
142  // Virtual constructor: unspecified_()
143  BaseSemantics::SValuePtr v1b = protoval->unspecified_(8);
144  check_sval_type(v1b, "SValue::unspecified_()");
145  require(v1b->get_width()==8, "SValue::unspecified() width");
146 
147  // Virtual constructor: number_(). Note that we can't check that the number is actually concrete and has a value
148  // because BaseSemantics defines only the API for is_number() and get_number() and not the semantics of those
149  // methods. In fact, the NullSemantics domain doesn't make any distinction between concrete and abstract values--it
150  // treats everything as abstract.
151  BaseSemantics::SValuePtr v2 = protoval->number_(32, 123);
152  check_sval_type(v2, "SValue::number_()");
153  require(v2->get_width()==32, "SValue::number_() width");
154 
155  // Virtual constructor: boolean_()
156  BaseSemantics::SValuePtr v3 = protoval->boolean_(true);
157  check_sval_type(v3, "SValue::boolean_()");
158  require(v3->get_width()==1, "SValue::boolean_() width");
159 
160  // Virtual constructor: copy()
161  BaseSemantics::SValuePtr v4 = v3->copy();
162  check_sval_type(v4, "SValue::copy()");
163  require(v4!=v3, "SValue::copy() should have returned a new object");
164  require(v4->get_width()==1, "SValue::copy() width");
165  require(v4->is_number() == v3->is_number(), "copies should be identical");
166  if (v4->is_number())
167  require(v4->get_number() == v3->get_number(), "concrete copies should be identical");
168  std::ostringstream v3str, v4str;
169  v3str <<*v3;
170  v4str <<*v4;
171  require(v3str.str() == v4str.str(), "copies should be identical");
172 
173  // may_equal
174  require(v3->may_equal(v3), "a value may_equal itself");
175  require(v3->may_equal(v4), "a value may_equal a copy of itself");
176  require(v4->may_equal(v3), "a value may_equal a copy of itself");
177 
178  // must_equal. Note: must_equal(v3, v4) need not be true when v4 is a copy of v3, although most subclasses do this.
179  require(v3->must_equal(v3), "a value must_equal itself");
180  require(v3->must_equal(v4) == v4->must_equal(v3), "must_equal should be symmetric");
181 
182 
184  // RegisterState (read/write is tested by RiscOperators)
186 
187  // Dynamic pointer cast
188  BaseSemantics::RegisterStatePtr rs1 = state->registerState();
189  check_type<RegisterStatePtr>(RegisterState::promote(rs1), "RegisterState::promote()");
190 
191  BaseSemantics::SValuePtr rs1v1 = rs1->protoval();
192  check_sval_type(rs1v1, "RegisterState::protoval()");
193 
194  // Virtual constructors
195  BaseSemantics::RegisterStatePtr rs3 = rs1->create(protoval, regdict);
196  check_type<RegisterStatePtr>(rs3, "create()");
197  require(rs3->get_register_dictionary()==regdict, "RegisterState::create() register dictionary");
198  require(rs3 != rs1, "RegisterState::create() must return a new object");
199  BaseSemantics::SValuePtr rs3v1 = rs3->protoval();
200  check_sval_type(rs3v1, "RegisterState::protoval() after create()");
201 
202  BaseSemantics::RegisterStatePtr rs4 = rs1->clone();
203  check_type<RegisterStatePtr>(rs4, "clone()");
204  require(rs4 != rs1, "RegisterState::clone() must return a new object");
205  require(rs4->get_register_dictionary()==rs1->get_register_dictionary(),
206  "RegisterState::clone() must use the register dictionary from the source state");
207  BaseSemantics::SValuePtr rs4v1 = rs4->protoval();
208  check_sval_type(rs4v1, "RegisterState::protoval() after clone()");
209 
211  // MemoryState (read/write is tested by RiscOperators)
213 
214  // Dynamic pointer cast
215  BaseSemantics::MemoryStatePtr ms1 = state->memoryState();
216  check_type<MemoryStatePtr>(MemoryState::promote(ms1), "MemoryState::promote()");
217 
218  BaseSemantics::SValuePtr ms1v1 = ms1->get_addr_protoval();
219  check_sval_type(ms1v1, "MemoryState::get_addr_protoval()");
220 
221  BaseSemantics::SValuePtr ms1v2 = ms1->get_val_protoval();
222  check_sval_type(ms1v2, "MemoryState::get_val_protoval()");
223 
224  // Virtual constructors
225  BaseSemantics::MemoryStatePtr ms2 = ms1->create(protoval, protoval);
226  require(ms2 != ms1, "MemoryState::create() must return a new state");
227  check_type<MemoryStatePtr>(ms2, "MemoryState::create(protoval)");
228  BaseSemantics::SValuePtr ms2v1 = ms2->get_addr_protoval();
229  check_sval_type(ms2v1, "MemoryState::get_addr_protoval() after create");
230  BaseSemantics::SValuePtr ms2v2 = ms2->get_val_protoval();
231  check_sval_type(ms2v2, "MemoryState::get_val_protoval() after create");
232 
233  BaseSemantics::MemoryStatePtr ms3 = ms1->clone();
234  require(ms3 != ms1, "MemoryState::clone must return a new state");
235  check_type<MemoryStatePtr>(ms3, "MemoryState::clone()");
236  BaseSemantics::SValuePtr ms3v1 = ms3->get_addr_protoval();
237  check_sval_type(ms3v1, "MemoryState::get_addr_protoval() after clone");
238  BaseSemantics::SValuePtr ms3v2 = ms3->get_val_protoval();
239  check_sval_type(ms3v2, "MemoryState::get_val_protoval() after clone");
240 
242  // State (read/write is tested by RiscOperators)
244 
245  // Dynamic pointer casts
246  check_type<StatePtr>(State::promote(state), "State::promote()");
247 
248  BaseSemantics::SValuePtr state_protoval = state->protoval();
249  check_sval_type(state_protoval, "State::protoval()");
250 
251  // Virtual constructors
252  BaseSemantics::StatePtr s1 = state->create(rs1, ms1);
253  require(s1 != state, "State::create() must return a new state");
254  check_type<StatePtr>(s1, "State::create(regs,mem)");
255  require(s1->registerState()==rs1, "State::create() must use supplied register state");
256  require(s1->memoryState()==ms1, "State::create() must use supplied memory state");
257 
258  BaseSemantics::StatePtr s2 = state->clone();
259  require(s2 != state, "State::clone() must return a new state");
260  check_type<StatePtr>(s2, "State::clone()");
261  require(s2->registerState() != state->registerState(),
262  "State::clone() must deep-copy the register state");
263  require(s2->memoryState() != state->memoryState(),
264  "State::clone() must deep-copy the memory state");
265 
267  // RiscOperators
269 
270  // Dynamic pointer casts
271  check_type<RiscOperatorsPtr>(RiscOperators::promote(ops), "RiscOperators::promote()");
272 
273  BaseSemantics::SValuePtr ops_protoval = ops->protoval();
274  check_sval_type(ops_protoval, "RiscOperators::protoval()");
275 
276  // Virtual constructors
277  BaseSemantics::RiscOperatorsPtr o1 = ops->create(protoval, solver);
278  require(o1 != ops, "RiscOperators::create(protoval,solver) should return a new object");
279  check_type<RiscOperatorsPtr>(o1, "RiscOperators::create(protoval,solver)");
280 
281  BaseSemantics::RiscOperatorsPtr o2 = ops->create(state, solver);
282  require(o2 != ops, "RiscOperators::create(state,solver) should return a new object");
283  check_type<RiscOperatorsPtr>(o2, "RiscOperators::create(state,solver)");
284 
285  BaseSemantics::StatePtr ops_orig_state = ops->currentState();
286  check_type<StatePtr>(ops_orig_state, "RiscOperators::currentState()");
287 
288  // We shouldn't use the supplied state because these tests modify it. So we'll make a copy of the state and use that,
289  // and then restore the original state before we return (but leave our state there fore debugging if there's an
290  // exception). This has the side effect of implicitly checking that State::clone() works because if it didn't the
291  // caller would see the mess we made here. State::clone was tested already.
292  BaseSemantics::StatePtr our_state = ops_orig_state->clone();
293  ops->currentState(our_state);
294  require(ops->currentState() == our_state, "RiscOperators::currentState failed to change state");
295 
296  for (size_t i=0; i<4; ++i) {
297  // Value-creating operators
298  BaseSemantics::SValuePtr v32a, v32b, v8, v1;
299  switch (i) {
300  case 0:
301  v32a = ops->undefined_(32);
302  v32b = ops->undefined_(32);
303  v8 = ops->undefined_(8);
304  v1 = ops->undefined_(1);
305  break;
306  case 1:
307  v32a = ops->undefined_(32);
308  v32b = ops->number_(32, 3);
309  v8 = ops->number_(8, 3);
310  v1 = ops->boolean_(false);
311  break;
312  case 2:
313  v32a = ops->number_(32, 4);
314  v32b = ops->undefined_(32);
315  v8 = ops->undefined_(8);
316  v1 = ops->undefined_(1);
317  break;
318  case 3:
319  v32a = ops->number_(32, 4);
320  v32b = ops->number_(32, 3);
321  v8 = ops->number_(8, 3);
322  v1 = ops->boolean_(true);
323  break;
324  }
325  check_sval_type(v32a, "RiscOperators value constructor");
326  require(v32a->get_width()==32, "RiscOperators value constructor width");
327  check_sval_type(v32b, "RiscOperators value constructor");
328  require(v32b->get_width()==32, "RiscOperators value constructor width");
329  check_sval_type(v8, "RiscOperators value constructor");
330  require(v8->get_width()==8, "RiscOperators value constructor width");
331  check_sval_type(v1, "RiscOperators value constructor");
332  require(v1->get_width()==1, "RiscOperators value constructor width");
333 
334  // x86-specific operators
335  BaseSemantics::SValuePtr ops_v4 = ops->filterCallTarget(v32a);
336  check_sval_type(ops_v4, "RiscOperators::filterCallTarget");
337  require(ops_v4->get_width()==32, "RiscOperators::filterCallTarget width");
338 
339  BaseSemantics::SValuePtr ops_v5 = ops->filterReturnTarget(v32a);
340  check_sval_type(ops_v5, "RiscOperators::filterReturnTarget");
341  require(ops_v5->get_width()==32, "RiscOperators::filterReturnTarget width");
342 
343  BaseSemantics::SValuePtr ops_v6 = ops->filterIndirectJumpTarget(v32a);
344  check_sval_type(ops_v6, "RiscOperators::filterIndirectJumpTarget");
345  require(ops_v6->get_width()==32, "RiscOperators::filterIndirectJumpTarget width");
346 
347  BaseSemantics::SValuePtr ops_v7 = ops->rdtsc();
348  check_sval_type(ops_v7, "RiscOperators::rdtsc");
349  require(ops_v7->get_width()==64, "RiscOperators::rdtsc width");
350 
351  BaseSemantics::SValuePtr ops_v8 = ops->and_(v32a, v32b);
352  check_sval_type(ops_v8, "RiscOperators::and_");
353  require(ops_v8->get_width()==32, "RiscOperators::and_ width");
354 
355  BaseSemantics::SValuePtr ops_v9 = ops->or_(v32a, v32b);
356  check_sval_type(ops_v9, "RiscOperators::or_");
357  require(ops_v9->get_width()==32, "RiscOperators::or_ width");
358 
359  BaseSemantics::SValuePtr ops_v10 = ops->xor_(v32a, v32b);
360  check_sval_type(ops_v10, "RiscOperators::xor_");
361  require(ops_v10->get_width()==32, "RiscOperators::xor_ width");
362 
363  BaseSemantics::SValuePtr ops_v11 = ops->invert(v32a);
364  check_sval_type(ops_v11, "RiscOperators::invert");
365  require(ops_v11->get_width()==32, "RiscOperators::invert width");
366 
367  BaseSemantics::SValuePtr ops_v12 = ops->extract(v32a, 5, 8);
368  check_sval_type(ops_v12, "RiscOperators::extract");
369  require(ops_v12->get_width()==3, "RiscOperators::extract width");
370 
371  BaseSemantics::SValuePtr ops_v13 = ops->concat(v32a, v32b);
372  check_sval_type(ops_v13, "RiscOperators::concat");
373  require(ops_v13->get_width()==64, "RiscOperators::concat width");
374 
375  BaseSemantics::SValuePtr ops_v14 = ops->leastSignificantSetBit(v32a);
376  check_sval_type(ops_v14, "RiscOperators::leastSignificantSetBit");
377  require(ops_v14->get_width()==32, "RiscOperators::leastSignificantSetBit width");
378 
379  BaseSemantics::SValuePtr ops_v15 = ops->mostSignificantSetBit(v32a);
380  check_sval_type(ops_v15, "RiscOperators::mostSignificantSetBit");
381  require(ops_v15->get_width()==32, "RiscOperators::mostSignificantSetBit width");
382 
383  BaseSemantics::SValuePtr ops_v16 = ops->rotateLeft(v32a, v8);
384  check_sval_type(ops_v16, "RiscOperators::rotateLeft");
385  require(ops_v16->get_width()==32, "RiscOperators::rotateLeft width");
386 
387  BaseSemantics::SValuePtr ops_v17 = ops->rotateRight(v32a, v8);
388  check_sval_type(ops_v17, "RiscOperators::rotateRight");
389  require(ops_v17->get_width()==32, "RiscOperators::rotateRight width");
390 
391  BaseSemantics::SValuePtr ops_v18 = ops->shiftLeft(v32a, v8);
392  check_sval_type(ops_v18, "RiscOperators::shiftLeft");
393  require(ops_v18->get_width()==32, "RiscOperators::shiftLeft width");
394 
395  BaseSemantics::SValuePtr ops_v19 = ops->shiftRight(v32a, v8);
396  check_sval_type(ops_v19, "RiscOperators::shiftRight");
397  require(ops_v19->get_width()==32, "RiscOperators::shiftRight width");
398 
399  BaseSemantics::SValuePtr ops_v20 = ops->shiftRightArithmetic(v32a, v8);
400  check_sval_type(ops_v20, "RiscOperators::shiftRightArithmetic");
401  require(ops_v20->get_width()==32, "RiscOperators::shiftRightArithmetic width");
402 
403  BaseSemantics::SValuePtr ops_v21 = ops->equalToZero(v32a);
404  check_sval_type(ops_v21, "RiscOperators::equalToZero");
405  require(ops_v21->get_width()==1, "RiscOperators::equalToZero width");
406 
407  BaseSemantics::SValuePtr ops_v22 = ops->ite(v1, v32a, v32b);
408  check_sval_type(ops_v22, "RiscOperators::ite");
409  require(ops_v22->get_width()==32, "RiscOperators::ite width");
410 
411  BaseSemantics::SValuePtr ops_v23 = ops->unsignedExtend(v8, 32);
412  check_sval_type(ops_v23, "RiscOperators::unsignedExtend");
413  require(ops_v23->get_width()==32, "RiscOperators::unsignedExtend width");
414 
415  BaseSemantics::SValuePtr ops_v24 = ops->unsignedExtend(v32a, 8);
416  check_sval_type(ops_v24, "RiscOperators::unsignedExtend truncate");
417  require(ops_v24->get_width()==8, "RiscOperators::unsignedExtend truncate width");
418 
419  BaseSemantics::SValuePtr ops_v25 = ops->signExtend(v8, 32);
420  check_sval_type(ops_v25, "RiscOperators::signExtend");
421  require(ops_v25->get_width()==32, "RiscOperators::signExtend width");
422 
423  BaseSemantics::SValuePtr ops_v26 = ops->add(v32a, v32b);
424  check_sval_type(ops_v26, "RiscOperators::add");
425  require(ops_v26->get_width()==32, "RiscOperators::add width");
426 
427  BaseSemantics::SValuePtr carry_out;
428  BaseSemantics::SValuePtr ops_v27 = ops->addWithCarries(v32a, v32b, v1, carry_out);
429  check_sval_type(ops_v27, "RiscOperators::addWithCarries");
430  require(ops_v27->get_width()==32, "RiscOperators::addWithCarries width");
431  check_sval_type(carry_out, "RiscOperators::addWithCarries carry_out");
432  require(carry_out->get_width()==32, "RiscOperators::addWithCarries carry_out width");
433 
434  BaseSemantics::SValuePtr ops_v28 = ops->negate(v32a);
435  check_sval_type(ops_v28, "RiscOperators::negate");
436  require(ops_v28->get_width()==32, "RiscOperators::negate width");
437 
438  try {
439  BaseSemantics::SValuePtr ops_v29 = ops->signedDivide(v32a, v8);
440  check_sval_type(ops_v29, "RiscOperators::signedDivide");
441  require(ops_v29->get_width()==32, "RiscOperators::signedDivide width");
442  } catch (const BaseSemantics::Exception&) {
443  // possible division by zero
444  }
445 
446  try {
447  BaseSemantics::SValuePtr ops_v30 = ops->signedModulo(v32a, v8);
448  check_sval_type(ops_v30, "RiscOperators::signedModulo");
449  require(ops_v30->get_width()==8, "RiscOperators::signedModulo width");
450  } catch (const BaseSemantics::Exception&) {
451  // possible division by zero
452  }
453 
454  BaseSemantics::SValuePtr ops_v31 = ops->signedMultiply(v32a, v8);
455  check_sval_type(ops_v31, "RiscOperators::signedMultiply");
456  require(ops_v31->get_width()==40, "RiscOperators::signedMultiply width");
457 
458  try {
459  BaseSemantics::SValuePtr ops_v32 = ops->unsignedDivide(v32a, v8);
460  check_sval_type(ops_v32, "RiscOperators::unsignedDivide");
461  require(ops_v32->get_width()==32, "RiscOperators::unsignedDivide width");
462  } catch (const BaseSemantics::Exception&) {
463  // possible division by zero
464  }
465 
466  try {
467  BaseSemantics::SValuePtr ops_v33 = ops->unsignedModulo(v32a, v8);
468  check_sval_type(ops_v33, "RiscOperators::unsignedModulo");
469  require(ops_v33->get_width()==8, "RiscOperators::unsignedModulo width");
470  } catch (const BaseSemantics::Exception&) {
471  // possible division by zero
472  }
473 
474  BaseSemantics::SValuePtr ops_v34 = ops->unsignedMultiply(v32a, v8);
475  check_sval_type(ops_v34, "RiscOperators::unsignedMultiply");
476  require(ops_v34->get_width()==40, "RiscOperators::unsignedMultiply width");
477 
478  BaseSemantics::SValuePtr ops_v35 = ops->readRegister(reg32);
479  check_sval_type(ops_v35, "RiscOperators::readRegister");
480  require(ops_v35->get_width()==32, "RiscOperators::readRegister width");
481 
482  // We can't really check many semantics for readMemory because each MemoryState might behave differently. For
483  // example, we can't check that reading the same address twice in a row returns the same value both times because
484  // the NullSemantics doesn't have this property.
485 
486  BaseSemantics::SValuePtr dflt8 = ops->number_(8, 0);
487  BaseSemantics::SValuePtr ops_v36 = ops->readMemory(segreg, v32a, dflt8, v1);
488  check_sval_type(ops_v36, "RiscOperators::readMemory byte");
489  require(ops_v36->get_width()==8, "RiscOperators::readMemory byte width");
490 
491  BaseSemantics::SValuePtr dflt32 = ops->number_(32, 0);
492  BaseSemantics::SValuePtr ops_v37 = ops->readMemory(segreg, v32a, dflt32, v1);
493  check_sval_type(ops_v37, "RiscOperators::readMemory word");
494  require(ops_v37->get_width()==32, "RiscOperators::readMemory word width");
495 
496  // Nothing to check for write memory other than that we can actually call it. The problem is that writeMemory only
497  // modifies a state and doesn't return anything we can test. The specifics of how it modifies a memory state is
498  // entirely up to the implementation, so we can't even test that writing a value to an address and then reading
499  // from that address returns the value that was written (e.g., NullSemantics doesn't have this property).
500 
501  ops->writeMemory(segreg, v32a, dflt32, v1);
502 
503  }
504 
505  // Restore the original state
506  ops->currentState(ops_orig_state);
507  }
508 };
509 
510 } // namespace
511 } // namespace
512 } // namespace
513 
514 #endif
515 #endif
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< State > StatePtr
Shared-ownership pointer to a semantic state.
RegisterDescriptor findOrThrow(const std::string &name) const
Find a register by name.
static const RegisterDictionary * dictionary_pentium4()
Intel Pentium 4 registers.
Main namespace for the ROSE library.
Sawyer::SharedPointer< class SmtSolver > SmtSolverPtr
Reference-counting pointer for SMT solvers.
static Ptr instance(const std::string &name)
Allocate a new solver by name.
Describes (part of) a physical CPU register.
Defines registers available for a particular architecture.
Definition: Registers.h:38
Base class for all ROSE exceptions.
Definition: RoseException.h:9
Base class for exceptions thrown by instruction semantics.
ROSE_DLL_API GenericSwitchArgs genericSwitchArgs
Global location for parsed generic command-line switches.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
Provides functions for testing binary instruction semantics.