You can search for identifiers within the package.
in-package search v0.2.0
Source file self.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526(**************************************************************************)(* *)(* SPDX-License-Identifier LGPL-2.1 *)(* Copyright (C) *)(* CEA (Commissariat à l'énergie atomique et aux énergies alternatives) *)(* *)(**************************************************************************)(* Parses a string given to -eva-msg-key or -eva-warn-key into a list of
message or warning category names. *)letparse_categoriess=letcategories=String.split_on_char','sinletparse_names=matchString.split_on_char'='swith|[]->assertfalse(* split_on_char never returns an empty list *)|""::_->None|name::_->matchString.getname0with|'-'|'+'->Some(String.subname1(String.lengthname-1))|_->SomenameinList.filter_mapparse_namecategories(* Split a category "x:y:z" into a list of subcategories "x", "x:y", "x:y:z". *)letsplit_categoryname=letlist=String.split_on_char':'nameinletconcataccelt=letacc=acc^eltinacc^":",accinsnd(List.fold_left_mapconcat""list)letdefault_verbosity=5let()=Plugin.set_default_verbose_leveldefault_verbosityincludePlugin.Register(structletname="Eva"letshortname="eva"lethelp="automatically computes variation domains for the variables of the program"end)let()=add_plugin_output_aliases~visible:false~deprecated:true["value";"val"]let()=Verbose.set_range~min:0~max:11(* ----- Analysis state ----------------------------------------------------- *)(* Do not add dependencies to Kernel parameters here, but at the top of
Parameters. *)letkernel_dependencies=[Ast.self;Alarms.self;Annotations.code_annot_state;]letproxy=State_builder.Proxy.(create"eva"Forwardkernel_dependencies)letstate=State_builder.Proxy.getproxy(* Current state of the analysis *)typecomputation_state=NotComputed|Computing|Computed|AbortedmoduleComputationState=structletto_string=function|NotComputed->"NotComputed"|Computing->"Computing"|Computed->"Computed"|Aborted->"Aborted"modulePrototype=structincludeDatatype.Serializable_undefinedtypet=computation_stateletname="Eva.Analysis.ComputationState"letprettyfmts=Format.pp_print_stringfmt(to_strings)letreprs=[NotComputed;Computing;Computed;Aborted]letdependencies=[state]letdefault()=NotComputedendmoduleDatatype'=Datatype.Make(Prototype)include(State_builder.Ref(Datatype')(Prototype))endexceptionAbortletis_computed()=matchComputationState.get()with|Computed|Aborted->true|NotComputed|Computing->falseletclear_results()=Project.clear~selection:(State_selection.with_dependenciesstate)();(* Explicit clear to apply hooks on changes. *)ComputationState.clear()(* ----- Verbosity configuration -------------------------------------------- *)(* List of message and warn categories manually set by the user via -eva-msg-key
or -eva-warn-key. Here, names of both category kinds are in the same list,
assuming no messages and warnings share the same category name.
In Log, enabled categories are not projectified nor saved on disk, so we
simply use a reference. *)letuser_categories:stringlistref=ref[]letadd_user_categorys=user_categories:=s::!user_categories(* Avoid enabling/disabling categories set by the user. *)letis_used_categoryname=split_categoryname|>List.exists(funname->List.memname!user_categories)(* Hook to register categories set by the user. *)let()=lethook_s=parse_categoriess|>List.iteradd_user_categoryinMessage_category.add_set_hookhook;Warn_category.add_set_hookhookmoduleIntTbl=Hashtbl.Make(Datatype.Int)(* Eva message category can be bound to a verbosity level, at which the key
is automatically enabled. This table binds each verbosity level to the list
of message keys enabled at this level. *)letdkey_by_verbosity:categorylistIntTbl.t=IntTbl.create11(* Some Eva warning categories are feedback by default, and are bound to a
verbosity level, as for message categories. This table binds each verbosity
level to the list of warning keys enabled as feedback at this level. *)letwkey_by_verbosity:warn_categorylistIntTbl.t=IntTbl.create11letregister_key_verbositytblcategorylevel=assert(level>=0&&level<=11);(* No need to register keys with a verbosity level of 0,
as they are always enabled. *)iflevel>0thenletlist=IntTbl.find_default~default:[]tbllevelinIntTbl.replacetbllevel(category::list)(* Enable/disable message and warning categories according to -eva-verbose,
except for categories manually set by the user. *)letconfigure_verbosity()=letlevel=Verbose.get()inletchange_messagepositivecategory=ifnot(is_used_category(dkey_namecategory))then(ifpositivethenadd_debug_keyselsedel_debug_keys)categoryinletenableilist=List.iter(change_message(i<=level))listinIntTbl.iterenabledkey_by_verbosity;letchange_warningpositivewarn_category=ifnot(is_used_category(wkey_namewarn_category))thenletstatus=ifpositivethenLog.WfeedbackelseLog.Winactiveinset_warn_statuswarn_categorystatusinletenableilist=List.iter(change_warning(i<=level))listinIntTbl.iterenablewkey_by_verbosity(* Makes the help message mandatory and adds an optional verbosity level. *)letregister_category?level~helpname=letdefault=Option.fold~none:false~some:((>=)default_verbosity)levelinletcategory=register_category~help~defaultnameinOption.iter(register_key_verbositydkey_by_verbositycategory)level;category(* Default status of warning categories: feedback is associated to a verbosity
level. *)typewarn_default=Inactive|Feedbackofint|Error(* Makes the help message of various categories mandatory, and adds a verbosity
level to the Feedback default status. *)letregister_warn_category~help?defaultname=letdefault,level=matchdefaultwith|None->None,None|SomeInactive->SomeLog.Winactive,None|SomeError->SomeLog.Werror,None|Some(Feedbacklevel)->SomeLog.Wfeedback,Somelevelinletcategory=register_warn_category~help?defaultnameinOption.iter(register_key_verbositywkey_by_verbositycategory)level;category(* ----- Help message about categories -------------------------------------- *)letis_domain_categoryname=Stdlib.String.starts_with~prefix:"d-"nameletprint_all_categories()=letget_infocategory=dkey_namecategory,get_category_helpcategoryinletlist=get_all_categories()|>List.mapget_infoinletlength=Stdlib.String.lengthinletmax=List.fold_left(funm(name,_)->maxm(lengthname))0listinletprint_one_eltfmt(name,help)=Format.fprintffmt"%-*s : @[<hov>%a@]"maxnameFormat.pp_print_texthelpinletis_domain(name,_)=is_domain_categorynameinletdomains,others=List.partitionis_domainlistinfeedback~level:0"@[<v>Standard Eva message categories are:@;%a@]"(Format.pp_print_listprint_one_elt)others;feedback~level:0"@[<v>Additional message categories for printing domain states \
on user directives:@;%a@]"(Format.pp_print_listprint_one_elt)domainsletprint_categories_by_verbosity()=letpp_levellevellist=letis_no_domainc=not(is_domain_category(dkey_namec))inletlist=List.filteris_no_domainlistinprintf~level:0" %2i: %a"level(Pretty_utils.pp_list~sep:" "pp_category)listinfeedback~level:0"Message categories by verbosity:";IntTbl.iter_sortedpp_leveldkey_by_verbosity;printf~level:0"-eva-verbose N automatically enables all message categories \
with a verbosity equal to or less than N. Default to %i."default_verbosityletprint_categories()=print_all_categories();print_categories_by_verbosity();raiseCmdline.Exit(* Hook to register categories set by the user. *)let()=Message_category.add_set_hook(fun_s->ifs="help"thenprint_categories())(* ----- Message categories ------------------------------------------------- *)(* Each message category is automatically enabled at a given level of verbosity:
0: No messages.
1: Minimal general info (starting analysis, etc) and summary.
2: Directives given by user: Frama_C_show_each, split, etc.
3-4: Important information about the analysis: partitioning, imprecisions…
5: Initial and final states.
6-8: Advanced information about automatic behaviors.
9: Additional information such as callstacks in messages.
10: Progress of the analysis (equivalent to -eva-show-progress).
11: All messages (except debug messages).
*)letdkey_show=register_category"show"~level:2~help:"show values/states inferred by the analysis on directives \
such as Frama_C_show_each and Frama_C_dump_each"letdkey_initial_state=register_category"initial-state"~level:5~help:"at the start of the analysis, \
print the initial value of global variables"letdkey_final_states=register_category"final-states"~level:5~help:"at the end of the analysis, print final values inferred \
at the return point of each analyzed function "letdkey_summary=register_category"summary"~level:1~help:"print a summary of the analysis at the end, including coverage \
and alarm numbers"letdkey_pointer_comparison=register_category"pointer-comparison"~level:7~help:"messages about the evaluation of pointer comparisons"letdkey_cvalue_domain=register_category"d-cvalue"~level:0~help:"print states of the cvalue domain"letdkey_iterator=register_category"iterator"~help:"debug messages about the fixpoint engine on the control-flow graph \
of functions"letdkey_widening=register_category"widening"~level:7~help:"print a message at each point where the analysis applies a widening"letdkey_partition=register_category"partition"~level:4~help:"messages about states partitioning"letdkey_split_return=register_category"split-return"~level:4~help:"messages related to option -eva-split-return"letdkey_precision_settings=register_category"precision-settings"~level:3~help:"messages about the automatic configuration of the analysis by \
option -eva-precision"letdkey_progress=register_category"progress"~level:10~help:"messages about the analysis progress in the C code"letdkey_callstacks=register_category"callstacks"~level:9~help:"print the current callstack alongside some messages"letdkey_callstack_hash=register_category"callstack-hash"~level:9~help:"additionally print the current callstack hash in some messages"letdkey_include_string_literal=register_category"include-string-literals"~level:11~help:"when printing a state, \
also include globals representing string literals"(* ----- Warning categories ------------------------------------------------- *)letwkey_alarm=register_warn_category"alarm"~help:"warnings for each possible undefined behavior detected \
by the analysis"letwkey_volatile=register_warn_category"volatile"~help:"a non-volatile lvalue may point to a volatile memory location"letwkey_locals_escaping=register_warn_category"locals-escaping"~help:"a pointer p points to an out of scope local variable \
(any use of p also generates an alarm)"let_wkey_garbled_mix=register_warn_category"garbled-mix"~help:"warnings about very imprecise values inferred for pointers, \
named garbled mix"letwkey_garbled_mix_write=register_warn_category"garbled-mix:write"~help:"the interpretation of an assignment creates a garbled mix"~default:(Feedback3)letwkey_garbled_mix_assigns=register_warn_category"garbled-mix:assigns"~help:"the interpretation of a specification creates a garbled mix"~default:(Feedback3)letwkey_garbled_mix_summary=register_warn_category"garbled-mix:summary"~help:"list the origins of garbled mix at the end of an analysis"~default:(Feedback3)let_wkey_builtins=register_warn_category"builtins"~help:"warnings related to builtins used to interpret some libc functions"letwkey_builtins_missing_spec=register_warn_category"builtins:missing-spec"~help:"the ACSL specification on which a builtin soundness relies is missing"letwkey_builtins_override=register_warn_category"builtins:override"~help:"a builtin overrides a function definition, which is therefore \
not analyzed"let_wkey_libc=register_warn_category"libc"~help:"warnings related to the interpretation of the standard C library"letwkey_libc_unsupported_spec=register_warn_category"libc:unsupported-spec"~help:"the ACSL specification of a libc function is not supported by Eva"let_wkey_loop_unroll=register_warn_category"loop-unroll"~help:"messages about loop unrolling"letwkey_loop_unroll_auto=register_warn_category"loop-unroll:auto"~help:"a loop is automatically unrolled by -eva-auto-loop-unroll"~default:(Feedback4)letwkey_loop_unroll_partial=register_warn_category"loop-unroll:partial"~help:"a loop has been partially but not completely unrolled"~default:(Feedback4)letwkey_missing_loop_unroll=register_warn_category"loop-unroll:missing"~help:"a loop has no unroll annotation"~default:Inactiveletwkey_missing_loop_unroll_for=register_warn_category"loop-unroll:missing:for"~help:"a for loop has no unroll annotation"~default:Inactiveletwkey_signed_overflow=register_warn_category"signed-overflow"~help:"two's complement is used to interpret a signed overflow \
(when signed overflow alarms are disabled)"let_wkey_assigns=register_warn_category"assigns"~help:"warnings related to the interpretation of assigns clauses \
in ACSL specification"letwkey_invalid_assigns=register_warn_category"assigns:invalid-location"~help:"the memory location targeted by an assigns clause is invalid \
in at least one analysis state"~default:(Feedback4)letwkey_missing_assigns=register_warn_category"assigns:missing"~help:"assigns clauses are missing or incomplete from an ACSL \
specification on which the analysis soundness relies"~default:Errorletwkey_missing_assigns_result=register_warn_category"assigns:missing-result"~help:"an assigns \\result clause is missing from an ACSL specification \
on which the analysis soundness relies"letwkey_experimental=register_warn_category"experimental"~help:"an experimental feature of Eva is enabled"letwkey_unknown_size=register_warn_category"unknown-size"~help:"the analysis cannot compute the size of a variable, \
which will thus be very imprecise"letwkey_ensures_false=register_warn_category"ensures-false"~help:"a post-condition evaluates to false; \
there might be an error in the specification"letwkey_watchpoint=register_warn_category"watchpoint"~help:"undocumented"~default:(Feedback2)letwkey_recursion=register_warn_category"recursion"~help:"a recursive call is analyzed"~default:(Feedback3)letwkey_acsl=register_warn_category"acsl"~help:"messages about evaluation of ACSL terms and predicates"~default:(Feedback4)letwkey_acsl_unsupported=register_warn_category"acsl:unsupported"~help:"messages about ACSL terms not supported by Eva"~default:(Feedback4)(* ----- Log with positions ------------------------------------------------- *)type'apretty_printer=?emitwith:(Log.event->unit)->?once:bool->?pos:Position.t->?current:bool->?source:Filepos.t->?stacktrace:bool->?append:(Format.formatter->unit)->?echo:bool->('a,Format.formatter,unit)format->'atype('a,'b)pretty_aborter=?pos:Position.t->?current:bool->?source:Filepos.t->?stacktrace:bool->?append:(Format.formatter->unit)->?echo:bool->('a,Format.formatter,unit,'b)format4->'aletappend_callstack?(stacktrace=false)?append~callstackfmt=letpretty_hashfmtcs=ifis_debug_key_enableddkey_callstack_hashthenFormat.fprintffmt"<%a> "Callstack.pretty_hashcsinOption.iter(funappend->appendfmt)append;ifstacktrace&&is_debug_key_enableddkey_callstacksthenmatchcallstackwith|None->()|Somecs->(* note: the "\n" before the pretty print of the stack is required by:
FRAMAC_LIB/analysis-scripts/make_wrapper.py *)Format.fprintffmt"@\nstack: @[<hv>%a%a@]"pretty_hashcsCallstack.prettycsletlift_aborter(aborter:('a,'b)Log.pretty_aborter):('a,'b)pretty_aborter=fun?pos?current?source?stacktrace?append->(* Extract source location *)matchposwith|Somepos->letcallstack=Position.callstackposinletsource=Option.value~default:(Position.pospos)source(* Append callstack if requested *)andappend=append_callstack?stacktrace?append~callstackinaborter?current:None~source~append|None->letcallstack=Current_callstack.get()inletappend=append_callstack?stacktrace?append~callstackinaborter?current?source~appendletlift_printer(printer:'aLog.pretty_printer):'apretty_printer=fun?emitwith?once->lift_aborter(printer?emitwith?once)letresult?level?dkey=lift_printer(result?level?dkey)letfeedback?ontty?level?dkey=lift_printer(feedback?ontty?level?dkey)letdebug?level?dkey=lift_printer(debug?level?dkey)letwarning?wkey:'apretty_printer=lift_printer(warning?wkey)letalarm?emitwith=warning~wkey:wkey_alarm?emitwithleterror?emitwith=lift_printererror?emitwithletabort?pos=lift_aborterabort?posletfailure?emitwith=lift_printerfailure?emitwithletfatal?pos=lift_aborterfatal?pos