123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* 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). *)(* *)(**************************************************************************)typeformat=Dot|Jsonletoutputformatcontextfilename=letoutput_function=matchformatwith|Dot->Dive_graph.output_to_dot|Json->Server_interface.output_to_jsoninSelf.result"output to %a"Filepath.Normalized.prettyfilename;letout_channel=open_out(filename:>string)inoutput_functionout_channel(Context.get_graphcontext);close_outout_channelletmain()=ifnot(Self.FromBases.is_empty()&&Self.FromFunctionAlarms.is_empty())thenbegin(* Make sure Eva is computed *)Eva.Analysis.compute();(* Create the initial graph *)letcontext=Context.create()in(* Handle parameters *)Self.UnfoldedBases.iter(Context.unfoldcontext);Self.HiddenBases.iter(Context.hidecontext);letdepth=Self.DepthLimit.get()in(* Add targeted vars to it *)letadd_varvi=letnode=Build.add_varcontextviinBuild.explore_backward~depthcontextnodeinSelf.FromBases.iteradd_var;(* Add alarms *)letadd_alarm_emitterkfstmt~rank:_alarm_code_annot=ifSelf.FromFunctionAlarms.memkfthenbeginletnode=Build.add_alarmcontextstmtalarminBuild.explore_backward~depthcontextnodeendinifnot(Self.FromFunctionAlarms.is_empty())thenAlarms.iteradd_alarm;(* Output it *)ifnot(Self.OutputDot.is_empty())thenoutputDotcontext(Self.OutputDot.get());ifnot(Self.OutputJson.is_empty())thenoutputJsoncontext(Self.OutputJson.get());endlet()=Db.Main.extendmain