123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293(**************************************************************************)(* *)(* SPDX-License-Identifier LGPL-2.1 *)(* Copyright (C) *)(* CEA (Commissariat à l'énergie atomique et aux énergies alternatives) *)(* *)(**************************************************************************)openCil_types(* -------------------------------------------------------------------------- *)(* --- User-Defined Probes --- *)(* -------------------------------------------------------------------------- *)typeprobe={id:int;name:string;stmt:stmtoption;loc:location;}letcreate=letid=ref(-1)infun~loc?stmt~name()->incrid;{id=!id;loc;stmt;name}moduleS=structincludeDatatype.Undefinedletname="WP.Conditions.Probe.t"letreprs=[{loc=Cil_datatype.Location.unknown;stmt=None;name="";id=1}]typet=probelethashx=x.idletequalxy=Int.equalx.idy.idletcomparexy=Int.comparey.idx.id(* lastly created first (wp) *)letprettyfmtp=ifWp_parameters.debug_atleast1thenFormat.fprintffmt"%s#%d"p.namep.idelseFormat.fprintffmt"%s"p.nameendincludeDatatype.Make_with_collections(S)(* -------------------------------------------------------------------------- *)(* --- ACSL Extension --- *)(* -------------------------------------------------------------------------- *)letrecname_of_host=function|TVar{lv_name=x}->x|TResult_->"result"(* currently not used, but could be one day *)|TMemt->name_of_termtandname_of_term(t:term)=matcht.term_namewitha::_->a|_->matcht.term_nodewith|TLval(lh,_)|TAddrOf(lh,_)|TStartOf(lh,_)->name_of_hostlh|_->raiseNot_foundletannotationsstmt=letcollect_emitterannotacc=matchannot.annot_contentwith|Cil_types.AExtended(_,_,{ext_name="probe";ext_kind=Ext_termsps;})->List.rev_appendpsacc|_->accinletmk_probet=tryname_of_termt,twithNot_found->Wp_parameters.abort~source:(fstt.term_loc)"Missing name for probe, use @probe A: term;"inList.rev_mapmk_probe(Annotations.fold_code_annotcollectstmt[])letparse_probe:Acsl_extension.extension_typer=funcontext_locterms->(* use default context of the code-annotation (like an assert clause) *)letparse_term=context.type_termcontextcontext.pre_stateinExt_terms(List.mapparse_termterms)letregistered=reffalseletregister()=ifnot!registered&&Wp_parameters.Probes.get()thenbeginregistered:=true;Acsl_extension.register_code_annot~plugin:"wp""probe"parse_probefalse;endlet()=Cmdline.run_after_configuring_stageregister(* -------------------------------------------------------------------------- *)