123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat a l'energie atomique et aux energies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openCil_datatypeopenLang.FopenSigs(* ------------------------------------------------------------------------ *)(* ---- Pretty-printers ---- *)(* ------------------------------------------------------------------------ *)letpp_sequencepp_valfmtseq=Format.fprintffmt"@[{pre=%a,@,post=%a}@]"pp_valseq.prepp_valseq.postletpp_equationfmt=function|Set(lt,rt)->Format.fprintffmt"@[%a =@, %a@]"pp_termltpp_termrt|Assertpred->pp_predfmtpredletpp_acsfmt=function|RW->Format.pp_print_stringfmt"RW"|RD->Format.pp_print_stringfmt"RD"|OBJ->Format.pp_print_stringfmt"OBJ"letpp_valuepp_locfmt=function|Valt->pp_termfmtt|Locl->pp_locfmtlletpp_rlocpp_locfmt=function|Rloc(_obj,l)->Format.fprintffmt"[@{%a}@]"pp_locl|Rrange(l,_obj,tmin,tmax)->Format.fprintffmt"@[%a+(%a..%a)@]"pp_locl(Pretty_utils.pp_optpp_term)tmin(Pretty_utils.pp_optpp_term)tmaxletpp_slocpp_locfmt=function|Slocl->Format.fprintffmt"@[{%a}@]"pp_locl|Sarray(l,_obj,size)->Format.fprintffmt"@[%a+(0..%d)@]"pp_loclsize|Srange(l,_obj,tmin,tmax)->Format.fprintffmt"@[%a+(%a..%a)@]"pp_locl(Pretty_utils.pp_optpp_term)tmin(Pretty_utils.pp_optpp_term)tmax|Sdescr(xs,l,p)->Format.fprintffmt"@[{ %a @,| %a@,; %a }@]"pp_locl(Pretty_utils.pp_listpp_var)xspp_predp(* ------------------------------------------------------------------------ *)(* ---- Debug Memory Model ---- *)(* ------------------------------------------------------------------------ *)letdkey_cons=Wp_parameters.register_category"memdebug:cons"letdkey_loc=Wp_parameters.register_category"memdebug:loc"letdkey_cast=Wp_parameters.register_category"memdebug:cast"letdkey_access=Wp_parameters.register_category"memdebug:access"letdkey_valid=Wp_parameters.register_category"memdebug:valid"letdkey_alias=Wp_parameters.register_category"memdebug:alias"letdebug_cons=Wp_parameters.debug~dkey:dkey_consletdebug_loc=Wp_parameters.debug~dkey:dkey_locletdebug_cast=Wp_parameters.debug~dkey:dkey_castletdebug_access=Wp_parameters.debug~dkey:dkey_accessletdebug_valid=Wp_parameters.debug~dkey:dkey_validletdebug_alias=Wp_parameters.debug~dkey:dkey_aliasmoduleMake(M:Sigs.Model)=structletdatatype="MemDebug."^M.datatypeletconfigure=M.configurelethypotheses=M.hypothesesmoduleChunk=M.ChunkmoduleHeap=M.HeapmoduleSigma=M.Sigmatypeloc=M.loctypechunk=M.chunktypesigma=M.sigmatypesegment=M.segmenttypestate=M.state(* ---------------------------------------------------------------------- *)(* ---- Pretty-printing ---- *)(* ---------------------------------------------------------------------- *)letpretty=M.prettyletstate=M.stateletiter=M.iterletlookup=M.lookupletupdates=M.updatesletapply=M.applyletvars=M.varsletoccurs=M.occurs(* ---------------------------------------------------------------------- *)(* ---- Constructors ----- *)(* ---------------------------------------------------------------------- *)letnull=letl=M.nullindebug_cons"null:@, %a"prettyl;M.nullletliteral~eidcstr=letl=M.literal~eidcstrindebug_cons"literal ~eid:%d ->@, %a"eidprettyl;lletcvarx=letl=M.cvarxindebug_cons"cvar %a ->@, %a"Varinfo.prettyxprettyl;lletpointer_loce=letl=M.pointer_loceindebug_cons"term2loc %a ->@, %a"pp_termeprettyl;lletpointer_vall=lete=M.pointer_vallindebug_cons"loc2term %a ->@, %a"prettylpp_terme;e(* ---------------------------------------------------------------------- *)(* ---- Operations ---- *)(* ---------------------------------------------------------------------- *)letfieldlfd=letl'=M.fieldlfdindebug_loc"@[%a.%a ->@, %a@]"prettylFieldinfo.prettyfdprettyl';l'letshiftlobje=letl'=M.shiftlobjeindebug_loc"@[%a+%a ->@, %a@]"prettylpp_termeprettyl';l'letbase_addrl=letl'=M.base_addrlindebug_loc"@[base_addr: %a -> %a@]"prettylprettyl';l'letblock_length=M.block_length(* ---------------------------------------------------------------------- *)(* ---- Casting ----- *)(* ---------------------------------------------------------------------- *)letcasttyl=letl'=M.casttylindebug_cast"(%a)%a -> %a"Ctypes.prettyty.postprettylprettyl';l'letloc_of_intobje=letl=M.loc_of_intobjeindebug_cast"(%a)%a -> %a"Ctypes.prettyobjpp_termeprettyl;lletint_of_loccintl=lete=M.int_of_loccintlindebug_cast"(%a)%a -> %a"Ctypes.pp_intcintprettylpp_terme;e(* ---------------------------------------------------------------------- *)(* ---- Domain ----- *)(* ---------------------------------------------------------------------- *)letdomain=M.domain(* ---------------------------------------------------------------------- *)(* ---- Memory Access ----- *)(* ---------------------------------------------------------------------- *)letloadsobjl=letv=M.loadsobjlindebug_access"@[load %a @, %a @, %a ->@, %a@]@."Sigma.prettysCtypes.prettyobjprettyl(pp_valuepretty)v;vletload_init_s_obj_l=e_falseletstoredseqobjlt=letpreds=M.storedseqobjltindebug_access"@[stored %a@, %a@, %a@, %a ->@, %a@]@."(pp_sequenceSigma.pretty)seqCtypes.prettyobjprettylpp_termt(Pretty_utils.pp_listpp_equation)preds;predsletstored_init_seq_obj_l_v=[]letcopiedseqobjllrl=letpreds=M.copiedseqobjllrlindebug_access"@[copied %a@, %a@, %a@, %a ->@, %a@]@."(pp_sequenceSigma.pretty)seqCtypes.prettyobjprettyllprettyrl(Pretty_utils.pp_listpp_equation)preds;predsletcopied_init_seq_obj_ll_rl=[]letassignedseqobjsloc=letpreds=M.assignedseqobjslocindebug_access"@[assigned %a@, %a@, %a ->@, %a@]@."(pp_sequenceSigma.pretty)seqCtypes.prettyobj(pp_slocpretty)sloc(Pretty_utils.pp_listpp_equation)preds;preds(* ---------------------------------------------------------------------- *)(* ---- Pointer Comparison ----- *)(* ---------------------------------------------------------------------- *)letis_null=M.is_nullletloc_eq=M.loc_eqletloc_lt=M.loc_ltletloc_leq=M.loc_leqletloc_neq=M.loc_neqletloc_diff=M.loc_diff(* ---------------------------------------------------------------------- *)(* ---- Validity ----- *)(* ---------------------------------------------------------------------- *)letvalidsacsseg=letp=M.validsacssegindebug_valid"@[valid %a@, %a@, %a ->@, %a@]@."Sigma.prettyspp_acsacs(pp_rlocpretty)segpp_predp;pletinvalidsseg=letp=M.invalidssegindebug_valid"@[invalid %a@, %a ->@, %a@]@."Sigma.prettys(pp_rlocpretty)segpp_predp;pletscope=M.scopeletglobal=M.global(* ---------------------------------------------------------------------- *)(* ---- Separation ----- *)(* ---------------------------------------------------------------------- *)letincludedseg1seg2=letp=M.includedseg1seg2indebug_alias"@[included %a@, %a ->@, %a@]@."(pp_rlocpretty)seg1(pp_rlocpretty)seg2pp_predp;pletseparatedseg1seg2=letp=M.separatedseg1seg2indebug_alias"@[separated %a@, %a ->@, %a@]@."(pp_rlocpretty)seg1(pp_rlocpretty)seg2pp_predp;p(** todo *)letinitialized=M.initializedletalloc=M.allocletframe=M.frameletis_well_formed=M.is_well_formedletbase_offset=M.base_offsettypedomain=M.domainletconfigure_ia=M.configure_iaend