@@ -45,6 +45,7 @@ class GlobalMessages(str, Enum):
45
45
PROGRAM = 'program'
46
46
RESULT = 'result'
47
47
MESSAGE_TEXT = 'messageText'
48
+ MESSAGE_TYPE = 'messageType'
48
49
SUCCESS = 'SUCCESS'
49
50
FAILED = 'FAILED'
50
51
REACH_CHECK_DESC = "[KANI_REACHABILITY_CHECK]"
@@ -180,6 +181,13 @@ def transform_cbmc_output(cbmc_response_string, output_style, extra_ptr_check):
180
181
181
182
# Extract property information from the restructured JSON file
182
183
properties , solver_information = extract_solver_information (cbmc_json_array )
184
+
185
+ # Check if there were any errors
186
+ errors = extract_errors (solver_information )
187
+ if errors :
188
+ print ('\n ' .join (errors ))
189
+ return 1
190
+
183
191
properties , messages = postprocess_results (properties , extra_ptr_check )
184
192
185
193
# Using Case Switching to Toggle between various output styles
@@ -265,6 +273,21 @@ def extract_solver_information(cbmc_response_json_array):
265
273
266
274
return properties , solver_information
267
275
276
+ def extract_errors (solver_information ):
277
+ """
278
+ Extract errors from the CBMC output, which are messages that have the
279
+ message type 'ERROR'
280
+ """
281
+ errors = []
282
+ for message in solver_information :
283
+ if GlobalMessages .MESSAGE_TYPE in message and message [GlobalMessages .MESSAGE_TYPE ] == 'ERROR' :
284
+ error_message = message [GlobalMessages .MESSAGE_TEXT ]
285
+ # Replace "--object bits n" with "--enable-unstable --cbmc-args
286
+ # --object bits n" in the message
287
+ if 'use the `--object-bits n` option' in error_message :
288
+ error_message = error_message .replace ("--object-bits " , "--enable-unstable --cbmc-args --object-bits " )
289
+ errors .append (error_message )
290
+ return errors
268
291
269
292
def postprocess_results (properties , extra_ptr_check ):
270
293
"""
0 commit comments