46
46
#include < util/msgstream.h>
47
47
#include < util/prefix.h>
48
48
#include < util/json_map_serializer.h>
49
+ #include < util/exit_codes.h>
49
50
50
51
#include < cbmc/version.h>
51
52
@@ -135,7 +136,7 @@ int sec_driver_parse_optionst::doit()
135
136
if (cmdline.isset (" version" ))
136
137
{
137
138
std::cout << CBMC_VERSION << std::endl;
138
- return 0 ;
139
+ return CPROVER_EXIT_SUCCESS ;
139
140
}
140
141
141
142
//
@@ -176,7 +177,7 @@ int sec_driver_parse_optionst::doit()
176
177
{
177
178
error () << " lazy-methods-context-sensitive requires --function to be set"
178
179
<< messaget::eom;
179
- return 6 ;
180
+ return CPROVER_EXIT_USAGE_ERROR ;
180
181
}
181
182
csvsa_analysis=
182
183
csvsa_load_and_analyze_functions (lazy_goto_model, get_message_handler ());
@@ -189,14 +190,14 @@ int sec_driver_parse_optionst::doit()
189
190
if (cmdline.isset (" show-symbol-table" ))
190
191
{
191
192
::show_symbol_table (lazy_goto_model.symbol_table, get_ui());
192
- return 6 ;
193
+ return CPROVER_EXIT_SUCCESS ;
193
194
}
194
195
195
196
std::unique_ptr<goto_modelt> maybe_goto_model =
196
197
lazy_goto_modelt::process_whole_model_and_freeze (
197
198
std::move (lazy_goto_model));
198
199
if (maybe_goto_model == nullptr )
199
- return 6 ;
200
+ return CPROVER_EXIT_INTERNAL_ERROR ;
200
201
goto_modelt &goto_model = *maybe_goto_model;
201
202
202
203
// show it?
@@ -205,7 +206,7 @@ int sec_driver_parse_optionst::doit()
205
206
namespacet ns (goto_model.symbol_table );
206
207
207
208
goto_model.goto_functions .output (ns, std::cout);
208
- return 6 ;
209
+ return CPROVER_EXIT_SUCCESS ;
209
210
}
210
211
211
212
if (cmdline.isset (" do-not-use-precise-access-paths" ))
@@ -215,11 +216,20 @@ int sec_driver_parse_optionst::doit()
215
216
216
217
if (cmdline.isset (" security-scanner" ))
217
218
{
218
- return taint_do_security_scan (
219
- cmdline.get_value (" security-scanner" ),
220
- goto_model,
221
- cmdline.isset (" rebuild-taint-cache" ),
222
- *this ) ? 0 : 127 ;
219
+ try
220
+ {
221
+ return taint_do_security_scan (
222
+ cmdline.get_value (" security-scanner" ),
223
+ goto_model,
224
+ cmdline.isset (" rebuild-taint-cache" ),
225
+ *this ) ? CPROVER_EXIT_SUCCESS : CPROVER_EXIT_INCORRECT_TASK;
226
+ }
227
+ catch (const std::exception &e)
228
+ {
229
+ error ()
230
+ << " ERROR: This exception was raised: " << e.what () << messaget::eom;
231
+ return CPROVER_EXIT_EXCEPTION;
232
+ }
223
233
}
224
234
225
235
if (cmdline.isset (" local-value-set-analysis" ))
@@ -228,7 +238,7 @@ int sec_driver_parse_optionst::doit()
228
238
if (dbpath==" " )
229
239
{
230
240
error () << " Must specify lvsa-summary-directory" << eom;
231
- abort () ;
241
+ return CPROVER_EXIT_USAGE_ERROR ;
232
242
}
233
243
234
244
json_map_serializert<irep_idt, lvsaa_single_external_set_summaryt>
@@ -252,7 +262,7 @@ int sec_driver_parse_optionst::doit()
252
262
debug () << " " << f.first .c_str () << " \n " ;
253
263
}
254
264
debug () << eom;
255
- abort () ;
265
+ return CPROVER_EXIT_INCORRECT_TASK ;
256
266
}
257
267
const auto & gf=goto_model.goto_functions .function_map .at (fname);
258
268
class_hierarchyt class_hierarchy;
@@ -330,7 +340,7 @@ int sec_driver_parse_optionst::doit()
330
340
status () << dump_message << eom;
331
341
}
332
342
}
333
- return 0 ;
343
+ return CPROVER_EXIT_SUCCESS ;
334
344
}
335
345
336
346
if (cmdline.isset (" dump-html-program" ))
@@ -347,7 +357,7 @@ int sec_driver_parse_optionst::doit()
347
357
<< cmdline.get_value (" dump-html-program" )
348
358
<< " ' for the HTML dump exists."
349
359
<< eom;
350
- return - 1 ;
360
+ return CPROVER_EXIT_INCORRECT_TASK ;
351
361
}
352
362
class_hierarchyt class_hierarchy;
353
363
class_hierarchy (goto_model.symbol_table );
@@ -361,12 +371,12 @@ int sec_driver_parse_optionst::doit()
361
371
goto_model.symbol_table ,
362
372
inverted_topological_order,
363
373
cmdline.get_value (" dump-html-program" ));
364
- return 0 ;
374
+ return CPROVER_EXIT_SUCCESS ;
365
375
}
366
376
367
377
error () << " no analysis option given -- consider reading --help"
368
378
<< eom;
369
- return 6 ;
379
+ return CPROVER_EXIT_INCORRECT_TASK ;
370
380
}
371
381
372
382
void sec_driver_parse_optionst::process_goto_function (
0 commit comments