Skip to content

Commit d63548c

Browse files
Add support for using the --function flag to goto-analyze and symex
symex and goto-analyze (through the goto_modelt class) now support setting the --function flag on precompiled .gb files. Refactored out the function flag and its help function to rebuild_goto_start_functions. Used this extracted flag in goto-analyze, symex and CBMC. Added tests that check both goto-analyze and symex when ran with the --function flag actually generate the correct _start function. Also added tests for when it isn't a precompiled binary. Added these new folders to the overal test suite
1 parent bca1b20 commit d63548c

File tree

11 files changed

+98
-4
lines changed

11 files changed

+98
-4
lines changed

lib/cbmc

Submodule cbmc updated 164 files

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
DIRS = symex \
22
symex-infeasibility \
3+
goto-cc-symex \
34
# Empty last line
45

56
# Check for the existence of $dir. Tests under goto-gcc cannot be run on

regression/goto-cc-symex/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
default: tests.log
3+
4+
test:
5+
@if ! ../../lib/cbmc/regression/test.pl -c ../chain.sh ; then \
6+
../../lib/cbmc/regression/failed-tests-printer.pl ; \
7+
exit 1; \
8+
fi
9+
10+
tests.log:
11+
pwd
12+
@if ! ../../lib/cbmc/regression/test.pl -c ../chain.sh ; then \
13+
../../lib/cbmc/regression/failed-tests-printer.pl ; \
14+
exit 1; \
15+
fi
16+
17+
show:
18+
@for dir in *; do \
19+
if [ -d "$$dir" ]; then \
20+
vim -o "$$dir/*.c" "$$dir/*.out"; \
21+
fi; \
22+
done;
23+
24+
clean:
25+
@for dir in *; do \
26+
rm -f tests.log; \
27+
if [ -d "$$dir" ]; then \
28+
cd "$$dir"; \
29+
rm -f *.out *.gb; \
30+
cd ..; \
31+
fi \
32+
done

regression/goto-cc-symex/chain.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
gc=../../../lib/cbmc/src/goto-cc/goto-cc
4+
symex=../../../src/symex/symex
5+
6+
options=$1
7+
name=${2%.c}
8+
9+
$gc $name.c -o $name.gb
10+
$symex $name.gb $options
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <assert.h>
2+
3+
int fun(int x)
4+
{
5+
int i;
6+
if(i>=20)
7+
assert(i>=10);
8+
}
9+
10+
int main(int argc, char** argv)
11+
{
12+
int i;
13+
14+
if(i>=5)
15+
assert(i>=10);
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
"--function fun --show-goto-functions"
4+
^\s*return.*=\s*fun#return_value;$
5+
^EXIT=6$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <assert.h>
2+
3+
int fun(int x)
4+
{
5+
int i;
6+
if(i>=20)
7+
assert(i>=10);
8+
}
9+
10+
int main(int argc, char** argv)
11+
{
12+
int i;
13+
14+
if(i>=5)
15+
assert(i>=10);
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--function fun --show-goto-functions
4+
fun\(x\);$
5+
^EXIT=6$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

regression/symex/show-trace1/test.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33
--trace
44
^EXIT=10$
@@ -9,3 +9,5 @@ main.c
99
^ k=6 .*$
1010
--
1111
^warning: ignoring
12+
--
13+
diffblue/cbmc#1361

src/symex/symex_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ void symex_parse_optionst::help()
587587
" --round-to-plus-inf IEEE floating point rounding mode\n"
588588
" --round-to-minus-inf IEEE floating point rounding mode\n"
589589
" --round-to-zero IEEE floating point rounding mode\n"
590-
" --function name set main function name\n"
590+
HELP_FUNCTIONS
591591
"\n"
592592
"Java Bytecode frontend options:\n"
593593
JAVA_BYTECODE_LANGUAGE_OPTIONS_HELP

src/symex/symex_parse_options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include <goto-programs/goto_model.h>
1919
#include <goto-programs/show_goto_functions.h>
20+
#include <goto-programs/rebuild_goto_start_function.h>
2021

2122
#include <analyses/goto_check.h>
2223

@@ -28,7 +29,7 @@ class goto_functionst;
2829
class optionst;
2930

3031
#define SYMEX_OPTIONS \
31-
"(function):" \
32+
OPT_FUNCTIONS \
3233
"D:I:" \
3334
"(depth):(context-bound):(branch-bound):(unwind):(max-search-time):" \
3435
OPT_GOTO_CHECK \

0 commit comments

Comments
 (0)