@@ -49,30 +49,95 @@ class memory_snapshot_harness_generatort : public goto_harness_generatort
49
49
{
50
50
}
51
51
52
+ // / 1. load memory table from the snapshot
53
+ // / 2. add initial section to the initial location
54
+ // / 3. assign global variables their snapshot values (via the harness
55
+ // / function)
56
+ // / 4. insert call of the initial location (with nondet values) into the
57
+ // / harness function
58
+ // / 5. build symbol for the harness functions
59
+ // / 6. insert harness function into \p goto_model
60
+ // / \param goto_model: goto model to be modified
61
+ // / \param harness_function_name: name of the resulting harness function
52
62
void generate (goto_modelt &goto_model, const irep_idt &harness_function_name)
53
63
override ;
54
64
55
65
protected:
66
+ // / Collect the memory-snapshot specific cmdline options (one at a time)
67
+ // / \param option: memory-snapshot | initial-location | havoc-variables
68
+ // / \param values: list of arguments related to a given option
56
69
void handle_option (
57
70
const std::string &option,
58
71
const std::list<std::string> &values) override ;
59
72
73
+ // / Check that user options make sense:
74
+ // / On their own, e.g. location number cannot be specified without a function.
75
+ // / In relation to the input program, e.g. function name must be known via
76
+ // / the symbol table.
60
77
void validate_options () override ;
61
78
79
+ // / Parse the snapshot JSON file and initialise the symbol table
80
+ // / \param file: the snapshot JSON file
81
+ // / \param snapshot: the resulting symbol table build from the snapshot
62
82
void
63
83
get_memory_snapshot (const std::string &file, symbol_tablet &snapshot) const ;
64
84
85
+ // / Turn this:
86
+ // / --------------------------------------------------------------------------
87
+ // / 0: int foo() {
88
+ // / 1: ..first_part..
89
+ // / ..
90
+ // / i: //location_number=i
91
+ // / ..
92
+ // / .. ..second_part..
93
+ // / n: }
94
+ // / --------------------------------------------------------------------------
95
+
96
+ // / Into this:
97
+ // / --------------------------------------------------------------------------
98
+ // / func_init_done;
99
+ // / __CPROVER_initialize() {
100
+ // / ...
101
+ // / func_init_done = false;
102
+ // / }
103
+ // / int foo() {
104
+ // / 0: if (func_init_done) goto 1;
105
+ // / 1: ;
106
+ // / func_init_done = true;
107
+ // / goto i;
108
+ // / ..first_part..
109
+ // / i: //location_number=i
110
+ // / ..second_part..
111
+ // / }
112
+ // / --------------------------------------------------------------------------
113
+ // / \param goto_model: Model where the modification takes place
65
114
void add_init_section (goto_modelt &goto_model) const ;
66
115
116
+ // / For each global symbol in the \p snapshot symbol table either:
117
+ // / 1) add \ref code_assignt assigning a value from the \snapshot to the
118
+ // / symbol
119
+ // / 2) recursively initialise the symbol to a non-deterministic value of the
120
+ // / right type
121
+ // / \param snapshot: snapshot to load the symbols and their values from
122
+ // / \param goto_model: model to initialise the havoc-ing
123
+ // / \param code: block of code where the assignments are added
67
124
void add_assignments_to_globals (
68
125
const symbol_tablet &snapshot,
69
126
goto_modelt &goto_model,
70
127
code_blockt &code) const ;
71
128
129
+ // / Create as many non-deterministic arguments as there are arguments of the
130
+ // / \p called_function_symbol and add a function call with those arguments
131
+ // / \param called_function_symbol: the function to be called
132
+ // / \param code: the block of code where the function call is added
72
133
void add_call_with_nondet_arguments (
73
134
const symbolt &called_function_symbol,
74
135
code_blockt &code) const ;
75
136
137
+ // / Insert the \p function into the symbol table (and the goto functions map)
138
+ // / of the \p goto_model
139
+ // / \param goto_model: goto model where the insertion is to take place
140
+ // / \param function: symbol of the function to be inserted
76
141
void insert_function (goto_modelt &goto_model, const symbolt &function) const ;
77
142
78
143
std::string memory_snapshot;
0 commit comments