Skip to content

[depends: #1161, #1272] JSON expr and JSON trace #1271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e274395
Make configt::set_classpath private
peterschrammel Jul 25, 2017
69bed5d
Factorize setting config from symbol table when reading goto binaries
peterschrammel Jul 25, 2017
5947035
Replace BV_ADDR_BITS by config setting
peterschrammel Jul 20, 2017
be93dcc
Better error message when too many dynamic objects
peterschrammel Jul 20, 2017
7944e21
Allow specifying object-bits via command line and language defaults
peterschrammel Jul 20, 2017
fc35b49
Catch command line parsing exceptions
peterschrammel Aug 2, 2017
eed3925
Add java address space limits tests
peterschrammel Jul 20, 2017
45b705e
Tests for overflows in pointer arithmetic
peterschrammel Jul 20, 2017
6e99cd2
Fix getting model for object address (unsigned -> size_t)
peterschrammel Jul 22, 2017
2056c8e
Output message about used object bits settings
peterschrammel Jul 26, 2017
5a84883
Display dynamic object names as 'data' in JSON traces
peterschrammel Mar 28, 2017
4f37939
Add hanlded for constant strings
May 22, 2017
b1c3aa4
Use the member functions to make code more robust
May 22, 2017
934bb49
Adding simple test for trace correctness
May 23, 2017
ee2b83b
Adding a mode option to json output diffblue/test-gen#294
romainbrenguier May 5, 2017
7b27200
Call to lookup that does not throw when symbol is not found
romainbrenguier Jun 5, 2017
f7bd507
Use the from_type function to get string for the type
romainbrenguier Jun 5, 2017
a8d0a00
Adding assertion to make sure "type" field is always set
romainbrenguier Jun 7, 2017
5532660
Adding assertions to prevent the "data" field from not being set
romainbrenguier Jun 7, 2017
5c3e67c
Assertion to forbid calling json() with nil values
romainbrenguier Jun 8, 2017
49bf719
Using unique pointers to avoid memory leak in json for expressions
romainbrenguier Jun 13, 2017
ab93ab7
Simplifying expressions of the form &array[0] in json
romainbrenguier May 5, 2017
885cfe2
Simplifying array access and expressions with pointer offsets
romainbrenguier May 11, 2017
5aec3c8
Adding test to check that data field of strings are set in json
romainbrenguier Jun 13, 2017
8e037aa
Documentation for json_goto_trace in doxygen format
romainbrenguier Jun 15, 2017
695e2a5
Fix remove_pointer_offsets
smowton Jun 27, 2017
c82da48
Allow "unknown" value assignments in JSON trace
Jun 21, 2017
dbf699a
Add regression test for nil assigns in JSON trace
Jun 21, 2017
67482d7
Fix language-specific constant printing in JSON
peterschrammel Aug 2, 2017
f7bfd6b
Fix mode in input/output steps in JSON trace
peterschrammel Aug 2, 2017
e85ecd8
Replace asserts
peterschrammel Aug 8, 2017
7248d1b
Replace simplify_index by simplify_expr
peterschrammel Aug 17, 2017
8a6b357
Replace asserts
peterschrammel Aug 8, 2017
1589bf1
Test for java-specific output in JSON
peterschrammel Aug 8, 2017
bdf18be
Do not use default arguments for json(...)
tautschnig Aug 23, 2017
0f2fcc4
Simplify pointer_offset(constant)
tautschnig Aug 23, 2017
a6236ab
Use generic simplify_expr instead of local simplification rules
tautschnig Aug 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
13 changes: 13 additions & 0 deletions regression/cbmc-java/address_space_size_limit1/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Test {
int x;
Test(int x) { this.x = x; }

public static void main(String[] args) {
int i;
Test[] tests = new Test[30];
for(i = 0; i < 30; ++i) {
tests[i] = new Test(i);
}
assert i == tests[0].x;
}
}
5 changes: 5 additions & 0 deletions regression/cbmc-java/address_space_size_limit1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CORE
Test.class
--object-bits 4
too many addressed objects
--
Binary file not shown.
13 changes: 13 additions & 0 deletions regression/cbmc-java/address_space_size_limit2/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Test {
int x;
Test(int x) { this.x = x; }

public static void main(String[] args) {
int i;
Test[] tests = new Test[30];
for(i = 0; i < 30; ++i) {
tests[i] = new Test(i);
}
assert i == tests[0].x;
}
}
8 changes: 8 additions & 0 deletions regression/cbmc-java/address_space_size_limit2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
Test.class
--object-bits 8
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
^\[java::Test.main:\(\[Ljava/lang/String;\)V.assertion.1\] .*: FAILURE$
--
Binary file added regression/cbmc-java/exceptions20/A.class
Binary file not shown.
Binary file added regression/cbmc-java/exceptions20/B.class
Binary file not shown.
Binary file added regression/cbmc-java/exceptions20/C.class
Binary file not shown.
Binary file added regression/cbmc-java/exceptions20/D.class
Binary file not shown.
Binary file added regression/cbmc-java/exceptions20/test.class
Binary file not shown.
11 changes: 11 additions & 0 deletions regression/cbmc-java/exceptions20/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
test.class
--json-ui --trace
^EXIT=10$
^SIGNAL=0$
.*VERIFICATION FAILED.*
--
^warning: ignoring
--
this fails with assertion error if nil values are not allowed in assignments in
the JSON trace
30 changes: 30 additions & 0 deletions regression/cbmc-java/exceptions20/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class A extends Throwable {}
class B extends A {}
class C extends B {}
class D extends C {}

public class test {
public static void main (String arg[]) {
try {
D d = new D();
C c = new C();
B b = new B();
A a = new A();
A e = a;
throw e;
}
catch(D exc) {
assert false;
}
catch(C exc) {
assert false;
}
catch(B exc) {
assert false;
}
catch(A exc) {
assert false;
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is exceptions20 included deliberately?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is a merge error, I will review how this crept in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, no, not quite: this appears to be the regression test affiliated with d299ea2. Do you think this is not a good fit for this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I forgot about that and wondered what is has to do with JSON. ok for inclusion then.

Binary file added regression/cbmc-java/json_trace1/Test.class
Binary file not shown.
21 changes: 21 additions & 0 deletions regression/cbmc-java/json_trace1/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class Test {

byte main(byte[] a) {
if (a.length != 9) {
return -1;
}

byte diff = 0;
for (byte i = 0; i < 9; i++) {
if (a[i] == 1) {
diff++;
} else if (a[i] == 2) {
diff--;
} else if (a[i] != 0) {
return -1;
}
}

return -1;
}
}
7 changes: 7 additions & 0 deletions regression/cbmc-java/json_trace1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
Test.class
--cover location --trace --json-ui
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
Binary file added regression/cbmc-java/json_trace2/Test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/json_trace2/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Test {
boolean test(Object x) {
if(x==null)
return false;
return true;
}
}
10 changes: 10 additions & 0 deletions regression/cbmc-java/json_trace2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
Test.class
--cover location --trace --json-ui --function Test.test
activate-multi-line-match
EXIT=0
SIGNAL=0
"outputID": "return",\n *"sourceLocation": \{\n *"file": "Test\.java",\n *"function": "java::Test\.test:\(Ljava/lang/Object;\)Z",\n *"line": "3"\n *\},\n *"stepType": "output",\n *"thread": 0,\n *"values": \[\n *\{\n *"binary": "00000000",\n *"data": "false",\n *"name": "integer",\n *"type": "boolean",\n *"width": 8
"inputID": "arg1a",\n *"internal": true,\n *"mode": "java",\n *"sourceLocation": \{\n *"file": "Test\.java",\n *"function": "java::Test\.test:\(Ljava/lang/Object;\)Z",\n *"line": "3"\n *\},\n *"stepType": "input",\n *"thread": 0,\n *"values": \[\n *\{\n *"data": "null",\n *"name": "pointer",\n *"type": "struct java\.lang\.Object \{ __CPROVER_string @class_identifier; boolean @lock; \} \*"
--
^warning: ignoring
4 changes: 2 additions & 2 deletions regression/cbmc/address_space_size_limit1/test.desc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CORE
test.c
--no-simplify --unwind 300
too many variables
--no-simplify --unwind 300 --object-bits 8
too many addressed objects
--
10 changes: 10 additions & 0 deletions regression/cbmc/address_space_size_limit2/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdlib.h>
#include <assert.h>

int main(int argc, char** argv)
{
char* c=(char*)malloc(10);
char* d=c;
for(char i=0; i<10; i++, d++);
assert((size_t)d==(size_t)c+10);
}
5 changes: 5 additions & 0 deletions regression/cbmc/address_space_size_limit2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
KNOWNBUG
test.c
--32 --object-bits 31 --unwind 11 --no-simplify
dynamic object too large
--
136 changes: 136 additions & 0 deletions regression/cbmc/address_space_size_limit3/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// copy of Pointer_Arithmetic12

#include <stdint.h>

#include <assert.h>

uint32_t __stack[32];

uint32_t eax;
uint32_t ebp;
uint32_t ebx;
uint32_t ecx;
uint32_t edi;
uint32_t edx;
uint32_t esi;
uint32_t esp=(uint32_t)&(__stack[31]);
uint32_t var0;
uint32_t var1;
uint32_t var10;
uint32_t var11;
uint32_t var12;
uint32_t var13;
uint32_t var14;
uint32_t var15;
uint32_t var16;
uint32_t var2;
uint32_t var3;
uint32_t var4;
uint32_t var5;
uint32_t var6;
uint32_t var7;
uint32_t var8;
uint32_t var9;

void g__L_0x3b4_0()
{
L_0x3b4_0: esp-=0x4;
L_0x3b4_1: *(uint32_t*)(esp)=ebp;
L_0x3b5_0: ebp=esp;
L_0x3b7_0: var4=ebp;
L_0x3b7_1: var4+=0xc;
L_0x3b7_2: eax=*(uint32_t*)(var4);
L_0x3ba_0: edx=eax;
L_0x3bc_0: edx&=0x3;
L_0x3bf_0: var5=ebp;
L_0x3bf_1: var5+=0x8;
L_0x3bf_2: eax=*(uint32_t*)(var5);
L_0x3c2_0: *(uint32_t*)(eax)=edx;
L_0x3c4_0: ebp=*(uint32_t*)(esp);
L_0x3c4_1: esp+=0x4;
L_0x3c5_0: return;
}

void f__L_0x3c6_0()
{
L_0x3c6_0: esp-=0x4;
L_0x3c6_1: *(uint32_t*)(esp)=ebp;
L_0x3c7_0: ebp=esp;
L_0x3c9_0: esp-=0x18;
L_0x3cc_0: var6=ebp;
L_0x3cc_1: var6-=0x4;
L_0x3cc_2: *(uint32_t*)(var6)=0x0;
L_0x3d3_0: var7=ebp;
L_0x3d3_1: var7-=0x8;
L_0x3d3_2: *(uint32_t*)(var7)=0x0;
L_0x3da_0: var8=ebp;
L_0x3da_1: var8+=0x8;
L_0x3da_2: eax=*(uint32_t*)(var8);
L_0x3dd_0: var9=ebp;
L_0x3dd_1: var9-=0x4;
L_0x3dd_2: *(uint32_t*)(var9)=eax;
L_0x3e0_0: var10=ebp;
L_0x3e0_1: var10-=0x4;
L_0x3e0_2: eax=*(uint32_t*)(var10);
L_0x3e3_0: var11=esp;
L_0x3e3_1: var11+=0x4;
L_0x3e3_2: *(uint32_t*)(var11)=eax;
L_0x3e7_0: var12=ebp;
L_0x3e7_1: var12-=0x8;
L_0x3e7_2: eax=(uint32_t)&*(uint32_t*)(var12);
L_0x3ea_0: *(uint32_t*)(esp)=eax;
L_0x3ed_0: esp-=4; g__L_0x3b4_0(); esp+=4;
L_0x3f2_0: var13=ebp;
L_0x3f2_1: var13-=0x4;
L_0x3f2_2: *(uint32_t*)(var13)=0x5;
L_0x3f9_0: var14=ebp;
L_0x3f9_1: var14-=0x8;
L_0x3f9_2: eax=*(uint32_t*)(var14);
L_0x3fc_0: esp=ebp;
L_0x3fc_1: ebp=*(uint32_t*)(esp);
L_0x3fc_2: esp+=0x4;
L_0x3fd_0: return;
}

int main()
{
L_0x3fe_0: esp-=0x4;
L_0x3fe_1: *(uint32_t*)(esp)=ebp;
L_0x3ff_0: ebp=esp;
L_0x401_0: esp-=0x14;
L_0x404_0: var15=ebp;
L_0x404_1: var15-=0x4;
#ifdef NONDET
L_0x404_2: *(uint32_t*)(var15)=nondet_uint();
#else
L_0x404_2: *(uint32_t*)(var15)=0xffffffff;
#endif
L_0x40b_0: var16=ebp;
L_0x40b_1: var16-=0x4;
L_0x40b_2: eax=*(uint32_t*)(var16);
L_0x40e_0: *(uint32_t*)(esp)=eax;
L_0x411_0: esp-=4; f__L_0x3c6_0(); esp+=4;
#if 1
uint32_t eax1=eax;
C_0x3ff_0: ebp=esp;
C_0x401_0: esp-=0x14;
C_0x404_0: var15=ebp;
C_0x404_1: var15-=0x4;
#ifdef NONDET
C_0x404_2: *(uint32_t*)(var15)=nondet_uint();
#else
C_0x404_2: *(uint32_t*)(var15)=0xffffffff;
#endif
C_0x40b_0: var16=ebp;
C_0x40b_1: var16-=0x4;
C_0x40b_2: eax=*(uint32_t*)(var16);
C_0x40e_0: *(uint32_t*)(esp)=eax;
C_0x411_0: esp-=4; f__L_0x3c6_0(); esp+=4;
uint32_t eax2=eax;
assert(eax2==eax1);
#endif
L_0x416_0: esp=ebp;
L_0x416_1: ebp=*(uint32_t*)(esp);
L_0x416_2: esp+=0x4;
L_0x417_0: return 0;
}
11 changes: 11 additions & 0 deletions regression/cbmc/address_space_size_limit3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--32 --little-endian --object-bits 25 --pointer-check
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
^.* dereference failure: pointer outside object bounds in .*: FAILURE$
--
^warning: ignoring
--
requires at least 8 offset bits
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc/trace_class_identifier/TestGenTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class TestGenTest
{
public void f()
{
int a = 4;
}
}
8 changes: 8 additions & 0 deletions regression/cbmc/trace_class_identifier/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
TestGenTest.class
--function TestGenTest.f --trace --cover location --json-ui
"data": "java::TestGenTest",$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
Binary file added regression/strings-smoke-tests/jsonArrays/test.class
Binary file not shown.
10 changes: 10 additions & 0 deletions regression/strings-smoke-tests/jsonArrays/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
test.class
--refine-strings --function test.check --json-ui --trace --string-max-length 100 --cover location
^EXIT=0$
^SIGNAL=0$
\"data\".*\"tmp_object_factory\$6.*\"
--
This checks that tmp_object_factory$6 gets affected to the data field
of some strings, which was not the case in previous versions of cbmc,
as it was just ignored by the json output.
8 changes: 8 additions & 0 deletions regression/strings-smoke-tests/jsonArrays/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class test
{
public static int check(String s)
{
int i=Integer.parseInt(s);
return i;
}
}
3 changes: 2 additions & 1 deletion src/cbmc/bmc_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ bool bmc_covert::operator()()
json_objectt json_input;
json_input["id"]=json_stringt(id2string(step.io_id));
if(step.io_args.size()==1)
json_input["value"]=json(step.io_args.front(), bmc.ns);
json_input["value"]=
json(step.io_args.front(), bmc.ns, ID_unknown);
json_test.push_back(json_input);
}
}
Expand Down
Loading