analysis tool. In this context, tool C.Open provides a new functionality, since it can
manage C programs that make calls to an external API. Furthermore, the programs can
actually use the external API to form a concurrent system. Given this concurrent system,
C.Open may construct its state spaces on-the-fly.
In order to deal with external APIs, we need to construct models of the external calls.
These models are, in fact, abstractions of the real behavior of the external functions.
They only provide the minimum functionality required to carry out the analysis. For
instance, if an external function deals with intermediate communication buffers, we
probably do not need to implement buffers with their real size, it might be sufficient
to use some type of reduced buffers. In fact, due to the state space problem, reducing
the complexity of real data structures is essential to obtain effective analysis tools, like
model checkers. The models of external calls are C functions which are executed by
the graph module when it is generating the successors of a given state if any of them
correspond to one external function.
The decision about how to model external functions strongly depends on the prop-
erties to be analyzed on the system. In any case, the transitions of the resulting LTS may
be labelled with ι representing an atomic sequence of internal C sentences (including
no external call) or, on the contrary, they may be labelled with a call to the model of an
external function. In summary, we can deal with any kind of C code provided models
of all external calls to the corresponding API are given. The next section explains how
to obtain models of external functions.
3.1 The External API
Table 1. Shared Memory API functions.
func. return arg 1 arg 2 arg 3
screate reg.id(int) reg name(char *) sizeof reg.(int) value(void *)
sread value(void *) reg.id(int)
swrite code(int) reg.id(int) value(void *) sizeof value(int)
sclose code(int) reg.id(int)
For external calls to the language, C.Open needs a model of these functions written
in C and a translation rules file for translating the external API functions into the corre-
sponding modelled function. Table 1 shows, as an example, the API Shared Memory,
also used in Section 4, that provides four basic functions to deal with a shared resource,
that is, create, read, write and close. The shared memory is composed of sev-
eral regions, each one with a unique name and size. When screate is called with
a given name, size and initial value, a new region is created, provided that no region
has been previously created with the same name, size and initial value. Otherwise, if
there was a region with the same name, the function call returns the region identifier
previously assigned. The other operations, sread, swrite and sclose, are used
to read from, write to, or close the region specified by the corresponding argument. In
particular, the sclose operation decreases the number of references to that region,
108