CBMC
|
#include <interpreter_class.h>
Classes | |
struct | function_assignments_contextt |
struct | function_assignmentt |
class | memory_cellt |
class | stack_framet |
Public Types | |
typedef std::vector< function_assignmentt > | function_assignmentst |
typedef std::vector< mp_integer > | mp_vectort |
typedef std::pair< irep_idt, irep_idt > | assignment_idt |
typedef std::pair< exprt, exprt > | diff_pairt |
typedef std::map< assignment_idt, diff_pairt > | side_effects_differencet |
typedef std::pair< irep_idt, exprt > | input_entryt |
typedef std::map< irep_idt, exprt > | input_valuest |
typedef std::map< irep_idt, typet > | dynamic_typest |
typedef std::map< irep_idt, function_assignmentst > | output_valuest |
typedef std::list< function_assignments_contextt > | function_assignments_contextst |
typedef std::map< irep_idt, std::list< function_assignments_contextt > > | list_input_varst |
Public Member Functions | |
interpretert (const symbol_table_baset &_symbol_table, const goto_functionst &_goto_functions, message_handlert &_message_handler) | |
void | operator() () |
void | print_memory (bool input_flags) |
Prints the current state of the memory map Since messaget mdofifies class members, print functions are nonconst. More... | |
const dynamic_typest & | get_dynamic_types () |
Public Attributes | |
output_valuest | output_values |
Protected Types | |
typedef std::unordered_map< irep_idt, mp_integer > | memory_mapt |
using | inverse_memory_mapt = std::map< mp_integer, std::optional< symbol_exprt > > |
typedef sparse_vectort< memory_cellt > | memoryt |
typedef std::map< std::string, const irep_idt & > | parameter_sett |
typedef std::pair< const irep_idt, const irep_idt > | struct_member_idt |
typedef std::map< struct_member_idt, const exprt > | struct_valuest |
typedef std::stack< stack_framet > | call_stackt |
Protected Member Functions | |
const inverse_memory_mapt::value_type & | address_to_object_record (const mp_integer &address) const |
symbol_exprt | address_to_symbol (const mp_integer &address) const |
mp_integer | address_to_offset (const mp_integer &address) const |
mp_integer | base_address_to_alloc_size (const mp_integer &address) const |
mp_integer | base_address_to_actual_size (const mp_integer &address) const |
void | build_memory_map () |
Creates a memory map of all static symbols in the program. More... | |
void | build_memory_map (const symbolt &symbol) |
mp_integer | build_memory_map (const symbol_exprt &symbol_expr) |
Populates dynamic entries of the memory map. More... | |
typet | concretize_type (const typet &type) |
turns a variable length array type into a fixed array type More... | |
bool | unbounded_size (const typet &) |
mp_integer | get_size (const typet &type) |
Retrieves the actual size of the provided structured type. More... | |
struct_typet::componentt | get_component (const typet &object_type, const mp_integer &offset) |
Retrieves the member at offset of an object of type object_type . More... | |
typet | get_type (const irep_idt &id) const |
returns the type object corresponding to id More... | |
exprt | get_value (const typet &type, const mp_integer &offset=0, bool use_non_det=false) |
retrives the constant value at memory location offset as an object of type type More... | |
exprt | get_value (const typet &type, mp_vectort &rhs, const mp_integer &offset=0) |
returns the value at offset in the form of type given a memory buffer rhs which is typically a structured type More... | |
exprt | get_value (const irep_idt &id) |
void | step () |
executes a single step and updates the program counter More... | |
void | execute_assert () |
void | execute_assume () |
void | execute_assign () |
executes the assign statement at the current pc value More... | |
void | execute_goto () |
executes a goto instruction More... | |
void | execute_function_call () |
void | execute_other () |
executes side effects of 'other' instructions More... | |
void | execute_decl () |
void | clear_input_flags () |
Clears memoy r/w flag initialization. More... | |
void | allocate (const mp_integer &address, const mp_integer &size) |
reserves memory block of size at address More... | |
void | assign (const mp_integer &address, const mp_vectort &rhs) |
sets the memory at address with the given rhs value (up to sizeof(rhs)) More... | |
void | read (const mp_integer &address, mp_vectort &dest) const |
Reads a memory address and loads it into the dest variable. More... | |
void | read_unbounded (const mp_integer &address, mp_vectort &dest) const |
virtual void | command () |
reads a user command and executes it. More... | |
bool | evaluate_boolean (const exprt &expr) |
bool | count_type_leaves (const typet &source_type, mp_integer &result) |
Count the number of leaf subtypes of ty , a leaf type is a type that is not an array or a struct. More... | |
bool | byte_offset_to_memory_offset (const typet &source_type, const mp_integer &byte_offset, mp_integer &result) |
Supposing the caller has an mp_vector representing a value with type 'source_type', this yields the offset into that vector at which to find a value at byte address 'offset'. More... | |
bool | memory_offset_to_byte_offset (const typet &source_type, const mp_integer &cell_offset, mp_integer &result) |
Similarly to the above, the interpreter's memory objects contain mp_integers that represent variable-sized struct members. More... | |
mp_vectort | evaluate (const exprt &) |
Evaluate an expression. More... | |
mp_integer | evaluate_address (const exprt &expr, bool fail_quietly=false) |
void | initialize (bool init) |
Initializes the memory map of the interpreter and [optionally] runs up to the entry point (thus doing the cprover initialization) More... | |
void | show_state () |
displays the current position of the pc and corresponding code More... | |
Protected Attributes | |
messaget | output |
const symbol_table_baset & | symbol_table |
const namespacet | ns |
const goto_functionst & | goto_functions |
memory_mapt | memory_map |
inverse_memory_mapt | inverse_memory_map |
memoryt | memory |
mp_integer | stack_pointer |
call_stackt | call_stack |
input_valuest | input_vars |
list_input_varst | function_input_vars |
goto_functionst::function_mapt::const_iterator | function |
goto_programt::const_targett | pc |
goto_programt::const_targett | next_pc |
goto_tracet | steps |
bool | done |
bool | show |
size_t | num_steps |
size_t | total_steps |
dynamic_typest | dynamic_types |
int | num_dynamic_objects |
unsigned | thread_id |
Static Protected Attributes | |
static const size_t | npos =std::numeric_limits<size_t>::max() |
Friends | |
class | interpreter_testt |
Definition at line 28 of file interpreter_class.h.
typedef std::pair<irep_idt, irep_idt> interpretert::assignment_idt |
Definition at line 62 of file interpreter_class.h.
|
protected |
Definition at line 257 of file interpreter_class.h.
typedef std::pair<exprt, exprt> interpretert::diff_pairt |
Definition at line 65 of file interpreter_class.h.
typedef std::map<irep_idt, typet> interpretert::dynamic_typest |
Definition at line 77 of file interpreter_class.h.
typedef std::list<function_assignments_contextt> interpretert::function_assignments_contextst |
Definition at line 94 of file interpreter_class.h.
typedef std::vector<function_assignmentt> interpretert::function_assignmentst |
Definition at line 57 of file interpreter_class.h.
typedef std::pair<irep_idt, exprt> interpretert::input_entryt |
Definition at line 71 of file interpreter_class.h.
typedef std::map<irep_idt, exprt> interpretert::input_valuest |
Definition at line 74 of file interpreter_class.h.
|
protected |
Definition at line 110 of file interpreter_class.h.
typedef std::map<irep_idt, std::list<function_assignments_contextt> > interpretert::list_input_varst |
Definition at line 96 of file interpreter_class.h.
|
protected |
Definition at line 109 of file interpreter_class.h.
|
protected |
Definition at line 181 of file interpreter_class.h.
typedef std::vector<mp_integer> interpretert::mp_vectort |
Definition at line 59 of file interpreter_class.h.
typedef std::map<irep_idt, function_assignmentst> interpretert::output_valuest |
Definition at line 79 of file interpreter_class.h.
|
protected |
Definition at line 182 of file interpreter_class.h.
typedef std::map<assignment_idt, diff_pairt> interpretert::side_effects_differencet |
Definition at line 68 of file interpreter_class.h.
|
protected |
Definition at line 184 of file interpreter_class.h.
|
protected |
Definition at line 185 of file interpreter_class.h.
|
inline |
Definition at line 31 of file interpreter_class.h.
|
inlineprotected |
Definition at line 114 of file interpreter_class.h.
|
inlineprotected |
Definition at line 131 of file interpreter_class.h.
|
inlineprotected |
Definition at line 126 of file interpreter_class.h.
|
protected |
reserves memory block of size at address
Definition at line 85 of file interpreter_evaluate.cpp.
|
protected |
sets the memory at address with the given rhs value (up to sizeof(rhs))
Definition at line 693 of file interpreter.cpp.
|
inlineprotected |
Definition at line 147 of file interpreter_class.h.
|
inlineprotected |
Definition at line 136 of file interpreter_class.h.
|
protected |
Creates a memory map of all static symbols in the program.
Definition at line 842 of file interpreter.cpp.
|
protected |
Populates dynamic entries of the memory map.
Definition at line 909 of file interpreter.cpp.
|
protected |
Definition at line 860 of file interpreter.cpp.
|
protected |
Supposing the caller has an mp_vector representing a value with type 'source_type', this yields the offset into that vector at which to find a value at byte address 'offset'.
We need this because the interpreter's memory map uses unlabelled variable-width values – for example, a C value { { 1, 2 }, 3, 4 } of type struct { int x[2]; char y; unsigned long z; } would be represented [1,2,3,4], with the source type needed alongside to figure out which member is targeted by a byte-extract operation.
Definition at line 160 of file interpreter_evaluate.cpp.
|
protected |
Clears memoy r/w flag initialization.
Definition at line 102 of file interpreter_evaluate.cpp.
|
protectedvirtual |
reads a user command and executes it.
Definition at line 129 of file interpreter.cpp.
turns a variable length array type into a fixed array type
Definition at line 883 of file interpreter.cpp.
|
protected |
Count the number of leaf subtypes of ty
, a leaf type is a type that is not an array or a struct.
For instance the count for a type such as struct { (int[3])[5]; int }
would be 16 = (3 * 5 + 1).
ty | a type | |
[out] | result | Number of leaf primitive types in ty |
Definition at line 118 of file interpreter_evaluate.cpp.
|
protected |
Evaluate an expression.
expr | expression to evaluate |
Definition at line 312 of file interpreter_evaluate.cpp.
|
protected |
Definition at line 996 of file interpreter_evaluate.cpp.
|
inlineprotected |
Definition at line 276 of file interpreter_class.h.
|
protected |
Definition at line 724 of file interpreter.cpp.
|
protected |
executes the assign statement at the current pc value
Definition at line 649 of file interpreter.cpp.
|
protected |
Definition at line 718 of file interpreter.cpp.
|
protected |
Definition at line 418 of file interpreter.cpp.
|
protected |
Definition at line 734 of file interpreter.cpp.
|
protected |
executes a goto instruction
Definition at line 369 of file interpreter.cpp.
|
protected |
executes side effects of 'other' instructions
Definition at line 384 of file interpreter.cpp.
|
protected |
Retrieves the member at offset
of an object of type object_type
.
Definition at line 425 of file interpreter.cpp.
|
inline |
Definition at line 98 of file interpreter_class.h.
|
protected |
Retrieves the actual size of the provided structured type.
Unbounded objects get allocated 2^(platform bit-width / 2 + 1) address space each.
type | a structured type |
Definition at line 963 of file interpreter.cpp.
returns the type object corresponding to id
Definition at line 448 of file interpreter.cpp.
Definition at line 1025 of file interpreter.cpp.
|
protected |
retrives the constant value at memory location offset as an object of type type
Definition at line 458 of file interpreter.cpp.
|
protected |
returns the value at offset in the form of type given a memory buffer rhs which is typically a structured type
Definition at line 523 of file interpreter.cpp.
|
protected |
Initializes the memory map of the interpreter and [optionally] runs up to the entry point (thus doing the cprover initialization)
Definition at line 62 of file interpreter.cpp.
|
protected |
Similarly to the above, the interpreter's memory objects contain mp_integers that represent variable-sized struct members.
This counts the size of type leaves to determine the byte offset corresponding to a memory offset.
Definition at line 241 of file interpreter_evaluate.cpp.
void interpretert::operator() | ( | void | ) |
Definition at line 38 of file interpreter.cpp.
void interpretert::print_memory | ( | bool | input_flags | ) |
Prints the current state of the memory map Since messaget mdofifies class members, print functions are nonconst.
Definition at line 1045 of file interpreter.cpp.
|
protected |
Reads a memory address and loads it into the dest
variable.
Marks cell as READ_BEFORE_WRITTEN
if cell has never been written.
Definition at line 31 of file interpreter_evaluate.cpp.
|
protected |
Definition at line 55 of file interpreter_evaluate.cpp.
|
protected |
displays the current position of the pc and corresponding code
Definition at line 110 of file interpreter.cpp.
|
protected |
executes a single step and updates the program counter
Definition at line 234 of file interpreter.cpp.
|
protected |
Definition at line 940 of file interpreter.cpp.
|
friend |
Definition at line 305 of file interpreter_class.h.
|
protected |
Definition at line 259 of file interpreter_class.h.
|
protected |
Definition at line 266 of file interpreter_class.h.
|
protected |
Definition at line 272 of file interpreter_class.h.
|
protected |
Definition at line 263 of file interpreter_class.h.
|
protected |
Definition at line 261 of file interpreter_class.h.
|
protected |
Definition at line 107 of file interpreter_class.h.
|
protected |
Definition at line 260 of file interpreter_class.h.
|
protected |
Definition at line 112 of file interpreter_class.h.
|
mutableprotected |
Definition at line 190 of file interpreter_class.h.
|
protected |
Definition at line 111 of file interpreter_class.h.
|
protected |
Definition at line 264 of file interpreter_class.h.
|
staticprotected |
Definition at line 268 of file interpreter_class.h.
|
protected |
Definition at line 105 of file interpreter_class.h.
|
protected |
Definition at line 273 of file interpreter_class.h.
|
protected |
Definition at line 269 of file interpreter_class.h.
|
protected |
Definition at line 101 of file interpreter_class.h.
output_valuest interpretert::output_values |
Definition at line 80 of file interpreter_class.h.
|
protected |
Definition at line 264 of file interpreter_class.h.
|
protected |
Definition at line 267 of file interpreter_class.h.
|
protected |
Definition at line 192 of file interpreter_class.h.
|
protected |
Definition at line 265 of file interpreter_class.h.
|
protected |
Definition at line 102 of file interpreter_class.h.
|
protected |
Definition at line 274 of file interpreter_class.h.
|
protected |
Definition at line 270 of file interpreter_class.h.