source: CIVL/doc/manual/part-tools.tex@ fbc5eb8

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since fbc5eb8 was 8f423ff, checked in by Stephen Siegel <siegel@…>, 12 years ago

Cleaned up all problems with manual, got book marks right, table
of contents right, got rid of all warnings.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@700 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 19.5 KB
Line 
1\part{Tools}
2\label{part:tools}
3
4\chapter{Tool Overview}
5
6\section{Symbolic execution}
7
8The tools currently in the CIVL tool kit all use \emph{symbolic
9 execution}. This is a technique in which variables are assigned
10symbolic rather than concrete values. In particular, input variables
11are assigned unique \emph{symbolic constants}, which are symbols such
12as $X$, $Y$, and so on. Operations produce symbolic expressions in
13those symbols, such as $(X+Y)/2$.
14
15\section{Commands}
16
17Current tools allow one to \emph{run} a CIVL program using random
18choice to resolve nondeterministic choices; \emph{verify} a program
19using model checking to explore all states of the program; and
20\emph{replay} a trace if an error is found. There are also commands
21to show the results just of preprocessing or parsing a file; as these
22are basically sub-tasks of the other tasks, they are used mainly for
23debugging.
24
25Each tool is launched from the command line by typing ``\texttt{civl}
26\textit{cmd} \ldots'', where \textit{cmd} is one of
27\begin{itemize}
28\item \ct{help} : print usage information
29\item \ct{run} : run the program using random simulation
30\item \ct{verify} : verify program
31\item \ct{replay} : replay trace for program
32\item \ct{parse} : show result of preprocessing and parsing file
33\item \ct{preprocess} : show result of preprocessing file only.
34\end{itemize}
35The additional arguments and options are described below and are also
36shown by the \ct{help} command.
37
38A number of properties are checked when running or verifying
39a CIVL program. These include the following:
40\begin{itemize}
41\item absence of deadlocks
42\item absence of assertion violations
43\item absence of division or modulus with denominator $0$
44\item absence of illegal pointer dereferences
45\item absence of out-of-bounds array indexes
46\item absence of invalid casts
47\item every object is defined (i.e., initialized) before
48 it is used.
49\end{itemize}
50
51
52\section{Options}
53
54The following command line options are available:
55
56\newenvironment{optionlist}{\begin{flushleft}}{\end{flushleft}}
57\newcommand{\option}[2]{#1\\[0mm]\makebox[5mm]{}#2\\[3mm]}
58\newcommand{\booloption}[3]{\option{\ct{-#1} or \ct{-#1=}\textit{boolean}
59 (default: \ct{#2})}{#3}}
60\newcommand{\intoption}[3]{\option{\ct{-#1=}\textit{integer}
61 (default: \ct{#2})}{#3}}
62\newcommand{\mapoption}[2]{\option{\ct{-#1}\textit{key}\ct{=}\textit{value}}{#2}}
63\newcommand{\stringoption}[3]{\option{\ct{-#1=}\textit{string}
64 (default: \ct{#2})}{#3}}
65
66\begin{optionlist}
67 \booloption{debug}{false}{debug mode: print very detailed information}
68 \booloption{echo}{false}{print the command line}
69 \intoption{errorBound}{1}{stop after finding this many errors}
70 \booloption{guided}{false}{user guided simulation; applies only to
71 run, ignored for all other commands}
72 \intoption{id}{0}{ID number of trace to replay}
73 \mapoption{input}{initialize input variable \textit{key} to
74 \textit{value}}
75 \intoption{maxdepth}{2147483647}{bound on search depth}
76 \booloption{min}{false}{search for minimal counterexample}
77 \stringoption{por}{std}{partial order reduction (por) choices:
78 std (standard por) or scp (scoped por)}
79 \booloption{random}{varies}{select enabled transitions randomly;
80 default for \texttt{run}, ignored for all other commands}
81 \booloption{saveStates}{true}{save states during depth-first search}
82 \stringoption{seed}{none}{set the random seed; applies only to run}
83 \booloption{showModel}{false}{print the model}
84 \booloption{showProverQueries}{false}{print theorem prover queries
85 only}
86 \booloption{showQueries}{false}{print all queries}
87 \booloption{showSavedStates}{false}{print saved states only}
88 \booloption{showStates}{false}{print all states}
89 \booloption{showTransitions}{false}{print transitions}
90 \booloption{simplify}{true}{simplify states?}
91 \booloption{solve}{false}{try to solve for concrete counterexample}
92 \stringoption{sysIncludePath}{}{set the system include path}
93 \stringoption{trace}{}{filename of trace to replay}
94 \stringoption{userIncludePath}{}{set the user include path}
95 \booloption{verbose}{false}{verbose mode}
96\end{optionlist}
97
98\section{Errors}
99\label{sec:errors}
100
101When a property violation occurs, either in \emph{verification} or
102\emph{run} mode, a brief report is written to the screen. In
103addition, a report may be \emph{logged} in the directory
104\texttt{CIVLREP}.
105
106The \emph{error bound} parameter determines how many errors can be
107encountered before a search terminates. By default, the error bound
108is 1, meaning a search will stop as soon as the first error is found.
109The error bound can be set to a higher number on the command line
110using option \emph{errorBound}.
111
112When the error bound is greater than one, the CIVL verifier continues
113searching after the first error is discovered. It first attempts to
114``recover'' from the error by adding to the path condition a clause
115which guarantees that the error cannot happen. For example, if the
116error was caused by a possible division by zero, $x/y$, where $y$ is
117an unconstrained real symbolic constant, CIVL will add to the path
118condition the predicate $y\neq 0$, and continue the search. In some
119cases, CIVL determines that the modified path condition is
120unsatisfiable, in which case the search will back-track in the usual
121symbolic execution way.
122
123In addition to the printed reports, errors are logged. However, CIVL
124follows a protocol aimed at limiting the number of reports of errors
125which are essentially the same. This protocol uses a simple
126equivalence relation on the set of errors. Two erroneous states are
127considered equivalent if the errors are of the same \emph{kind}
128(deadlock, division by zero, illegal pointer dereference, etc.) and
129every process is at the same location in both states. When an error
130is encountered, CIVL first checks to see if an earlier equivalent
131errors exists in the log. If so, the lengths of the traces leading to
132the two error states are compared. If the new trace is shorter, the
133old log entry is replaced with the new one. In this way, only the
134shortest representative error trace for each equivalence class of
135errors is recorded in the log.
136
137A log entry actually entails two things: first, a plain text entry
138similar to the one printed to the screen is made in a log file in
139\texttt{CIVLREP}. The name of this file is usually of the form
140\texttt{\textit{root}{\U}log.txt}, where \textit{root} is the root of
141the original file name, i.e., the substring of the file name that ends
142just before the first `\texttt{.}'. For example, if the file name is
143\texttt{diningBad.cvl}, the log file will be named
144\texttt{diningBad{\U}log.txt}. This is a plain text, human-readable
145file which summarizes the results of the verification run.
146
147In addition, each saved trace is stored in a separate file in
148\texttt{CIVLREP}. The names of these files have the form
149\texttt{\textit{root}{\U}\textit{id}.trace}, where \textit{id} is the
150error ID (reported when the error is printed and logged). This file
151is not intended to be human-readable. It contains a compressed
152representation of the trace, including all of the options and
153parameter values and choices made a nondeterministic points.
154This file is used by CIVL when replaying an error trace.
155
156As mentioned above, the CIVL \texttt{replay} command is used to play
157an earlier-saved error trace. When more than one trace has been
158saved, the \texttt{-id} command line option can be used to specify
159which one to play. (The default \emph{id} is 0).
160
161\chapter{Interpreting the Output}
162
163\section{Transitions}
164
165Transitions are printed during trace \texttt{replay}, in the course of
166a \texttt{run}, or during verification if option
167\emph{showTransitions} is selected. A typical transition is printed
168as follows:
169
170\begin{verbatim}
171State 6, proc 0:
172 44->49: LOOP_FALSE_BRANCH at f0:36.18-23 "i < n";
173 49->RET: return (init) at f0:37.0-1 "}";
174 7->8: i = 0 at f0:42.7-16 "int i = 0";
175--> State 74
176\end{verbatim}
177
178This means that the transition begins executing from the state with
179ID 6, and it is executed by the process with PID 0. The transition
180is executed in a sequence of atomic steps; in this case there the
181transition consists of three steps.
182
183Process 0 begins at location 44; this is a static location in the
184program graph of a function in the CIVL model. Details about the
185locations can be seen by printing the CIVL model. In executing the
186first step, control moves from location 44 to location 49. This first
187step is an edge in the program graph corresonding to the \emph{false}
188branch of a loop condition, i.e., the branch that exits the loop.
189
190The remainder of the line describing the step specifies the part of
191the original source code corresponding to this step. The source code
192fragment can be found in file \texttt{f0}. To save space and avoid
193constantly repeating long paths, all the source files involved in a
194program are printed once and assigned keys such as \texttt{f0},
195\texttt{f1}, etc. The legend is printed out once at the beginning of
196the run; in this case it is simply the following:
197\begin{verbatim}
198File name list:
199f0 : dining.cvl
200\end{verbatim}
201The source code fragment begins on character 18 of line 36 of
202\texttt{f0}, and extends to character 23 of that line. This range is
203inclusive on the left and exclusive on the right, so the total number
204of characters in this range is $23-18=5$. The five characters from
205the source code are printed next inside double quotes. For longer
206ranges, this excerpt will be abbreviated using an elipsis.
207
208The second step executes a \emph{return} statement, which results in
209popping the top activation frame from process 0's call stack. The
210function returning is \texttt{init}. Since the program counter for
211that frame disappears with the execution of this step, there is no
212final value for its new location; this is signified using the
213pseudo-location \texttt{RET}.
214
215In the new top frame, control is at location 7, and an assignment
216statement is executed, moving control to location 8. With this last
217step, the transition ends at State 74.
218
219Between transitions, processes can be renumbered. Hence a process
220with PID 0 in one state, may have a different PID in another state.
221The same is true for dynamic scope IDs. Within a single transition,
222however, these numbers will not change.
223
224\section{States}
225
226States are printed typically when a property is violated, at the
227initial or final points of a trace replay, or if the option
228\emph{showStates}, \emph{showSavedStates}, \emph{verbose}, or
229\emph{debug} is selected.
230
231\begin{figure}
232 \begin{small}
233\begin{verbatim}
234State 84
235| Path condition
236| | true
237| Dynamic scopes
238| | dyscope 0 (parent=-1, static=0)
239| | | reachers = {1,2}
240| | | variables
241| | | | __atomic_lock_var = process<-1>
242| | | | __heap = NULL
243| | | | BOUND = 3
244| | | | n = 2
245| | | | forks = X_s0v4[0:=0, 1:=-1]
246| | dyscope 1 (parent=2, static=5)
247| | | reachers = {1}
248| | | variables
249| | | | __heap = NULL
250| | | | left = 0
251| | | | right = 1
252| | dyscope 2 (parent=0, static=1)
253| | | reachers = {1}
254| | | variables
255| | | | id = 0
256| | | | __heap = NULL
257| | dyscope 3 (parent=4, static=5)
258| | | reachers = {2}
259| | | variables
260| | | | __heap = NULL
261| | | | left = 1
262| | | | right = 0
263| | dyscope 4 (parent=0, static=1)
264| | | reachers = {2}
265| | | variables
266| | | | id = 1
267| | | | __heap = NULL
268| Process states
269| | process 0
270| | | atomicCount = 0
271| | | call stack
272| | process 1
273| | | atomicCount = 0
274| | | call stack
275| | | | Frame[function=dine, location=25, f0:22.32-44 "forks[right]", scope=1]
276| | process 2
277| | | atomicCount = 0
278| | | call stack
279| | | | Frame[function=dine, location=33, f0:26.32-44 "forks[right]", scope=3]
280\end{verbatim}
281 \end{small}
282 \caption{Complete print-out of a state}
283 \label{fig:state-print}
284\end{figure}
285
286A complete print-out of a state can be seen in Figure
287\ref{fig:state-print}. The state is presented in hierarchical way.
288At the top-most level of this hierarchy, there are 3 main parts to the
289state:
290\begin{enumerate}
291\item the \emph{path condition}, i.e., the boolea-valued symbolic
292 expression used in symbolic execution to keep track of all
293 conditions on the input symbols which must hold in order for the
294 current path to have been followed;
295\item the \emph{dynamic scopes}, and
296\item the \emph{process states}.
297\end{enumerate}
298
299The dynamic scopes are numbered starting from 0. This numbering is
300arbitrary and is invisible to the program, i.e., there is no way for
301the program to obtain its dynamic scope ID. This allows the verifier
302to renumber dynamic scopes at will in order to transform a state into
303an equivalence canonical form.
304
305The print-out of each dynamic scope specifies the ID of the dyscope's
306parent in the dyscope tree. (The root dyscope shows $-1$ for the
307parent.) This specifies the complete tree structure of the dyscopes.
308Each dyscope is an instance of some static scope; the representation
309also shows the ID of this static scope.
310
311The next line in the representation of the dyscope shows a set of
312\emph{reachers}. These are the PIDs of the processes that can
313\emph{reach} this dyscope. A process can reach a dyscope if there is
314path in the dyscope tree that starts from a dyscope referenced by a
315frame on the process' call stack and follows the parent edges in the
316tree.
317
318The \emph{variables} section of the dyscope representation consists of
319one line for each variable in the static scope corresponding to the
320dyscope. There are also special hidden variables, such as the heap.
321In each case, the value assigned to the variable is shown. A value of
322\texttt{NULL} indicates that the variable is currently undefined.
323
324The process states section consists of one sub-section for each
325process currently in the state. Like the dynamic scopes, the
326processes are numbered in some arbitrary way. For each process, the
327value of the \emph{atomic count} is given. This is the nesting depth
328of the atomic blocks in which the process is currently located, i.e.,
329the number of times the process has entered an atomic block without
330exiting the block.
331
332The call stack of the process lists the activation frames on the stack
333from top to bottom. The frame at the top correspond to the function
334currently executing in that process. The name of the function, the
335value of the program counter (location), and the source code for that
336location, and the dyscope ID for the frame are shown.
337
338\section{Property Violations}
339
340As described in Section \ref{sec:errors}, an error report is printed
341whenever CIVL encounters an error. A typical error report appears as
342follows:
343\begin{small}
344\begin{verbatim}
345Error 0 encountered at depth 21:
346CIVL execution error (kind: DEADLOCK, certainty: PROVEABLE)
347A deadlock is possible:
348 Path condition: true
349 Enabling predicate: false
350ProcessState 0: terminated
351ProcessState 1: at location 25, f0:21.30-42 "forks[right]"
352 Enabling predicate: false
353ProcessState 2: at location 25, f0:21.30-42 "forks[right]"
354 Enabling predicate: false
355at f0:21.30-42 "forks[right]".
356\end{verbatim}
357\end{small}
358
359The report begins with ``Error 0''. The errors are numbered in the
360order they are discovered in this search; this indicates that this is
361the first (0th) error encountered. The depth refers to the length of
362the depth-first search stack when the error was encountered. In this
363case, the depth was 21, meaning that the trace leading to the
364erroneous state is a sequence of 21 states and 20 transitions.
365
366The errors are categorized by \emph{kind}. The error kinds include
367\emph{deadlock}, indicating that it is possible no transition is
368enabled in the state; \emph{assertion violation}, indicating an
369assertion may fail in the state; \emph{division by zero}; and
370\emph{out of bounds}, indicating an array index may be out of bounds,
371among many more.
372
373In addition to the brief report shown above, most error reports
374also include a complete print-out of the state at which the error
375occurred. They will also include additional information specific
376to the kind of error. For example, the deadlock error report shown
377above includes the following information:
378\begin{itemize}
379\item the value of the path condition;
380\item the \emph{enabling predicate}, which is the disjunction of the
381 guards associated to all transitions departing from the current
382 state. This is the predicate that CIVL has found to possibly be
383 unsatisfiable under the context of the path condition; and
384\item for each process, the current location of the process and the
385 enabling predicate for that process, i.e., the disjunction of the
386 guards associated to all transitions departing from the current
387 state in that process (CIVL has found that all of these may be
388 unsatisfiable).
389\end{itemize}
390
391Errors are also categorized as to their \emph{certainty}. CIVL is
392\emph{conservative}, meaning that if it not sure a property holds in a
393state, it will report it. This means that it may sometimes raise
394\emph{false alarms}, i.e., report a possible error even when none
395exists. The certainty measures how certain CIVL is that the error is
396real. The certainty levels, from most to least certain, are as
397follows:
398\begin{enumerate}
399\item \emph{concrete}: this indicates that CIVL has actually found
400 concrete
401 values for all input variables that are guaranteed to drive the
402 execution along the current trace and result in the error;
403\item \emph{proveable}: this indicates that a theorem prover (either
404 the external one or CIVL's built-in prover) has determined that
405 the error is feasible, which includes proving that the path condition
406 is satisfiable; however, it has not necessarily found concrete
407 values for the inputs;
408\item \emph{maybe}: this indicates the prover is not sure whether this
409 is an error; this could be due to the incompleteness of the decision
410 procecure, or it could be a real error;
411\item \emph{none}: probably an internal CIVL error: the theorem prover
412 has not said anything.
413\end{enumerate}
414
415\section{Statistics}
416
417\begin{itemize}
418\item \emph{validCalls}: the number of calls to the CIVL \emph{valid}
419 method, used to determine if a first-order formula is valid under
420 a given first-order context. Some of these queries are resolved
421 quickly by CIVL; when CIVL cannot resolve the query itself, it
422 calls a separate theorem prover (CVC3)
423\item \emph{proverCalls}: the number of calls to the separate theorem
424 prover's \emph{valid} method
425\item \emph{memory}: the total amount of memory, in bytes, consumed by
426 the Java virtual machine at the end of the search/run.
427\item \emph{time}: the total time, in seconds, used to perform the
428 CIVL operation
429\item \emph{maxProcs}: the maximum process count achieved, over all states
430 encountered in the search/run
431\item \emph{statesInstantiated}: the number of state objects
432 instantiated during the course of the verification/run
433\item \emph{statesSaved}: the number of states saved in the course
434 of a search
435\item \emph{statesSeen}: the number of states pushed onto the
436 depth-first search stack in the course of the search; note
437 that ``intermediate states'' created in the process of executing
438 a transition are not pushed onto the stack, only the final
439 state resulting from the transition is pushed
440\item \emph{statesMatched}: the number of times a state encountered
441 in the depth-first search was found to match a saved state seen
442 earlier in the search
443\item \emph{steps}: the total number of primitive steps executed
444 during the verification/run. A step is the smallest, atomic,
445 unit of execution; each transition is composed of one or more steps.
446 This number is a good measure for the total amount of ``work''
447 carried out by CIVL
448\item \emph{transitions}: the total number of transitions executed
449 during the verification/run. A transition is a coarser unit
450 of execution; each transition consists of one or more steps
451 executed from a single process, resulting in a state which is then
452 pushed onto the DFS stack.
453\end{itemize}
454
Note: See TracBrowser for help on using the repository browser.