123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136(**************************************************************************)(* *)(* 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). *)(* *)(**************************************************************************)openCil_typesincludePlugin.Register(structletname="dive"letshortname="dive"lethelp="An interactive imprecision graph generator for Eva."end)moduleOutputDot=Filepath(structletoption_name="-dive-output-dot"letarg_name="output.dot"letfile_kind="DOT"letexistence=Fc_Filepath.Indifferentlethelp="Outputs the built graph in DOT format to the specified file."end)moduleOutputJson=Filepath(structletoption_name="-dive-output-json"letarg_name="output.json"letfile_kind="JSON"letexistence=Fc_Filepath.Indifferentlethelp="Outputs the built graph in JSON format to the specified."end)moduleDepthLimit=Int(structletoption_name="-dive-depth-limit"lethelp="Build dependencies up to a depth of N."letarg_name="N"letdefault=3end)moduleFromFunctionAlarms=Kernel_function_set(structletoption_name="-dive-from-alarms"lethelp="Build the graph from the alarms emitted in the given functions."letarg_name="f1,..."end)moduleVarinfo=structincludeCil_datatype.Varinfoletof_strings=letregexp=Str.regexp"^\\([_a-zA-Z0-9]+\\)::\\([_a-zA-Z0-9]+\\)$"inifStr.string_matchregexps0thenletfunction_name=Str.matched_group1sandvariable_name=Str.matched_group2sinletkf=tryGlobals.Functions.find_by_namefunction_namewithNot_found->raise(Cannot_build("no function '"^function_name^"'"))intryGlobals.Vars.find_from_astinfovariable_name(Whole_functionkf)withNot_found->tryGlobals.Vars.find_from_astinfovariable_name(Formalkf)withNot_found->raise(Cannot_build("no variable '"^variable_name^"' in function "^function_name))elseletregexp=Str.regexp"^[_a-zA-Z0-9]+$"inifnot(Str.string_matchregexps0)thenraise(Cannot_build("wrong syntax: '"^s^"'"));matchGlobals.Syntactic_search.find_in_scopesCil_types.Programwith|Somevi->vi|None->raise(Cannot_build("no global variable '"^s^"'"))letto_stringvi=matchKernel_function.find_defining_kfviwith|None->vi.vname|Somekf->Kernel_function.get_namekf^"::"^vi.vnameletof_singleton_string=no_element_of_stringendmoduletypeVarinfo_set=Parameter_sig.Setwithtypeelt=Cil_types.varinfoandtypet=Cil_datatype.Varinfo.Set.tmoduleVarinfo_set(X:Parameter_sig.Input_with_arg)=Make_set(Varinfo)(structincludeXletdependencies=[]letdefault=Cil_datatype.Varinfo.Set.emptyend)moduleFromBases=Varinfo_set(structletoption_name="-dive-from-variables"lethelp="Build the graph from these local variables."letarg_name="f::v,..."end)moduleUnfoldedBases=Varinfo_set(structletoption_name="-dive-unfold"lethelp="Defines the composite variables which should be \
unfolded into individual cells."letarg_name="f::v,..."end)moduleHiddenBases=Varinfo_set(structletoption_name="-dive-hide"lethelp="Defines the variables which must not be \
displayed in the graph. The dependencies for these bases \
are not computed either."letarg_name="f::v,..."end)