123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272(**************************************************************************)(* *)(* 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). *)(* *)(**************************************************************************)(* ************************************************************************* *)(** {2 Slicing options} *)(* ************************************************************************* *)includePlugin.Register(structletname="slicing"letshortname="slicing"lethelp="code slicer"end)moduleSelect=structlet()=Parameter_customize.argument_may_be_fundecl()moduleCalls=Kernel_function_set(structletoption_name="-slice-calls"letarg_name="f1, ..., fn"lethelp="select every calls to functions f1,...,fn, and all their effect"end)let()=Parameter_customize.argument_may_be_fundecl()moduleReturn=Kernel_function_set(structletoption_name="-slice-return"letarg_name="f1, ..., fn"lethelp="select the result (returned value) of functions f1,...,fn"end)let()=Parameter_customize.argument_may_be_fundecl()moduleThreat=Kernel_function_set(structletoption_name="-slice-threat"letarg_name="f1, ..., fn"lethelp="select the threats of functions f1,...,fn"end)moduleAssert=Kernel_function_set(structletoption_name="-slice-assert"letarg_name="f1, ..., fn"lethelp="select the assertions of functions f1,...,fn"end)moduleLoopInv=Kernel_function_set(structletoption_name="-slice-loop-inv"letarg_name="f1, ..., fn"lethelp="select the loop invariants of functions f1,...,fn"end)moduleLoopVar=Kernel_function_set(structletoption_name="-slice-loop-var"letarg_name="f1, ..., fn"lethelp="select the loop variants of functions f1,...,fn"end)modulePragma=Kernel_function_set(structletoption_name="-slice-pragma"letarg_name="f1, ..., fn"lethelp="use the slicing pragmas in the code of functions f1,...,fn as \
slicing criteria:\n\
//@ slice pragma ctrl; to reach this control-flow point\n\
//@ slice pragma expr <expr_desc;> to preserve the value of an expression at \
this control-flow point\n\
//@ slice pragma stmt; to preserve the effect of the next statement"end)moduleRdAccess=String_set(structletoption_name="-slice-rd"letarg_name="v1, ..., vn"lethelp="select the read accesses to left-values v1,...,vn \
(addresses are evaluated at the beginning of the function given as \
entry point)"end)moduleWrAccess=String_set(structletoption_name="-slice-wr"letarg_name="v1, ..., vn"lethelp="select the write accesses to left-values v1,...,vn \
(addresses are evaluated at the beginning of the function given as\
entry point)"end)moduleValue=String_set(structletoption_name="-slice-value"letarg_name="v1, ..., vn"lethelp="select the result of left-values v1,...,vn at the end of the \
function given as entry point (addresses are evaluated at the beginning of \
the function given as entry point)"end)endmoduleMode=structmoduleCallers=True(structletoption_name="-slice-callers"lethelp="propagate the slicing to the function callers"end)moduleCalls=Int(structletoption_name="-slicing-level"letdefault=2letarg_name=""lethelp="set the default level of slicing used to propagate to \
the calls\n\
0 : don't slice the called functions\n\
1 : don't slice the called functions but propagate the marks anyway\n\
2 : try to use existing slices, create at most one\n\
3 : most precise slices\n\
note: this value (defaults to 2) is not used for calls to undefined \
functions\n\
except when '-slice-undef-functions' option is set"end)let()=Calls.set_range~min:0~max:3moduleSliceUndef=False(structletoption_name="-slice-undef-functions"lethelp="allow the use of the -slicing-level option for calls \
to undefined functions"end)moduleKeepAnnotations=False(structletoption_name="-slicing-keep-annotations"lethelp="keep annotations as long as the used variables are \
declared and the accessibility of the program point is preserved (even if the \
value of the data is not preserved)"end)endmoduleProjectName=String(structletoption_name="-slicing-project-name"letarg_name="ident"lethelp="name of the slicing project (defaults to \"Slicing\").\
This name is used as basename when building the name of the exported project (see -slicing-exported-project-postfix option)"letdefault="Slicing"end)moduleExportedProjectPostfix=String(structletoption_name="-slicing-exported-project-postfix"letarg_name="postfix"lethelp="postfix added to the slicing project name for building \
the name of the exported project (defaults to \" export\")"letdefault=" export"end)moduleForce=True(structletoption_name="-slice-force"lethelp="force slicing"end)moduleOptionModified=State_builder.Ref(Datatype.Bool)(structletname="Slicing.OptionModified"letdependencies=[]letdefault()=trueend)letwkey_cmdline=register_warn_category"cmdline"let()=set_warn_statuswkey_cmdlineLog.Wabortlet()=State_dependency_graph.add_codependencies~onto:OptionModified.self[Select.Calls.self;Select.Return.self;Select.Threat.self;Select.Assert.self;Select.LoopInv.self;Select.LoopVar.self;Select.Pragma.self;Select.RdAccess.self;Select.WrAccess.self;Select.Value.self;Mode.Callers.self;Mode.Calls.self;Mode.SliceUndef.self;Mode.KeepAnnotations.self]letis_on()=(Force.get()||OptionModified.get())&&(not(Select.Calls.is_empty()&&Select.Return.is_empty()&&Select.Threat.is_empty()&&Select.Assert.is_empty()&&Select.LoopInv.is_empty()&&Select.LoopVar.is_empty()&&Select.Pragma.is_empty()&&Select.RdAccess.is_empty()&&Select.WrAccess.is_empty()&&Select.Value.is_empty()))letset_off()=Force.off();OptionModified.setfalseletclear()=Force.clear();Select.Calls.clear();Select.Return.clear();Select.Threat.clear();Select.Assert.clear();Select.LoopInv.clear();Select.LoopVar.clear();Select.Pragma.clear();Select.RdAccess.clear();Select.WrAccess.clear();Select.Value.clear();OptionModified.clear()(*
Local Variables:
compile-command: "make -C ../../.."
End:
*)