Skip to content

Commit 38ff68f

Browse files
committed
Add goto-harness man page
This was built using help2man and then manually expanded. In the process of preparing it, several errors in existing goto-harness documentation were found and fixed as well.
1 parent a0d4239 commit 38ff68f

File tree

3 files changed

+135
-3
lines changed

3 files changed

+135
-3
lines changed

doc/man/goto-harness.1

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/man/goto-harness.1

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
.TH GOTO-HARNESS "1" "June 2022" "goto-harness-5.59.0" "User Commands"
2+
.SH NAME
3+
goto-harness \- Generate environments for symbolic analysis
4+
.SH SYNOPSIS
5+
.TP
6+
.B goto\-harness [\-?] [\-h] [\-\-help]
7+
show help
8+
.TP
9+
.B goto\-harness \fB\-\-version\fR
10+
show version
11+
.TP
12+
.B goto\-harness \fIin\fB \fIout\fB \-\-harness\-function\-name\ \fIname\fB \-\-harness\-type \fIharness\-type\fR [\fBharness-options\fR]
13+
build harness for \fIin\fR and write harness to \fIout\fR; the harness is
14+
printed as C code, if \fIout\fR has a .c suffix, else a goto binary including
15+
the harness is generated
16+
.SH DESCRIPTION
17+
\fBgoto\-harness\fR constructs functions that set up an appropriate environment
18+
before calling functions under analysis. This is most useful when trying to
19+
analyze an isolated unit of a program.
20+
.PP
21+
A typical sequence of tool invocations is
22+
as follows. Given a C program \fIprogram.c\fR, we generate a harness for
23+
function \fItest_function\fR:
24+
.EX
25+
.IP
26+
# Compile the program
27+
goto-cc program.c -o program.gb
28+
# Run goto-harness to produce harness file
29+
goto-harness --harness-type call-function --harness-function-name generated_harness_test_function
30+
--function test_function program.gb harness.c
31+
# Run the checks targeting the generated harness
32+
cbmc --pointer-check harness.c --function generated_harness_test_function
33+
.EE
34+
.PP
35+
\fBgoto\-harness\fR has two main modes of operation. First,function-call harnesses,
36+
which automatically synthesize an environment without having any information
37+
about the program state. Second, memory-snapshot harnesses, in which case
38+
\fBgoto\-harness\fR loads an existing program state as generated by
39+
\fBmemory-analyzer\fR(1) and selectively havocs some variables.
40+
.SH OPTIONS
41+
.TP
42+
\fB\-\-harness\-function\-name\fR \fIname\fR
43+
Use \fIname\fR as the name of the harness function that is generated, i.e., the
44+
new entry point.
45+
.TP
46+
\fB\-\-harness\-type\fR [\fBcall-function\fR|\fBinitialise-with-memory-snapshot\fR]
47+
Select the type of harness to generate. In addition to options applicable to
48+
both harness generators, each of them also has dedicated options that are
49+
described below.
50+
.SS "Common generator options"
51+
.TP
52+
\fB\-\-min\-null\-tree\-depth\fR \fIN\fR
53+
Set the minimum level at which a pointer can first be \fBNULL\fR
54+
in a recursively non-deterministically initialized struct to \fIN\fR. Defaults
55+
to 1.
56+
.TP
57+
\fB\-\-max\-nondet\-tree\-depth\fR \fIN\fR
58+
Set the maximum height of the non-deterministic object tree to \fIN\fR. At that
59+
level, all pointers will be set to \fBNULL\fR. Defaults to 2.
60+
.TP
61+
\fB\-\-min\-array\-size\fR \fIN\fR
62+
Set the minimum size of arrays of non-constant size allocated by the harness to
63+
\fIN\fR. Defaults to 1.
64+
.TP
65+
\fB\-\-max\-array\-size\fR N
66+
Set the maximum size of arrays of non-constant size allocated by the harness to
67+
\fIN\fR. Defaults to 2.
68+
.TP
69+
\fB\-\-nondet\-globals\fR
70+
Set global variables to non-deterministic values in harness.
71+
.TP
72+
\fB\-\-havoc\-member\fR \fImember\-expr\fR
73+
Non-deterministically initialize \fImember\-expr\fR of some global object (may
74+
be given multiple times).
75+
.TP
76+
\fB\-\-function\-pointer\-can\-be\-null\fR \fIfunction\-name\fR
77+
Name of parameters of the target function or of global variables of
78+
function-pointer type that can non-deterministically be set to \fBNULL\fR.
79+
.SS "Function harness generator (\fB\-\-harness\-type call-function\fR):"
80+
.TP
81+
\fB\-\-function\fR \fIfunction\-name\fR
82+
Generate an environment to call function \fIfunction\-name\fR, which the harness
83+
will then call.
84+
.TP
85+
\fB\-\-treat\-pointer\-as\-array\fR \fIp\fR
86+
Treat the (pointer-typed) function parameter with name \fIp\fR as an array.
87+
.TP
88+
\fB\-\-associated\-array\-size\fR \fIarray_name\fR:\fIsize_name\fR
89+
Set the function parameter \fIsize_name\fR to the size of the array parameter
90+
\fIarray_name\fR (implies \fB\-\-treat\-pointer\-as\-array \fIarray_name\fR).
91+
.TP
92+
\fB\-\-treat\-pointers\-equal\fR \fIp\fR,\fIq\fR,\fIr\fR[;\fIs\fR,\fIt\fR]
93+
Assume the pointer-typed function parameters \fIq\fR and \fIr\fR are equal to
94+
parameter \fIp\fR, and \fIs\fR equal to \fIt\fR, and so on.
95+
.TP
96+
\fB\-\-treat\-pointers\-equal\-maybe\fR
97+
Function parameter equality is non\-deterministic.
98+
.TP
99+
\fB\-\-treat\-pointer\-as\-cstring\fR \fIp\fR
100+
Treat the function parameter with the name \fIp\fR as a string of characters.
101+
.SS "Memory snapshot harness generator (\fB\-\-harness\-type initialise\-from\-memory\-snapshot\fR):"
102+
.TP
103+
\fB\-\-memory\-snapshot\fR \fIfile\fR
104+
Initialize memory from JSON memory snapshot stored in \fIfile\fR.
105+
.TP
106+
\fB\-\-initial\-goto\-location\fR \fIfunc\fR[:\fIn\fR]
107+
Use function \fIfunc\fR and goto binary location number \fIn\fR as entry point.
108+
.TP
109+
\fB\-\-initial\-source\-location\fR \fIfile\R:\fIn\fR
110+
Use given file name \fIfile\fR and line number \fIn\R in that file as entry
111+
point.
112+
.TP
113+
\fB\-\-havoc\-variables\fR \fIvars\fR
114+
Non-deterministically initialize all symbols named \fIvars\fR.
115+
.TP
116+
\fB\-\-pointer\-as\-array\fR \fIp\fR
117+
Treat the global pointer with name \fIp\fR as an array.
118+
.TP
119+
\fB\-\-size\-of\-array\fR \fIarray_name\fR:\fIsize_name\fR
120+
Set the variable \fIsize_name\fR to the size of the array variable
121+
\fIarray_name\fR (implies \fB\-\-pointer\-as\-array \fIarray_name\fR).
122+
.SH ENVIRONMENT
123+
All tools honor the TMPDIR environment variable when generating temporary
124+
files and directories.
125+
.SH BUGS
126+
If you encounter a problem please create an issue at
127+
.B https://github.com/diffblue/cbmc/issues
128+
.SH SEE ALSO
129+
.BR cbmc (1),
130+
.BR goto-cc (1),
131+
.BR memory-analyzer (1)
132+
.SH COPYRIGHT
133+
2019, Diffblue

src/goto-harness/memory_snapshot_harness_generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void memory_snapshot_harness_generatort::validate_options(
111111
{
112112
throw invalid_command_line_argument_exceptiont(
113113
"option --memory_snapshot is required",
114-
"--harness-type initialise-from-memory-snapshot");
114+
"--harness-type initialise-with-memory-snapshot");
115115
}
116116

117117
if(initial_source_location_line.empty() == initial_goto_location_line.empty())

src/goto-harness/memory_snapshot_harness_generator_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Author: Diffblue Ltd.
3333
// clang-format off
3434
#define MEMORY_SNAPSHOT_HARNESS_GENERATOR_HELP \
3535
"memory snapshot harness generator (--harness-type\n" \
36-
" initialise-from-memory-snapshot)\n\n" \
36+
" initialise-with-memory-snapshot)\n\n" \
3737
"--" MEMORY_SNAPSHOT_HARNESS_SNAPSHOT_OPT " <file> initialise memory " \
3838
"from JSON memory snapshot\n" \
3939
"--" MEMORY_SNAPSHOT_HARNESS_INITIAL_GOTO_LOC_OPT " <func[:<n>]>\n" \

0 commit comments

Comments
 (0)