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