File ‹program_analysis.ML›
signature PROGRAM_ANALYSIS =
sig
type 'a wrap = 'a RegionExtras.wrap
type 'ce ctype = 'ce Absyn.ctype
type expr = Absyn.expr
type ecenv = Absyn.ecenv
type s2s_config = {anon_vars : bool, owners : string list,
allow_underscore_idents : bool,
munge_info_fname : Path.T option, prog_name: string}
type 'a rcd_env = (string * (CType.rcd_kind * (string wrap * 'a) list * Region.t * CType.attribute list)) list
type senv = (int ctype * CType.attribute list) rcd_env
type union_variants = (string * ((string * senv) list)) list
type nm_info = {src_name : string, isa_name : MString.t}
type var_info
val is_global : var_info -> bool
val srcname : var_info -> string
val fullname : var_info -> string
val get_mname : var_info -> MString.t
val get_fname : var_info -> string option
val get_vtype : var_info -> int ctype
val get_struct_env : var_info -> senv
val get_attrs : var_info -> StmtDecl.gcc_attribute list
val declpos : var_info -> Region.t
val vi_compare : var_info * var_info -> order
datatype modify_var = M of var_info | TheHeap | PhantomState
| GhostState | AllGlobals
val mvar_compare : modify_var * modify_var -> order
val string_of_mvar : modify_var -> string
structure MVar_Table : TABLE where type key = modify_var
type selector = Expr.selector
type fun_ptr_call_info = (int ctype * int ctype list) *
(string * AstDatatype.var_info * selector list) list *
bool
datatype fncall_type = DirectCall of string
| FnPtrCall of fun_ptr_call_info
val is_function: (string * AstDatatype.var_info * selector list) -> bool
val fncall_ord : fncall_type * fncall_type -> order
type callgraph =
{callees: string Binaryset.set Symtab.table, callers: string Binaryset.set Symtab.table}
val closure: string Binaryset.set Symtab.table -> string list -> Symtab.key Binaryset.set
datatype clang_record_name = Named of string | Anonymous of SourcePos.t
datatype clang_field_kind =
Strct of {record_name: clang_record_name, field_name: string option} |
Un of {record_name: clang_record_name, field_name: string option} |
Fld of {name:string, typ:string}
type clang_field = {kind: clang_field_kind, level: int}
type clang_field_info = {field: clang_field, offset: int}
type clang_record_info = {
header: clang_field_info,
flds: clang_field_info list,
size: int,
align: int}
type csenv
type embedded_fncall_exprs = (expr * fncall_type list) list Symtab.table
val cse2ecenv : Proof.context -> csenv -> ecenv
val get_array_mentions : csenv -> (int ctype * int) Binaryset.set
val get_prog_name: csenv -> string
val get_senv : csenv -> senv
val get_pruned_senv : csenv -> senv
val get_union_variants : csenv -> union_variants
val variant_origin: csenv -> string -> string option
val get_clang_record_infos: csenv -> clang_record_info list
val map_clang_record_infos: (clang_record_info list -> clang_record_info list) -> csenv -> csenv
val get_rettype : string -> csenv -> int ctype option
val get_heaptypes : csenv -> int ctype Binaryset.set
val get_usedtypes : csenv -> int ctype Binaryset.set
val compute_callgraphs : csenv -> callgraph
val compute_callgraphs_with_exit : csenv -> callgraph
val get_addressed : csenv -> (expr * selector list) list XMSymTab.table
val is_addressed : csenv -> (MString.t * string option) -> bool
val get_addressed_types: csenv -> selector list Ord_List.T Absyn.CTypeTab.table
val get_callgraph : csenv -> fncall_type Binaryset.set Symtab.table
val get_direct_callees: csenv -> Symtab.key -> string list
val get_fun_ptr_callees: csenv -> Symtab.key -> string list
val get_fun_ptr_calls: csenv -> string -> fun_ptr_call_info list
val has_fun_ptr_calls: csenv -> string -> bool
val program_has_fun_ptr_calls: csenv -> bool
val functions_with_local_fun_ptr_calls: csenv -> string list
val get_fun_ptr_params: csenv -> ((string * AstDatatype.var_info * selector list) list) option list Symtab.table
val get_other_fun_ptr_dependencies: csenv -> Symtab.key -> string list
val get_all_other_fun_ptr_dependencies: csenv -> string list
val get_all_addressed_funs : csenv -> string list
val get_indirect_fun_ptr_dependencies: csenv -> Symtab.key -> string list
val get_callers : csenv -> string Binaryset.set Symtab.table
val get_vars : csenv -> var_info list Symtab.table
val get_locals : csenv -> string -> var_info list
val get_return_vars: csenv -> string -> var_info list
val get_variables : csenv -> string option -> var_info list
val get_globals : csenv -> var_info list
val get_globinits : csenv -> Absyn.expr MSymTab.table
val get_mangled_vars : csenv -> var_info list Symtab.table
val get_params : string -> csenv -> var_info list option
val get_fnspecs: csenv -> AstDatatype.fnspec list Symtab.table
val get_fun_ty: csenv -> string -> int CTypeDatatype.ctype option
val get_embedded_fncalls : csenv -> fncall_type Binaryset.set
val get_embedded_fncall_exprs: csenv -> embedded_fncall_exprs
val get_referenced_funs: csenv -> string list Symtab.table
val get_all_referenced_funs: {with_proto: bool} -> csenv -> Symtab.key list
val get_referenced_funs_global: csenv -> string list
val get_referenced_funs_via_const_globals: csenv -> Symtab.key -> string list
val get_functions_used_as_fun_ptr_params: csenv -> string list
val has_fun_ptr_params_called_with_object_method: csenv -> bool
val functions_with_fun_ptr_calls: csenv -> string list
val get_functions_used_via_fun_ptr: csenv -> string list
val get_functions_with_sig: csenv -> (int ctype * int ctype list) -> string list
val get_addressed_vis : string option -> csenv -> var_info list
val get_addressed_globals : csenv -> string -> string list
val get_local_info: csenv -> MString.t * string option -> {kind:NameGeneration.var_kind, addressed:bool,info:var_info} option
val has_addressable_variables: csenv -> string -> bool
val callers_with_addressable_variables: csenv -> string -> string list
val get_global_addressed : csenv -> (MString.t * (Absyn.expr * selector list) list) list
val get_vi_nm_info : csenv -> var_info -> nm_info
val get_fun_modifies : csenv -> string -> modify_var Binaryset.set option
val get_functions : csenv -> string list
val get_max_function_arity : csenv -> int
val get_non_proto_functions : csenv -> string list
val has_body_spec : csenv -> Symtab.key -> bool
val get_non_proto_and_body_spec_functions : csenv -> string list
val get_fninfo : csenv -> (int ctype * bool * var_info list) Symtab.table
val get_hpfninfo : csenv -> Absyn.ext_decl Symtab.table
val get_constant_global_fun_ptrs : csenv -> (string * string list) list
val map_constant_global_fun_ptrs : ((string * string list) list -> (string * string list) list)
-> csenv -> csenv
val get_global_fun_ptrs_grouped_by_type: csenv -> (string * int CTypeDatatype.ctype) list list
val get_global_fun_ptr_group_with_same_type: csenv -> string -> string list
val get_cliques : csenv -> string list list
val map_cliques : (string list list -> string list list ) -> csenv -> csenv
val get_final_callgraph : csenv -> callgraph
val get_final_callers : csenv -> string list -> string list
val get_final_callees : csenv -> string list -> string list
val map_final_callgraph: (callgraph -> callgraph) -> csenv -> csenv
val get_final_callgraph_with_exit : csenv -> callgraph
val map_final_callgraph_with_exit: (callgraph -> callgraph) -> csenv -> csenv
val get_clique : csenv -> string -> string list option
val get_fun_ptr_core_clique : csenv -> string list
val map_fun_ptr_core_clique: (string list -> string list) -> csenv -> csenv
val get_fun_ptr_clique : csenv -> string list
val get_fun_ptr_clique_fun_ptrs : csenv -> string list
val get_fun_ptr_parameters: csenv -> Symtab.key -> var_info option list
val has_fun_ptr_parameters: csenv -> Symtab.key -> bool
val all_fun_ptr_parameters: csenv -> var_info list
val all_fun_ptr_parameter_types: csenv -> int CTypeDatatype.ctype list
val all_method_fun_ptr_types: csenv -> int CTypeDatatype.ctype list
val get_method_approx: csenv -> string Binaryset.set Expr.CTypeSelectorsTab.table
val is_exit_reachable: csenv -> string -> bool
val update_hpfninfo0 : Absyn.ext_decl -> Absyn.ext_decl Symtab.table ->
Absyn.ext_decl Symtab.table
val add_init_globals_fun: StmtDecl.statement list -> csenv -> csenv
val get_defined_functions : csenv -> Region.Wrap.region Symtab.table
val get_read_globals : csenv -> modify_var Binaryset.set Symtab.table
val is_recursivefn : csenv -> string -> bool
val mvar_traverse : csenv -> csenv
val get_modified_global_locns : csenv -> string Binaryset.set MVar_Table.table
val get_all_globals : csenv -> int ctype MSymTab.table
val get_untouched_globals : csenv -> int ctype MSymTab.table
val get_touched_globinit_var_infos: csenv -> var_info list
val fndes_callinfo : Proof.context -> string -> AstDatatype.gcc_attribute list Region.Wrap.t list ->
csenv -> expr -> fncall_type * (int ctype * int ctype list)
val fns_by_type : csenv -> int ctype * int ctype list -> string list
val cse_typing : {report_error:bool} -> Proof.context -> csenv -> expr -> int ctype
val approx_expr : Proof.context -> csenv -> AstDatatype.expr_node ->
(string * AstDatatype.var_info * selector list) list
val used_fun_types_of_fun : csenv -> string -> int ctype list
val uses_globals : csenv -> string -> bool
val approx_globals': csenv ->
(string * (selector list * (string * AstDatatype.var_info) list) list) list
val approx_callees: csenv -> (string * Expr.var_info * selector list) -> string list
val process_decls : Proof.context -> s2s_config -> Absyn.ext_decl list ->
((Absyn.ext_decl list * Absyn.statement list) * csenv)
val function_specs : csenv -> Absyn.fnspec list Symtab.table
val sizeof_padding : csenv -> int ctype -> int * bool
val sizeof : csenv -> int ctype -> int
val sizeof_struct_or_union: csenv -> string -> int
val is_packed : csenv -> int ctype -> bool
val is_packed_trace : csenv -> int ctype -> bool
val is_packed_struct_or_union : csenv -> string -> bool
val is_packed_struct_or_union_trace : csenv -> string -> bool
val alignof: csenv -> int ctype -> int
val alignof_struct_or_union: csenv -> string -> int
val offsetof: csenv -> string -> string -> int
val offsetof': csenv -> string -> string list -> int
val contains_packed_attr: senv -> int ctype -> bool
val eq_string_assoc: (string * string list) list * (string * string list) list -> bool
type asm_stmt_elements = (string * bool * expr option * expr list)
val split_asm_stmt : Absyn.statement_node -> asm_stmt_elements
val merge_asm_stmt : asm_stmt_elements -> Absyn.statement_node
val get_globals_rcd : csenv -> senv
val dest_method_fun_ptr: string -> {report_error:bool} -> Proof.context -> AstDatatype.gcc_attribute list Region.Wrap.t list ->
csenv -> Expr.expr -> (int CTypeDatatype.ctype * string) option
val method_callers: csenv -> string list
val method_callers_via_fun_ptr_param: csenv -> string list
val method_callers_via_fun_ptr_param_of: csenv -> string -> string list
val callers_via_fun_ptr_param: csenv -> string list
val callers_via_local_fun_ptr_param: csenv -> string list
val callers_via_fun_ptr_param_of: csenv -> string -> string list
val callers_via_method_or_non_param_of_fun_ptr_param_of: csenv -> string -> string list
val method_types: csenv -> (int ctype * int ctype list) list
val potential_method_callees: csenv -> string list
val approx_global_fun_ptrs_from_ty: csenv -> int CTypeDatatype.ctype * AstDatatype.selector list -> string list
type mungedb = {fun_name: string option, nm_info: nm_info} list
val get_mungedb : csenv -> mungedb
val render_mungedb : mungedb -> string list
val export_mungedb : csenv -> unit
val check_post_ops_while: Proof.context -> Absyn.expr * AstDatatype.expr_node list -> unit
val mk_post_op_assign: AstDatatype.expr_node -> Absyn.statement
val variable_dependencies: Proof.context -> AstDatatype.dependencies Symtab.table -> csenv -> AstDatatype.dependencies Symtab.table
val get_variable_dependencies: csenv -> AstDatatype.dependencies Symtab.table
val map_variable_dependencies: (AstDatatype.dependencies Symtab.table -> AstDatatype.dependencies Symtab.table) -> csenv -> csenv
val check_embedded_fncall_exprs: Proof.context -> csenv -> unit
val check_packed_sizeof: bool Config.T
val check_packed_align: bool Config.T
val check_packed_offsets: bool Config.T
end
structure ProgramAnalysis: PROGRAM_ANALYSIS =
struct
fun maybe f opt = fold f (the_list opt)
open Absyn NameGeneration
type program = ext_decl list
type s2s_config = {anon_vars : bool, owners : string list,
allow_underscore_idents : bool, munge_info_fname : Path.T option, prog_name: string}
fun fname_str NONE = NameGeneration.initialisation_function
| fname_str (SOME f) = f
type 'a rcd_env = (string * (rcd_kind * (string wrap * 'a) list * Region.t * CType.attribute list)) list
type senv = (int ctype * CType.attribute list) rcd_env
type union_variants = (string * ((string * senv) list)) list