Skip to content

Goto instrument loop unwinding #241

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

Merged
merged 2 commits into from
Dec 6, 2016
Merged
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
41 changes: 31 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
language: cpp

os:
- linux
- osx
sudo: required
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you intentionally add .travis.yml changes to this pull request? (I am in favour of those changes, just asking.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using some new versions of methods of, e.g., std::set that were added in C++11. This didn't compile with the old travis file as the STL version it used for the Linux builds was too old.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, thanks for clarifying!


matrix:
include:
- os: linux
dist: trusty
compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
# newer g++ version (also pulls libstdc++)
- g++-4.9
- libwww-perl
- os: linux
dist: trusty
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
# newer g++ version (also pulls libstdc++)
- g++-4.9
- libwww-perl
before_install:
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90
- os: osx
compiler: clang
- os: osx
compiler: gcc

addons:
apt:
packages:
- libwww-perl

compiler:
- gcc
- clang

before_install:
- if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ] ; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get -qq update && sudo apt-get -qq install g++-4.8 gcc-4.8 && sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90 && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90 ; fi

install:
- chmod a+x regression/failed-tests-printer.pl
- cd src && make minisat2-download
Expand Down
2 changes: 1 addition & 1 deletion regression/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DIRS = ansi-c cbmc cpp goto-instrument
DIRS = ansi-c cbmc cpp goto-instrument goto-instrument-unwind

test:
$(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;)
5 changes: 3 additions & 2 deletions regression/goto-instrument-unwind/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ tests.log: ../test.pl
clean:
@for dir in *; do \
if [ -d "$$dir" ]; then \
rm $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \
rm -f $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \
fi; \
done;
done;
rm -f tests.log

show:
@for dir in *; do \
Expand Down
6 changes: 6 additions & 0 deletions regression/goto-instrument-unwind/assert1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

int main()
{
int i;
for(i = 0; i < 10; i++) {}
}
8 changes: 8 additions & 0 deletions regression/goto-instrument-unwind/assert1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--unwind 10 --unwinding-assertions
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
6 changes: 6 additions & 0 deletions regression/goto-instrument-unwind/assert2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

int main()
{
int i;
for(i = 0; i < 10; i++) {}
}
7 changes: 7 additions & 0 deletions regression/goto-instrument-unwind/assert2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
main.c
--unwind 9 --unwinding-assertions
^SIGNAL=0$
^VERIFICATION FAILED$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions regression/goto-instrument-unwind/assert3/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

int main()
{
int i;
i = 0;
do {
i++;
} while(i < 10);
}
8 changes: 8 additions & 0 deletions regression/goto-instrument-unwind/assert3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--unwind 10 --unwinding-assertions
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
7 changes: 7 additions & 0 deletions regression/goto-instrument-unwind/assume1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

int main()
{
int i;
for(i = 0; i < 10; i++) {}
assert(0);
}
7 changes: 7 additions & 0 deletions regression/goto-instrument-unwind/assume1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
main.c
--unwind 10
^SIGNAL=0$
^VERIFICATION FAILED$
--
^warning: ignoring
7 changes: 7 additions & 0 deletions regression/goto-instrument-unwind/assume2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

int main()
{
int i;
for(i = 0; i < 10; i++) {}
assert(0);
}
8 changes: 8 additions & 0 deletions regression/goto-instrument-unwind/assume2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--unwind 9
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/break-loop1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
10
--unwind 10 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/break-loop2/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
100
--unwind 100 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
7 changes: 7 additions & 0 deletions regression/goto-instrument-unwind/continue-as-loops1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

int main()
{
int i;
for(i = 0; i < 10; i++) {}
assert(i==10);
}
10 changes: 10 additions & 0 deletions regression/goto-instrument-unwind/continue-as-loops1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
main.c
--unwind 5 --continue-as-loops
^Unwinding loop.*iteration 5
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
^Unwinding loop.*iteration 6
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/continue-loop1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
10
--unwind 10 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/continue-loop2/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
100
--unwind 100 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
27 changes: 27 additions & 0 deletions regression/goto-instrument-unwind/do-while-loop1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

void f() {}

int main()
{
/**
* This is a test case for the unwind operation of goto-instrument;
* every loop will be unwound K times
**/
const unsigned K=10;

const unsigned n=100;
unsigned c=0, i;

i=1;
do
{
f();
c++;
i++;
} while(i<=n);

unsigned eva=n;
if(K<eva) eva=K;

__CPROVER_assert(c==eva, "do-while loop unwind (1)");
}
8 changes: 8 additions & 0 deletions regression/goto-instrument-unwind/do-while-loop1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--unwind 10 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
28 changes: 28 additions & 0 deletions regression/goto-instrument-unwind/do-while-loop2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

void f() {}

int main()
{
/**
* This is a test case for the unwind operation of goto-instrument;
* every loop will be unwound K times
**/
const unsigned K=100;

const unsigned n=10;
unsigned c=0, i;

i=1;
do
{
f();
c++;
i++;
} while(i<=n);

unsigned eva=n;
if(K<eva) eva=K;

__CPROVER_assert(c==eva, "do-while loop unwind (1)");

}
8 changes: 8 additions & 0 deletions regression/goto-instrument-unwind/do-while-loop2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--unwind 100 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/empty-loop1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
10
--unwind 10 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/empty-loop2/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
100
--unwind 100 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/nested-loops1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
10
--unwind 10 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/nested-loops2/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
10
--unwind 10 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/simple-loop1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
10
--unwind 10 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
3 changes: 2 additions & 1 deletion regression/goto-instrument-unwind/simple-loop2/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.c
100
--unwind 100 --partial-loops
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Expand Down
23 changes: 7 additions & 16 deletions regression/goto-instrument-unwind/unwind-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,14 @@ goto_cc=$src/goto-cc/goto-cc
goto_instrument=$src/goto-instrument/goto-instrument
cbmc=$src/cbmc/cbmc

function usage() {
echo "Usage: chain unwind-num test_file.c"
exit 1
}
name=${@:$#}
name=${name%.c}

echo "Usage: process test_file.c to goto program"

if [ $# -eq 2 ]
then
unwind_num=$1
name=`echo $2 | cut -d. -f1`
echo $unwind_num
echo $name
else
usage
fi
args=${@:1:$#-1}

$goto_cc -o $name.gb $name.c
$goto_instrument $name.gb ${name}-unwound.gb --unwind $unwind_num
$goto_instrument --show-goto-functions $name.gb
$goto_instrument $args $name.gb ${name}-unwound.gb
$goto_instrument --show-goto-functions ${name}-unwound.gb
$cbmc ${name}-unwound.gb

6 changes: 6 additions & 0 deletions regression/goto-instrument-unwind/unwind-log1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

int main()
{
int i;
for(i = 0; i < 10; i++) {}
}
8 changes: 8 additions & 0 deletions regression/goto-instrument-unwind/unwind-log1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--unwind 10 --unwinding-assertions --log -
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
Loading