package frama-c
Install
dune-project
Dependency
Authors
-
MMichele Alberti
-
TThibaud Antignac
-
GGergö Barany
-
PPatrick Baudin
-
TThibaut Benjamin
-
AAllan Blanchard
-
LLionel Blatter
-
FFrançois Bobot
-
RRichard Bonichon
-
QQuentin Bouillaguet
-
DDavid Bühler
-
ZZakaria Chihani
-
LLoïc Correnson
-
JJulien Crétin
-
PPascal Cuoq
-
ZZaynah Dargaye
-
BBasile Desloges
-
JJean-Christophe Filliâtre
-
PPhilippe Herrmann
-
MMaxime Jacquemin
-
FFlorent Kirchner
-
AAlexander Kogtenkov
-
TTristan Le Gall
-
JJean-Christophe Léchenet
-
MMatthieu Lemerre
-
DDara Ly
-
DDavid Maison
-
CClaude Marché
-
AAndré Maroneze
-
TThibault Martin
-
FFonenantsoa Maurica
-
MMelody Méaulle
-
BBenjamin Monate
-
YYannick Moy
-
PPierre Nigron
-
AAnne Pacalet
-
VValentin Perrelle
-
GGuillaume Petiot
-
DDario Pinto
-
VVirgile Prevosto
-
AArmand Puccetti
-
FFélix Ridoux
-
VVirgile Robles
-
JJan Rochel
-
MMuriel Roger
-
JJulien Signoles
-
NNicolas Stouls
-
KKostyantyn Vorobyov
-
BBoris Yakobowski
Maintainers
Sources
sha256=29612882330ecb6eddd0b4ca3afc0492b70d0feb3379a1b8e893194c6e173983
doc/frama-c-eva.gui/Eva_gui/Gui_eval/Make/argument-1-X/Dom/index.html
Module X.Dom
include Frama_c_kernel.Datatype.S_with_collections with type t = state
include Frama_c_kernel.Datatype.S with type t = state
include Frama_c_kernel.Datatype.S_no_copy with type t = state
include Frama_c_kernel.Datatype.Ty with type t = state
type t = stateval ty : t Frama_c_kernel.Type.tval descr : t Frama_c_kernel.Descr.tDatatype descriptor.
val packed_descr : Frama_c_kernel.Structural_descr.packPacked version of the descriptor.
val reprs : t listList of representants of the descriptor.
val hash : t -> intHash function: same spec than Hashtbl.hash.
val pretty : Format.formatter -> t -> unitPretty print each value in an user-friendly way.
val mem_project : (Frama_c_kernel.Project_skeleton.t -> bool) -> t -> boolmem_project f x must return true iff there is a value p of type Project.t in x such that f p returns true.
module Set : Frama_c_kernel.Datatype.Set with type elt = tmodule Map : Frama_c_kernel.Datatype.Map with type key = tmodule Hashtbl : Frama_c_kernel.Datatype.Hashtbl with type key = tLattice Structure
val top : tGreatest element.
val widen :
Frama_c_kernel.Cil_types.kernel_function ->
Frama_c_kernel.Cil_types.stmt ->
t ->
t ->
twiden h t1 t2 is an over-approximation of join t1 t2. Assumes is_included t1 t2
val narrow : t -> t -> t Eva.Eval.or_bottomOver-approximation of the intersection of two abstract states (called meet in the literature). Used only to gain some precision when interpreting the complete behaviors of a function specification. Can be very imprecise without impeding the analysis: meet x y = `Value x is always sound.
Queries
type value = Val.tNumerical values to which the expressions are evaluated.
type location = Loc.locationAbstract memory locations associated to left values.
The origin is used by the domain combiners to track the origin of a value. An abstract domain can always use a dummy type unit for origin, or use it to encode some specific information about a value.
Queries functions return a pair of:
- the set of alarms that ensures the of the soundness of the evaluation of
exp.Alarmset.allis always a sound over-approximation of these alarms. - a value for the expression, which can be: – `Bottom if its evaluation is infeasible; – `Value (v, o) where
vis an over-approximation of the abstract value of the expressionexp, andois the origin of the value, which can be None.
When evaluating an expression, the evaluation engine asks the domains for abstract values and alarms at each lvalue (via extract_lval) and each sub-expressions (via extract_expr). In these queries:
oracleis an evaluation function and can be used to find the answer by evaluating some others expressions, especially by relational domain. No recursive evaluation should be done by this function.contextrecord gives some information about the current evaluation.
val extract_expr :
oracle:(Frama_c_kernel.Cil_types.exp -> value Eva.Eval.evaluated) ->
Eva__.Abstract_domain.evaluation_context ->
t ->
Frama_c_kernel.Cil_types.exp ->
(value * origin option) Eva.Eval.evaluatedQuery function for compound expressions: extract_expr ~oracle context t exp returns the known value of exp by the state t. See above for more details on queries.
val extract_lval :
oracle:(Frama_c_kernel.Cil_types.exp -> value Eva.Eval.evaluated) ->
Eva__.Abstract_domain.evaluation_context ->
t ->
Frama_c_kernel.Cil_types.lval ->
Frama_c_kernel.Cil_types.typ ->
location ->
(value * origin option) Eva.Eval.evaluatedQuery function for lvalues: extract_lval ~oracle context t lval typ loc returns the known value stored at the location loc of the left value lval of type typ. See above for more details on queries.
val backward_location :
t ->
Frama_c_kernel.Cil_types.lval ->
Frama_c_kernel.Cil_types.typ ->
location ->
value ->
(location * value) Eva.Eval.or_bottombackward_location state lval typ loc v reduces the location loc of the lvalue lval of type typ, so that only the locations that may have value v are kept. The returned location must be included in loc, but it is always sound to return loc itself. Also returns the value that may have the returned location, if not bottom. Defined by Domain_builder.Complete with no reduction.
val reduce_further :
t ->
Frama_c_kernel.Cil_types.exp ->
value ->
(Frama_c_kernel.Cil_types.exp * value) listGiven a reduction expr = value, provides more reductions that may be performed. Defined by Domain_builder.Complete with no reduction.
Transfer Functions
Transfer functions from the result of evaluations. See Eval for more details about valuation.
update valuation t updates the state t with the values of expressions and the locations of lvalues available in the valuation record.
val assign :
Frama_c_kernel.Cil_types.kinstr ->
location Eva.Eval.left_value ->
Frama_c_kernel.Cil_types.exp ->
(location, value) Eva.Eval.assigned ->
(value, location, origin) Eva__.Abstract_domain.valuation ->
t ->
t Eva.Eval.or_bottomassign kinstr lv expr v valuation state is the transfer function for the assignment lv = expr for state. It must return the state where the assignment has been performed.
kinstris the statement of the assignment, or Kglobal for the initialization of a global variable.- when the kinstr is a function call,
expris the special variable in!Eval.call.return. vcarries the value being assigned tolv, i.e. the value of the expressionexpr.valso denotes the kind of assignment: Assign for the default assignment of the value, or Copy for the exact copy of a location if the right expressionexpris a lvalue.valuationis a cache of all sub-expressions and locations computed for the evaluation oflvalandexpr; it can also be used to reduce the state.
val assume :
Frama_c_kernel.Cil_types.stmt ->
Frama_c_kernel.Cil_types.exp ->
bool ->
(value, location, origin) Eva__.Abstract_domain.valuation ->
t ->
t Eva.Eval.or_bottomTransfer function for an assumption. assume stmt expr bool valuation state returns a state in which the boolean expression expr evaluates to bool.
stmtis the statement of the assumption.valuationis a cache of all sub-expressions and locations computed for the evaluation and the reduction ofexpr; it can also be used to reduce the state.
val start_call :
Frama_c_kernel.Cil_types.stmt ->
(location, value) Eva.Eval.call ->
Eva.Eval.recursion option ->
(value, location, origin) Eva__.Abstract_domain.valuation ->
t ->
t Eva.Eval.or_bottomstart_call stmt call recursion valuation state returns an initial state for the analysis of a called function. In particular, this function should introduce the formal parameters in the state, if necessary.
stmtis the statement of the call site;callrepresents the call: the called function and the arguments;recursionis the information needed to interpret a recursive call. It is None if the call is not recursive.stateis the abstract state at the call site, before the call;valuationis a cache for all values and locations computed during the evaluation of the function and its arguments.
On recursive calls, recursion contains some substitution of variables to be applied on the domain state to prevent mixing up local variables and formal parameters of different recursive calls. See Eval.recursion for more details. This substitution has been applied on values and expressions in call, but not in the valuation given as argument. If the domain uses some information from the valuation on a recursive call, it must apply the substitution on it.
val finalize_call :
Frama_c_kernel.Cil_types.stmt ->
(location, value) Eva.Eval.call ->
Eva.Eval.recursion option ->
pre:t ->
post:t ->
t Eva.Eval.or_bottomfinalize_call stmt call ~pre ~post computes the state after a function call, given the state pre before the call, and the state post at the end of the called function.
stmtis the statement of the call site;callrepresents the function call and its arguments.recursionis the information needed to interpret a recursive call. It is None if the call is not recursive.preandpostare the states before and at the end of the call respectively.
val show_expr :
(value, location, origin) Eva__.Abstract_domain.valuation ->
t ->
Format.formatter ->
Frama_c_kernel.Cil_types.exp ->
unitCalled on the Frama_C_domain_show_each directive. Prints the internal properties inferred by the domain in the state about the expression exp. Can use the valuation resulting from the cooperative evaluation of the expression. Defined by Domain_builder.Complete but prints nothing.
Logic
Logical evaluation. This API is subject to changes.
logic_assign None loc state removes from state all inferred properties that depend on the memory location loc. If the first argument is not None, it contains the logical clause being interpreted and the pre-state in which the terms of the clause are evaluated. The clause can be an assigns, allocates or frees clause. loc is then the memory location concerned by the clause.
val evaluate_predicate :
state Eva__.Abstract_domain.logic_environment ->
state ->
Frama_c_kernel.Cil_types.predicate ->
Frama_c_kernel.Abstract_interp.Comp.resultEvaluates a predicate to a logical status in the current state. The logic_environment contains the states at some labels and the potential variable for \result. Defined by Domain_builder.Complete: all predicates are Unknown.
val reduce_by_predicate :
state Eva__.Abstract_domain.logic_environment ->
state ->
Frama_c_kernel.Cil_types.predicate ->
bool ->
state Eva.Eval.or_bottomreduce_by_predicate env state pred b reduces the current state by assuming that the predicate pred evaluates to b. env contains the states at some labels and the potential variable for \result. Defined by Domain_builder.Complete with no reduction.
val interpret_acsl_extension :
Frama_c_kernel.Cil_types.acsl_extension ->
state Eva__.Abstract_domain.logic_environment ->
state ->
stateInterprets an ACSL extension. Defined by Domain_builder.Complete as the identity.
Scoping and initialization
Scoping: abstract transformers for entering and exiting blocks. The variables should be added or removed from the abstract state here. Note that the formals of a called function enter the scope through the transfer function start_call, and leave it through a call to leave_scope.
val enter_scope :
Eva__.Abstract_domain.variable_kind ->
Frama_c_kernel.Cil_types.varinfo list ->
t ->
tIntroduces a list of variables in the state. At this point, the variables are uninitialized. Globals and formals of the 'main' will be initialized by initialize_variable and initialize_variable_using_type. Local variables remain uninitialized until an assignment through assign. The formal parameters of a call enter the scope through start_call.
val leave_scope :
Frama_c_kernel.Cil_types.kernel_function ->
Frama_c_kernel.Cil_types.varinfo list ->
t ->
tRemoves a list of local and formal variables from the state. The first argument is the englobing function.
val empty : unit -> tThe initial state with which the analysis start.
val initialize_variable :
Frama_c_kernel.Cil_types.lval ->
location ->
initialized:bool ->
Eva__.Abstract_domain.init_value ->
t ->
tinitialize_variable lval loc ~initialized init_value state initializes the value of the location loc of lvalue lval in state with: – bits 0 if init_value = Zero; – any bits if init_value = Top. The boolean initialized is true if the location is initialized, and false if the location may be not initialized.
val initialize_variable_using_type :
Eva__.Abstract_domain.variable_kind ->
Frama_c_kernel.Cil_types.varinfo ->
t ->
tInitializes a variable according to its type. The variable can be:
- a global variable on lib-entry mode.
- a formal parameter of the 'main' function.
- the return variable of a function specification.
Miscellaneous
Transfer functions called when entering/leaving a loop, and at each loop iteration. Defined as identity by Domain_builder.Complete.
val enter_loop : Frama_c_kernel.Cil_types.stmt -> state -> stateval incr_loop_counter : Frama_c_kernel.Cil_types.stmt -> state -> stateval leave_loop : Frama_c_kernel.Cil_types.stmt -> state -> stateval relate :
Frama_c_kernel.Cil_types.kernel_function ->
Frama_c_kernel.Base.Hptset.t ->
t ->
Frama_c_kernel.Base.SetLattice.trelate kf bases state returns the set of bases bases in relation with bases in state — i.e. all bases other than bases whose value may affect the properties inferred on bases in state. state is the initial state of an analysis of kf. For a non-relational domain, it is always safe to return empty. For a relational domain, it is always safe to return top, but it disables MemExec.
val filter :
[ `Pre of Frama_c_kernel.Cil_types.kernel_function
| `Post of Frama_c_kernel.Cil_types.kernel_function
| `Print ] ->
Frama_c_kernel.Base.Hptset.t ->
t ->
tfilter kind bases states reduces the state state to only keep properties about bases — it is a projection on the set of bases. It allows reusing an analysis of kf from an initial state pre to a final state post. If kind is `Pre kf, state is the initial state of function kf, and bases includes all inputs of kf and satisfies relate kf bases state = bases. If kind is `Post kf, state is the final state of kf, and bases includes all inputs and outputs of kf. Afterwards, the two resulting states reduced_pre and reduced_post are used as follow: when kf should be analyzed with the initial state s, if filter kf `Pre s = reduced_pre, then the analysis is skipped, and reuse kf s reduced_post is used as its final state instead. If kind is `Print, the state is reduced before printing it for the end-user.
val reuse :
Frama_c_kernel.Cil_types.kernel_function ->
Frama_c_kernel.Base.Hptset.t ->
current_input:t ->
previous_output:t ->
treuse kf bases current_input previous_output merges the initial state current_input with a final state previous_output from a previous analysis of kf started with an equivalent initial state. reuse must overwrite the properties on bases in current_input with the ones in previous_output. Properties on other bases must be left unchanged from current_input.
Domain_builtin.Complete provides the simplest implementation of filter and reuse, which is: let filter _ _ _ state = state let reuse _ _ ~current_input:_ ~previous_output = previous_output This is correct as the cache will be triggered only for an initial state exactly equal to the previous initial state, in which case the previous output state is indeed a correct final state on its own.
Category for the messages about the domain. Must be created through Self.register_category.
val post_analysis : t Eva.Eval.or_bottom -> unitThis function is called after the analysis. The argument is the state computed at the return statement of the main function. The function can also access all states stored in the Store module during the analysis. If the analysis aborted, this function is not called. Defined by Domain_builder.Complete as doing nothing.
module Store : sig ... endStorage of the states computed by the analysis. Automatically built by Domain_builder.Complete.
val structure : t Eva__.Abstract.Domain.structureval get : 'a Eva__.Structure.Key_Domain.key -> (t -> 'a) optionFor a key of type k key:
- if the values of type
tcontain a subpart of typekfrom a module identified by the key, thenget keyreturns an accessor for it. - otherwise,
get keyreturns None.
For a key of type k key:
- if the values of type
tcontain a subpart of typekfrom a module identified by the key, thenset key v treturns the valuetin which this subpart has been replaced byv. - otherwise,
set key _is the identity function.
Iterators on the components of a structure.
val iter : polymorphic_iter_fun -> t -> unitval fold : 'b polymorphic_fold_fun -> t -> 'b -> 'bval map : polymorphic_map_fun -> t -> t