Skip to content

Commit 30cb51c

Browse files
Add stub for new goto-harness tool
This adds a new executable called goto-harness. Right now it doesn't actually do anything, but ultimately its purpose will be to generate "harness" functions for goto-programs - i.e. given some specification, it'll generate a function suitable as a cbmc entry point function that implements that specification. Planned for now are two types of harnesses: One that takes the name of a function with parameters and then generates a function that sets up these parameters and calls the function with them. This is similar to what cbmc does already, however will allow more flexibility in choosing how exactly these parameters will be initialised which was deemed out of scope for cbmc. The other will be able to take a snapshot of a concrete execution of a program, and then start an analysis from that point.
1 parent f6f7ecd commit 30cb51c

9 files changed

+135
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ set_target_properties(
9999
goto-checker
100100
goto-diff
101101
goto-diff-lib
102+
goto-harness
102103
goto-instrument
103104
goto-instrument-lib
104105
goto-programs

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ add_subdirectory(goto-cc)
103103
add_subdirectory(goto-instrument)
104104
add_subdirectory(goto-analyzer)
105105
add_subdirectory(goto-diff)
106+
add_subdirectory(goto-harness)

src/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ DIRS = analyses \
88
goto-cc \
99
goto-checker \
1010
goto-diff \
11+
goto-harness \
1112
goto-instrument \
1213
goto-programs \
1314
goto-symex \
@@ -27,6 +28,7 @@ all: cbmc.dir \
2728
goto-cc.dir \
2829
goto-diff.dir \
2930
goto-instrument.dir \
31+
goto-harness.dir \
3032
# Empty last line
3133

3234
###############################################################################
@@ -47,6 +49,8 @@ languages: util.dir langapi.dir \
4749

4850
solvers.dir: util.dir
4951

52+
goto-harness.dir: util.dir
53+
5054
goto-instrument.dir: languages goto-programs.dir pointer-analysis.dir \
5155
goto-symex.dir linking.dir analyses.dir solvers.dir
5256

src/goto-harness/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
file(GLOB_RECURSE sources "*.cpp" "*.h")
2+
add_executable(goto-harness ${sources})
3+
generic_includes(goto-harness)
4+
5+
target_link_libraries(goto-harness
6+
util
7+
)

src/goto-harness/Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
SRC = \
2+
goto_harness_main.cpp \
3+
goto_harness_parse_options.cpp \
4+
# Empty last line
5+
6+
OBJ += \
7+
../util/util$(LIBEXT) \
8+
# Empty last line
9+
10+
INCLUDES= -I ..
11+
12+
LIBS =
13+
14+
CLEANFILES = goto-harness$(EXEEXT)
15+
16+
include ../config.inc
17+
include ../common
18+
19+
all: goto-harness$(EXEEXT)
20+
21+
###############################################################################
22+
23+
goto-harness$(EXEEXT): $(OBJ)
24+
$(LINKBIN)
25+
26+
.PHONY: goto-harness-mac-signed
27+
28+
goto-harness-mac-signed: goto-harness$(EXEEXT)
29+
codesign -v -s $(OSX_IDENTITY) goto-harness$(EXEEXT)
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/******************************************************************\
2+
3+
Module: goto_harness_main
4+
5+
Author: Diffblue Ltd.
6+
7+
\******************************************************************/
8+
9+
#include "goto_harness_parse_options.h"
10+
11+
int main(int argc, const char *argv[])
12+
{
13+
auto parse_options = goto_harness_parse_optionst(argc, argv);
14+
return parse_options.main();
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/******************************************************************\
2+
3+
Module: goto_harness_parse_options
4+
5+
Author: Diffblue Ltd.
6+
7+
\******************************************************************/
8+
9+
#include <cstddef>
10+
#include <iostream>
11+
#include <string>
12+
13+
#include <util/exit_codes.h>
14+
#include <util/version.h>
15+
16+
#include "goto_harness_parse_options.h"
17+
18+
int goto_harness_parse_optionst::doit()
19+
{
20+
if(cmdline.isset("version"))
21+
{
22+
std::cout << CBMC_VERSION << '\n';
23+
return CPROVER_EXIT_SUCCESS;
24+
}
25+
26+
help();
27+
return CPROVER_EXIT_USAGE_ERROR;
28+
}
29+
30+
void goto_harness_parse_optionst::help()
31+
{
32+
std::cout << '\n'
33+
<< banner_string("Goto-Harness", CBMC_VERSION) << '\n'
34+
<< align_center_with_border("Copyright (C) 2019") << '\n'
35+
<< align_center_with_border("Diffblue Ltd.") << '\n'
36+
<< align_center_with_border("[email protected]")
37+
// ^--- No idea if this is the right email address
38+
<< '\n'
39+
<< '\n'
40+
<< "Usage: Purpose:\n"
41+
<< '\n'
42+
<< " goto-harness [-?] [-h] [--help] show help\n"
43+
<< " goto-harness --version show version\n";
44+
}
45+
46+
goto_harness_parse_optionst::goto_harness_parse_optionst(
47+
int argc,
48+
const char *argv[])
49+
: parse_options_baset{GOTO_HARNESS_OPTIONS, argc, argv}
50+
{
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/******************************************************************\
2+
3+
Module: goto_harness_parse_options
4+
5+
Author: Diffblue Ltd.
6+
7+
\******************************************************************/
8+
9+
#ifndef CPROVER_GOTO_HARNESS_GOTO_HARNESS_PARSE_OPTIONS_H
10+
#define CPROVER_GOTO_HARNESS_GOTO_HARNESS_PARSE_OPTIONS_H
11+
12+
#include <util/parse_options.h>
13+
14+
#define GOTO_HARNESS_OPTIONS "(version)" // end GOTO_HARNESS_OPTIONS
15+
16+
class goto_harness_parse_optionst : public parse_options_baset
17+
{
18+
public:
19+
int doit() override;
20+
void help() override;
21+
22+
goto_harness_parse_optionst(int argc, const char *argv[]);
23+
};
24+
25+
#endif // CPROVER_GOTO_HARNESS_GOTO_HARNESS_PARSE_OPTIONS_H
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
util
2+
goto-harness

0 commit comments

Comments
 (0)