123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2024 *)(* 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). *)(* *)(**************************************************************************)includePlugin.Register(structletname="users"letshortname="users"lethelp="function callees"end)moduleForceUsers=False(structletoption_name="-users"lethelp="compute function callees"end)moduleUsers=Kernel_function.Make_Table(Kernel_function.Hptset)(structletname="Users"letsize=17letdependencies=[Eva.Analysis.self;ForceUsers.self]end)letcompute_users_=letprocesskf=ifEva.Results.is_calledkfthenletcallstacks=Eva.Results.(at_start_ofkf|>callstacks)inletprocess_callstackcallstack=letusers=List.tl(List.rev(Eva.Callstack.to_kf_listcallstack))inletprocess_elementuser=ignore(Users.memo~change:(Kernel_function.Hptset.addkf)(fun_->Kernel_function.Hptset.singletonkf)user)inList.iterprocess_elementusersinList.iterprocess_callstackcallstacksinGlobals.Functions.iterprocess;Users.mark_as_computed()letadd_eva_hook()=Eva.Analysis.(register_computation_hook~on:Computedcompute_users)letinit()=ifForceUsers.get()thenadd_eva_hook()let()=Cmdline.run_after_configuring_stageinitletgetkf=letfindkf=tryUsers.findkfwithNot_found->Kernel_function.Hptset.emptyinifUsers.is_computed()thenfindkfelsebeginifEva.Analysis.is_computed()thenbeginfeedback"requiring again the computation of the value analysis";Project.clear~selection:(State_selection.with_dependenciesEva.Analysis.self)()endelsefeedback~level:2"requiring the computation of the value analysis";Eva.Analysis.compute();compute_users();findkfendletprint()=ifForceUsers.get()thenresult"@[<v>====== DISPLAYING USERS ======@ %t\
====== END OF USERS =========="(funfmt->Callgraph.Uses.iter_in_rev_order(funkf->letcallees=getkfinifnot(Kernel_function.Hptset.is_emptycallees)thenFormat.fprintffmt"@[<hov 4>%a: %a@]@ "Kernel_function.prettykf(Pretty_utils.pp_iter~pre:""~sep:"@ "~suf:""Kernel_function.Hptset.iterKernel_function.pretty)callees))letprint_once,_self_print=State_builder.apply_once"Users_register.print"[Users.self]printlet()=Boot.Main.extendprint_once(*
Local Variables:
compile-command: "make -C ../../.."
End:
*)