Skip to content

Load memory snapshot into cbmc #3755

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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"symbolTable": {
"x": {
"baseName": "x",
"isAuxiliary": false,
"isExported": false,
"isExtern": false,
"isFileLocal": false,
"isInput": false,
"isLvalue": true,
"isMacro": false,
"isOutput": false,
"isParameter": false,
"isProperty": false,
"isStateVar": false,
"isStaticLifetime": true,
"isThreadLocal": false,
"isType": false,
"isVolatile": false,
"isWeak": false,
"location": {},
"mode": "C",
"module": "main",
"name": "x",
"prettyName": "x",
"type": {
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_int"
},
"width": {
"id": "32"
}
}
},
"value": {
"id": "constant",
"namedSub": {
"#base": {
"id": "10"
},
"#source_location": {},
"type": {
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_int"
},
"width": {
"id": "32"
}
}
},
"value": {
"id": "1"
}
}
}
}
}
}
10 changes: 10 additions & 0 deletions regression/cbmc/load-snapshot-static-global-array-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
int x[] = {1, 2, 3};

int main()
{
assert(x[0] == 4);
assert(x[1] == 5);
assert(x[2] == 6);

return 0;
}
181 changes: 181 additions & 0 deletions regression/cbmc/load-snapshot-static-global-array-01/snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"symbolTable": {
"x": {
"baseName": "x",
"isAuxiliary": false,
"isExported": false,
"isExtern": false,
"isFileLocal": false,
"isInput": false,
"isLvalue": true,
"isMacro": false,
"isOutput": false,
"isParameter": false,
"isProperty": false,
"isStateVar": false,
"isStaticLifetime": true,
"isThreadLocal": false,
"isType": false,
"isVolatile": false,
"isWeak": false,
"location": {},
"mode": "C",
"module": "test",
"name": "x",
"prettyName": "x",
"type": {
"id": "array",
"namedSub": {
"#source_location": {},
"size": {
"id": "constant",
"namedSub": {
"type": {
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_long_int"
},
"width": {
"id": "64"
}
}
},
"value": {
"id": "3"
}
}
}
},
"sub": [
{
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_int"
},
"width": {
"id": "32"
}
}
}
]
},
"value": {
"id": "array",
"namedSub": {
"#source_location": {},
"type": {
"id": "array",
"namedSub": {
"#source_location": {},
"size": {
"id": "constant",
"namedSub": {
"type": {
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_long_int"
},
"width": {
"id": "64"
}
}
},
"value": {
"id": "3"
}
}
}
},
"sub": [
{
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_int"
},
"width": {
"id": "32"
}
}
}
]
}
},
"sub": [
{
"id": "constant",
"namedSub": {
"#base": {
"id": "10"
},
"#source_location": {},
"type": {
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_int"
},
"width": {
"id": "32"
}
}
},
"value": {
"id": "4"
}
}
},
{
"id": "constant",
"namedSub": {
"#base": {
"id": "10"
},
"#source_location": {},
"type": {
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_int"
},
"width": {
"id": "32"
}
}
},
"value": {
"id": "5"
}
}
},
{
"id": "constant",
"namedSub": {
"#base": {
"id": "10"
},
"#source_location": {},
"type": {
"id": "signedbv",
"namedSub": {
"#c_type": {
"id": "signed_int"
},
"width": {
"id": "32"
}
}
},
"value": {
"id": "6"
}
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--memory-snapshot snapshot.json --initial-location main:0
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
8 changes: 8 additions & 0 deletions regression/cbmc/load-snapshot-static-global-int-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int x;

int main()
{
assert(x == 1);

return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc/load-snapshot-static-global-int-01/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
10 changes: 10 additions & 0 deletions regression/cbmc/load-snapshot-static-global-int-02/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
int x;
int y; // snapshot contains no value for y

int main()
{
assert(x == 1);
assert(y == 1);

return 0;
}
9 changes: 9 additions & 0 deletions regression/cbmc/load-snapshot-static-global-int-02/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
--memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0
^EXIT=10$
^SIGNAL=0$
\[main.assertion.1\] line [0-9]+ assertion x == 1: SUCCESS
\[main.assertion.2\] line [0-9]+ assertion y == 1: FAILURE
--
^warning: ignoring
14 changes: 14 additions & 0 deletions regression/cbmc/load-snapshot-static-global-int-03/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
int x;

void func()
{
}

int main()
{
func();

assert(x == 1);

return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc/load-snapshot-static-global-int-03/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
19 changes: 19 additions & 0 deletions regression/cbmc/load-snapshot-static-global-int-paths-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
int x;
int y;

int main()
{
if(nondet_int())
{
y = 1;
}
else
{
y = 2;
}

assert(x == 1);
assert(y == 1 || y == 2);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--paths lifo --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
11 changes: 11 additions & 0 deletions regression/cbmc/load-snapshot-static-global-pointer-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
int x;
int *p; // has value &x in the snapshot

int main()
{
x = 1;

assert(*p == 1);

return 0;
}
Loading