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