package frama-c
Install
dune-project
Dependency
Authors
-
MMichele Alberti
-
TThibaud Antignac
-
GGergö Barany
-
PPatrick Baudin
-
NNicolas Bellec
-
TThibaut Benjamin
-
AAllan Blanchard
-
LLionel Blatter
-
FFrançois Bobot
-
RRichard Bonichon
-
VVincent Botbol
-
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
-
RRemi Lazarini
-
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=d2fbb3b8d0ff83945872e9e6fa258e934a706360e698dae3b4d5f971addf7493
doc/frama-c.kernel/Frama_c_kernel/Base/index.html
Module Frama_c_kernel.Base
Abstraction of the base of an addressable memory zone, together with the validity of the zone.
type cstring = | CSString of string| CSWstring of Escape.wstring(*This type abstracts over the two kinds of constant strings present in strings. It is used in a few modules below Base.
*)
type variable_validity = private {mutable weak : bool;(*Indicate that the variable is weak, i.e. that it may represent multiple memory locations
*)mutable min_alloc : Abstract_interp.Int.t;(*First bit guaranteed to be valid; can be -1
*)mutable max_alloc : Abstract_interp.Int.t;(*Last possibly valid bit
*)max_allocable : Abstract_interp.Int.t;(*Maximum valid bit after size increase
*)
}Validity for variables that might change size.
Whether the allocated base has been obtained via calls to malloc/calloc/realloc (Malloc), alloca (Alloca), or is related to a variable-length array (VLA).
type base = private | Var of Cil_types.varinfo * validity(*Base for a standard C variable.
*)| CLogic_Var of Cil_types.logic_var * Cil_types.typ * validity(*Base for a logic variable that has a C type.
*)| Null(*Base for an address like
*)(int* )0x123| String of int * cstring(*String(id, s)id: unique id of the constant string (one per code location)s: contents of the constant string
| Allocated of Cil_types.varinfo * deallocation * validity(*Base for a variable dynamically allocated via malloc/calloc/realloc/alloca
*)
and validity = | Empty(*For 0-sized bases
*)| Known of Abstract_interp.Int.t * Abstract_interp.Int.t(*Valid between those two bits
*)| Unknown of Abstract_interp.Int.t * Abstract_interp.Int.t option * Abstract_interp.Int.t(*Unknown(b,k,e) indicates: If k is
None, potentially valid between b and e If k isSome k, then b <= k <= e, and the base is- valid between b and k;
- potentially valid between k+1 and e: Accesses on potentially valid parts will succeed, but will also raise an alarm.
| Variable of variable_validity(*Variable(min_alloc, max_alloc) means:
- all offsets between
0andmin_allocare valid; min_alloc can be -1, in which case no offsets are guaranteed to be valid. - offsets between
min_alloc+1andmax_allocare potentially valid; - offsets above
max_alloc+1are invalid.
- all offsets between
| Invalid(*Valid nowhere. Typically used for the NULL base, or for function pointers.
*)
module Base : sig ... endinclude Datatype.S_with_collections with type t = base
include Datatype.S with type t = base
include Datatype.S_no_copy with type t = base
val packed_descr : 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 : (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 : Datatype.Set with type elt = tmodule Map : Datatype.Map with type key = tmodule Hashtbl : Datatype.Hashtbl with type key = tmodule Hptshape :
Hptmap_sig.Shape with type key = t and type 'v map = 'v Hptmap.Shape(Base).tmodule SetLattice : Lattice_type.Lattice_Set with module O = Hptsetmodule Validity : Datatype.S with type t = validityval pretty_addr : Format.formatter -> t -> unitpretty_addr fmt base pretty-prints the name of base on fmt, with a leading ampersand if it is a variable
val typeof : t -> Cil_types.typ optionType of the memory block that starts from the given base. Useful to give to the function Bit_utils.pretty_bits, typically.
Validity
val pretty_validity : Format.formatter -> validity -> unitval validity_from_size : Abstract_interp.Int.t -> validityvalidity_from_size size returns Empty if size is zero, or Known (0, size-1) if size > 0. size must not be negative.
val validity_from_type : Cil_types.varinfo -> validityval valid_range : validity -> range_validityvalid_range v returns Invalid_range if v is Invalid, Valid_range None if v is Empty, or Valid_range (Some (mn, mx)) otherwise, where mn and mx are the minimum and maximum (possibly) valid bounds of v.
val is_weak_validity : validity -> boolis_weak_validity v returns true iff v is a Weak validity.
val create_variable_validity :
weak:bool ->
min_alloc:Abstract_interp.Int.t ->
max_alloc:Abstract_interp.Int.t ->
variable_validityval update_variable_validity :
variable_validity ->
weak:bool ->
min_alloc:Abstract_interp.Int.t ->
max_alloc:Abstract_interp.Int.t ->
unitUpdate the corresponding fields of the variable validity. Bases already weak cannot be made 'strong' through this function, and the validity bounds can only grow.
Finding bases
val of_varinfo : Cil_types.varinfo -> tval of_string_exp : Cil_types.exp -> tval of_c_logic_var : Cil_types.logic_var -> tMust only be called on logic variables that have a C type
Origin of the variable underlying a base
val to_varinfo : t -> Cil_types.varinfoval is_formal_or_local : t -> Cil_types.fundec -> boolval is_any_formal_or_local : t -> boolval is_any_local : t -> boolval is_global : t -> boolval is_formal_of_prototype : t -> Cil_types.varinfo -> boolval is_local : t -> Cil_types.fundec -> boolval is_formal : t -> Cil_types.fundec -> boolval is_block_local : t -> Cil_types.block -> boolval is_function : t -> boolNULL base
val null : tval is_null : t -> boolval min_valid_absolute_address : unit -> Abstract_interp.Int.tval max_valid_absolute_address : unit -> Abstract_interp.Int.tBounds for option absolute-valid-range
Size of a base
val bits_sizeof : t -> Int_Base.tAccess kind: read/write of k bits, or no access. Without any access, an offset must point into or just beyond the base ("one past the last element of the array object", non-array object being viewed as array of one element).
is_valid_offset access b offset holds iff the ival offset (expressed in bits) is completely valid for the access of base b (it only represents valid offsets for such an access). Returns false if offset may be invalid for such an access.
Computes all offsets that may be valid for an access of base t. For bases with variable or unknown validity, the result may not satisfy is_valid_offset, as some offsets may be valid or invalid. bitfield is true by default: the computed offset may be offsets of bitfields. If it is set to false, the computed offsets are byte aligned (they are all congruent to 0 modulo 8).
Misc
val is_read_only : t -> boolIs the base valid as a read/write location, or only for reading. The const attribute is not currently taken into account.
val is_weak : t -> boolval id : t -> intval is_aligned_by : t -> Abstract_interp.Int.t -> boolRegistering bases
This is only useful to create an initial memory state for analysis, and is never needed for normal users.
val register_allocated_var : Cil_types.varinfo -> deallocation -> validity -> tAllocated variables are variables not present in the source of the program, but instead created through dynamic allocation. Their field vsource is set to false.
val register_memory_var : Cil_types.varinfo -> validity -> tMemory variables are variables not present in the source of the program. They are created only to fill the contents of another variable. Their field vsource is set to false.
Substituting bases
This is used to efficiently replace some bases by others in locations or in memory states, for instance in Locations or Lmap_sig.
type substitution = base Hptshape.mapType used for the substitution between bases.
val substitution_from_list : (base * base) list -> substitutionCreates a substitution from an association list.