1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2025 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* 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_typesletmthread_global_varvar_name()=tryGlobals.Vars.find_from_astinfovar_nameGlobalwithNot_found->Mt_options.fatal"Variable@ %s@ not@ found.@ It@ should@ be@ in@ %a."var_nameFilepath.pretty(Mt_lib.mthread_h())letis_call_to_syncstmt=matchstmt.skindwith|Instr(Call(_,{enode=Lval(Varvi,_)},_,_))whenvi.vname="Frama_C_mthread_sync"->true(* No Local_init possible here, as Frama_C_mthread_sync returns void. *)|_->false(* -------------------------------------------------------------------------- *)(* --- Pretty-printing --- *)(* -------------------------------------------------------------------------- *)letkinstr_to_source=function|Kglobal->None|Kstmtstmt->Some(fst(Cil_datatype.Stmt.locstmt))letpretty_succsfmtstmt=(Pretty_utils.pp_list~sep:" "(funfmts->Format.fprintffmt"%d"s.sid))fmtstmt.succs(* -------------------------------------------------------------------------- *)(* --- Stacks --- *)(* -------------------------------------------------------------------------- *)typestack_elt=kernel_function*kinstrmoduleStackElt=structincludeDatatype.Pair(Kernel_function)(Cil_datatype.Kinstr)letprettyfmt(f,ki)=Format.fprintffmt"@[<hov 2>%s%t@]"(Ast_info.Function.get_namef.fundec)(funfmt->matchkiwith|Kstmtstmt->letloc=Cil_datatype.Stmt.locstmtinFormat.fprintffmt" :: %a"Cil_datatype.Location.prettyloc|Kglobal->())endtypestack=stack_eltlistmoduleStack=structincludeDatatype.List(StackElt)letpretty=Pretty_utils.pp_list~pre:"@[<hv>"~sep:" <-@ "~suf:"@]"StackElt.prettymoduleFunAccessVars=State_builder.Option_ref(Cil_datatype.Kf)(structletdependencies=[Ast.self]letname="Stack.FunAccessVars"end)letfun_access_vars()=FunAccessVars.memo(fun()->Kernel_function.dummy())letaccess_to_varstmt:stack_elt=fun_access_vars(),Kstmtstmtletis_access_to_var(kf,_)=Kernel_function.equalkf(fun_access_vars())end