Skip to content

Commit cf56b53

Browse files
Add json-interface to CBMC
Allows reading the commandline in JSON format from stdin.
1 parent 316f1d6 commit cf56b53

File tree

6 files changed

+48
-1
lines changed

6 files changed

+48
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
3+
void foo(int x)
4+
{
5+
for(int i = 0; i < 5; ++i)
6+
{
7+
if(x)
8+
assert(0);
9+
assert(0);
10+
}
11+
assert(0);
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE broken-smt-backend
2+
--json-interface
3+
< test.json
4+
activate-multi-line-match
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
Not unwinding loop foo\.0 iteration 3 file main\.c line 5 function foo thread 0
8+
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"status": "SUCCESS"\n\s*\}
9+
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"status": "FAILURE",\n\s*"trace": \[
10+
VERIFICATION FAILED
11+
--
12+
"property": "foo\.assertion\.2"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"arguments": [
3+
"main.c"
4+
],
5+
"options": {
6+
"function": "foo",
7+
"unwind": 3,
8+
"property": [
9+
"foo.assertion.1",
10+
"foo.assertion.3"
11+
],
12+
"trace": true,
13+
"show-properties": false
14+
}
15+
}

src/cbmc/cbmc_parse_options.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ Author: Daniel Kroening, [email protected]
7979

8080
#include <langapi/mode.h>
8181

82+
#include <json/json_interface.h>
83+
8284
#include "c_test_input_generator.h"
8385
#include "xml_interface.h"
8486

@@ -90,6 +92,7 @@ cbmc_parse_optionst::cbmc_parse_optionst(int argc, const char **argv)
9092
std::string("CBMC ") + CBMC_VERSION),
9193
xml_interfacet(cmdline)
9294
{
95+
json_interface(cmdline, ui_message_handler);
9396
}
9497

9598
::cbmc_parse_optionst::cbmc_parse_optionst(
@@ -103,6 +106,7 @@ ::cbmc_parse_optionst::cbmc_parse_optionst(
103106
std::string("CBMC ") + CBMC_VERSION),
104107
xml_interfacet(cmdline)
105108
{
109+
json_interface(cmdline, ui_message_handler);
106110
}
107111

108112
void cbmc_parse_optionst::set_default_options(optionst &options)
@@ -1030,6 +1034,7 @@ void cbmc_parse_optionst::help()
10301034
" --xml-ui use XML-formatted output\n"
10311035
" --xml-interface bi-directional XML interface\n"
10321036
" --json-ui use JSON-formatted output\n"
1037+
" --json-interface bi-directional JSON interface\n"
10331038
// NOLINTNEXTLINE(whitespace/line_length)
10341039
HELP_VALIDATE
10351040
HELP_GOTO_TRACE

src/cbmc/cbmc_parse_options.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class optionst;
4949
"(object-bits):" \
5050
OPT_GOTO_CHECK \
5151
"(no-assertions)(no-assumptions)" \
52-
"(xml-ui)(xml-interface)(json-ui)" \
52+
"(xml-ui)(xml-interface)" \
53+
"(json-interface)" \
54+
"(json-ui)" \
5355
"(smt1)(smt2)(fpa)(cvc3)(cvc4)(boolector)(yices)(z3)(mathsat)" \
5456
"(cprover-smt2)" \
5557
"(no-sat-preprocessor)" \

src/cbmc/module_dependencies.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ goto-instrument
77
goto-programs
88
goto-symex
99
jsil
10+
json
1011
json-symtab-language
1112
langapi # should go away
1213
linking

0 commit comments

Comments
 (0)