@@ -11,8 +11,8 @@ Author: Daniel Kroening, Peter Schrammel
11
11
12
12
#include " bmc_util.h"
13
13
14
- #include < iostream>
15
14
#include < fstream>
15
+ #include < iostream>
16
16
17
17
#include < cbmc/symex_bmc.h>
18
18
@@ -33,55 +33,57 @@ Author: Daniel Kroening, Peter Schrammel
33
33
#include < util/make_unique.h>
34
34
#include < util/ui_message.h>
35
35
36
-
37
- void build_error_trace ( goto_tracet &goto_trace,
38
- const namespacet &ns,
39
- const symex_target_equationt &symex_target_equation,
40
- const prop_convt &prop_conv,
41
- ui_message_handlert &ui_message_handler)
36
+ void build_error_trace (
37
+ goto_tracet &goto_trace,
38
+ const namespacet &ns,
39
+ const symex_target_equationt &symex_target_equation,
40
+ const prop_convt &prop_conv,
41
+ ui_message_handlert &ui_message_handler)
42
42
{
43
43
messaget msg (ui_message_handler);
44
44
msg.status () << " Building error trace" << messaget::eom;
45
45
46
46
build_goto_trace (symex_target_equation, prop_conv, ns, goto_trace);
47
47
}
48
48
49
- void output_error_trace (const goto_tracet &goto_trace, const namespacet &ns,
50
- const trace_optionst &trace_options,
51
- ui_message_handlert &ui_message_handler)
49
+ void output_error_trace (
50
+ const goto_tracet &goto_trace,
51
+ const namespacet &ns,
52
+ const trace_optionst &trace_options,
53
+ ui_message_handlert &ui_message_handler)
52
54
{
53
55
messaget msg (ui_message_handler);
54
56
switch (ui_message_handler.get_ui ())
55
57
{
56
- case ui_message_handlert::uit::PLAIN:
57
- msg.result () << " Counterexample:" << messaget::eom;
58
- show_goto_trace (msg.result (), ns, goto_trace, trace_options);
59
- msg.result () << messaget::eom;
60
- break ;
58
+ case ui_message_handlert::uit::PLAIN:
59
+ msg.result () << " Counterexample:" << messaget::eom;
60
+ show_goto_trace (msg.result (), ns, goto_trace, trace_options);
61
+ msg.result () << messaget::eom;
62
+ break ;
61
63
62
- case ui_message_handlert::uit::XML_UI:
63
- {
64
- xmlt xml;
65
- convert (ns, goto_trace, xml);
66
- msg.status () << xml;
67
- }
68
- break ;
64
+ case ui_message_handlert::uit::XML_UI:
65
+ {
66
+ xmlt xml;
67
+ convert (ns, goto_trace, xml);
68
+ msg.status () << xml;
69
+ }
70
+ break ;
69
71
70
- case ui_message_handlert::uit::JSON_UI:
71
- {
72
- json_stream_objectt &json_result =
73
- ui_message_handler.get_json_stream ().push_back_stream_object ();
74
- const goto_trace_stept &step= goto_trace.steps .back ();
75
- json_result[" property" ] =
76
- json_stringt (step.pc ->source_location .get_property_id ());
77
- json_result[" description" ] =
78
- json_stringt (step.pc ->source_location .get_comment ());
79
- json_result[" status" ]= json_stringt (" failed" );
80
- json_stream_arrayt &json_trace =
81
- json_result.push_back_stream_array (" trace" );
82
- convert<json_stream_arrayt>(ns, goto_trace, json_trace, trace_options);
83
- }
84
- break ;
72
+ case ui_message_handlert::uit::JSON_UI:
73
+ {
74
+ json_stream_objectt &json_result =
75
+ ui_message_handler.get_json_stream ().push_back_stream_object ();
76
+ const goto_trace_stept &step = goto_trace.steps .back ();
77
+ json_result[" property" ] =
78
+ json_stringt (step.pc ->source_location .get_property_id ());
79
+ json_result[" description" ] =
80
+ json_stringt (step.pc ->source_location .get_comment ());
81
+ json_result[" status" ] = json_stringt (" failed" );
82
+ json_stream_arrayt &json_trace =
83
+ json_result.push_back_stream_array (" trace" );
84
+ convert<json_stream_arrayt>(ns, goto_trace, json_trace, trace_options);
85
+ }
86
+ break ;
85
87
}
86
88
}
87
89
@@ -93,19 +95,19 @@ void output_graphml(
93
95
const namespacet &ns,
94
96
const optionst &options)
95
97
{
96
- const std::string graphml= options.get_option (" graphml-witness" );
98
+ const std::string graphml = options.get_option (" graphml-witness" );
97
99
if (graphml.empty ())
98
100
return ;
99
101
100
102
graphml_witnesst graphml_witness (ns);
101
- if (result== safety_checkert::resultt::UNSAFE)
103
+ if (result == safety_checkert::resultt::UNSAFE)
102
104
graphml_witness (goto_trace);
103
- else if (result== safety_checkert::resultt::SAFE)
105
+ else if (result == safety_checkert::resultt::SAFE)
104
106
graphml_witness (symex_target_equation);
105
107
else
106
108
return ;
107
109
108
- if (graphml== " -" )
110
+ if (graphml == " -" )
109
111
write_graphml (graphml_witness.graph (), std::cout);
110
112
else
111
113
{
@@ -126,33 +128,33 @@ void convert_symex_target_equation(
126
128
equation.convert (prop_conv);
127
129
}
128
130
129
- std::unique_ptr<memory_model_baset> get_memory_model (
130
- const optionst &options,
131
- const namespacet &ns)
131
+ std::unique_ptr<memory_model_baset>
132
+ get_memory_model (const optionst &options, const namespacet &ns)
132
133
{
133
- const std::string mm= options.get_option (" mm" );
134
+ const std::string mm = options.get_option (" mm" );
134
135
135
- if (mm.empty () || mm== " sc" )
136
+ if (mm.empty () || mm == " sc" )
136
137
return util_make_unique<memory_model_sct>(ns);
137
- else if (mm== " tso" )
138
+ else if (mm == " tso" )
138
139
return util_make_unique<memory_model_tsot>(ns);
139
- else if (mm== " pso" )
140
+ else if (mm == " pso" )
140
141
return util_make_unique<memory_model_psot>(ns);
141
142
else
142
143
{
143
144
throw " invalid memory model '" + mm + " ': use one of sc, tso, pso" ;
144
145
}
145
146
}
146
147
147
- void setup_symex (symex_bmct &symex,
148
- const namespacet &ns,
149
- const optionst &options,
150
- ui_message_handlert &ui_message_handler)
148
+ void setup_symex (
149
+ symex_bmct &symex,
150
+ const namespacet &ns,
151
+ const optionst &options,
152
+ ui_message_handlert &ui_message_handler)
151
153
{
152
154
messaget msg (ui_message_handler);
153
155
const symbolt *init_symbol;
154
156
if (!ns.lookup (INITIALIZE_FUNCTION, init_symbol))
155
- symex.language_mode = init_symbol->mode ;
157
+ symex.language_mode = init_symbol->mode ;
156
158
157
159
msg.status () << " Starting Bounded Model Checking" << messaget::eom;
158
160
@@ -170,13 +172,12 @@ void slice(
170
172
ui_message_handlert &ui_message_handler)
171
173
{
172
174
messaget msg (ui_message_handler);
173
- if (options.get_option (" slice-by-trace" )!= " " )
175
+ if (options.get_option (" slice-by-trace" ) != " " )
174
176
{
175
177
symex_slice_by_tracet symex_slice_by_trace (ns);
176
178
177
- symex_slice_by_trace.slice_by_trace
178
- (options.get_option (" slice-by-trace" ),
179
- symex_target_equation);
179
+ symex_slice_by_trace.slice_by_trace (
180
+ options.get_option (" slice-by-trace" ), symex_target_equation);
180
181
}
181
182
// any properties to check at all?
182
183
if (symex_target_equation.has_threads ())
@@ -190,24 +191,23 @@ void slice(
190
191
{
191
192
::slice (symex_target_equation);
192
193
msg.statistics () << " slicing removed "
193
- << symex_target_equation.count_ignored_SSA_steps ()
194
- << " assignments" << messaget::eom;
194
+ << symex_target_equation.count_ignored_SSA_steps ()
195
+ << " assignments" << messaget::eom;
195
196
}
196
197
else
197
198
{
198
199
if (options.get_list_option (" cover" ).empty ())
199
200
{
200
201
simple_slice (symex_target_equation);
201
202
msg.statistics () << " simple slicing removed "
202
- << symex_target_equation.count_ignored_SSA_steps ()
203
- << " assignments" << messaget::eom;
203
+ << symex_target_equation.count_ignored_SSA_steps ()
204
+ << " assignments" << messaget::eom;
204
205
}
205
206
}
206
207
}
207
- msg.statistics () << " Generated "
208
- << symex.get_total_vccs () <<" VCC(s), "
209
- << symex.get_remaining_vccs ()
210
- << " remaining after simplification" << messaget::eom;
208
+ msg.statistics () << " Generated " << symex.get_total_vccs () << " VCC(s), "
209
+ << symex.get_remaining_vccs ()
210
+ << " remaining after simplification" << messaget::eom;
211
211
}
212
212
213
213
void report_success (ui_message_handlert &ui_message_handler)
@@ -217,24 +217,24 @@ void report_success(ui_message_handlert &ui_message_handler)
217
217
218
218
switch (ui_message_handler.get_ui ())
219
219
{
220
- case ui_message_handlert::uit::PLAIN:
221
- break ;
220
+ case ui_message_handlert::uit::PLAIN:
221
+ break ;
222
222
223
- case ui_message_handlert::uit::XML_UI:
224
- {
225
- xmlt xml (" cprover-status" );
226
- xml.data = " SUCCESS" ;
227
- msg.result () << xml;
228
- }
229
- break ;
223
+ case ui_message_handlert::uit::XML_UI:
224
+ {
225
+ xmlt xml (" cprover-status" );
226
+ xml.data = " SUCCESS" ;
227
+ msg.result () << xml;
228
+ }
229
+ break ;
230
230
231
- case ui_message_handlert::uit::JSON_UI:
232
- {
233
- json_objectt json_result;
234
- json_result[" cProverStatus" ]= json_stringt (" success" );
235
- msg.result () << json_result;
236
- }
237
- break ;
231
+ case ui_message_handlert::uit::JSON_UI:
232
+ {
233
+ json_objectt json_result;
234
+ json_result[" cProverStatus" ] = json_stringt (" success" );
235
+ msg.result () << json_result;
236
+ }
237
+ break ;
238
238
}
239
239
}
240
240
@@ -245,23 +245,23 @@ void report_failure(ui_message_handlert &ui_message_handler)
245
245
246
246
switch (ui_message_handler.get_ui ())
247
247
{
248
- case ui_message_handlert::uit::PLAIN:
249
- break ;
248
+ case ui_message_handlert::uit::PLAIN:
249
+ break ;
250
250
251
- case ui_message_handlert::uit::XML_UI:
252
- {
253
- xmlt xml (" cprover-status" );
254
- xml.data = " FAILURE" ;
255
- msg.result () << xml;
256
- }
257
- break ;
251
+ case ui_message_handlert::uit::XML_UI:
252
+ {
253
+ xmlt xml (" cprover-status" );
254
+ xml.data = " FAILURE" ;
255
+ msg.result () << xml;
256
+ }
257
+ break ;
258
258
259
- case ui_message_handlert::uit::JSON_UI:
260
- {
261
- json_objectt json_result;
262
- json_result[" cProverStatus" ] = json_stringt (" failure" );
263
- msg.result () << json_result;
264
- }
265
- break ;
259
+ case ui_message_handlert::uit::JSON_UI:
260
+ {
261
+ json_objectt json_result;
262
+ json_result[" cProverStatus" ] = json_stringt (" failure" );
263
+ msg.result () << json_result;
264
+ }
265
+ break ;
266
266
}
267
267
}
0 commit comments